SAP Customers: Make sure your SAPJVM is up to date!
SAP NetWeaver Java deserialised untrusted data sent over the p4 protocol, allowing an unauthenticated attacker to execute arbitrary code via a crafted serialised object using the Jdk7u21 gadget. Successful exploitation could lead to full host compromise and potentially wider SAP landscape compromise.
Code White have already an impressive publication record on Java Deserialization. This post is dedicated to a vulnerability in SAP NetWeaver Java.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the p4 protocol deserialised attacker-controlled Java objects without adequate filtering, and the bundled SAP JVM contained the Jdk7u21 gadget chain.
Impact
An unauthenticated attacker could execute arbitrary code, read secure storage, access the database, create an administrative NetWeaver user, and potentially compromise the wider SAP landscape; the exploit was verified on specific SAP JVM versions, and newer versions patched the gadget.
What the attacker needed
Network access to p4; vulnerable SAP JVM version; no authentication required
The fix
SAP JVM was updated to patch the AnnotationInvocationHandler and later adopted JEP 290 serialisation filtering; users should also block p4 on their firewall and keep the SAP JVM up to date.
How it was found
- Obtain a p4 test client and capture its network traffic.
- Identify the serialised object and the message block length encoding.
- Build a script that sends the byte arrays in order, reads replies, and sets the dynamic header words.
- Replace the serialised object with a ysoserial Jdk7u21 payload adapted to the custom serializer.
- Send the crafted message to the target and observe code execution.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Java can turn data into live objects, a process called deserialisation. If a program deserialises data from an untrusted source, an attacker can craft that data so that creating the object runs their own code. Here, the p4 network protocol carried such data without authentication, so an attacker could run commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.