Jackson CVE-2019-12384: anatomy of a vulnerability class
An application used Jackson's polymorphic type handling to deserialise untrusted JSON, letting an attacker choose which Java class was instantiated. By selecting a logback class that opens a JDBC connection, the attacker could trigger SSRF and, with the H2 driver, run arbitrary code.
blog.doyensec.com
Published on blog.doyensec.com
During one of our engagements, we analyzed an application which used the Jackson library for deserializing JSONs. In that context, we have identified a deserialization vulnerability where we could control the class to be deserialized.
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 application enabled Jackson's default typing so that a JSON property could name any class, and Jackson's blacklist did not cover the logback and H2 classes used in the chain.
Impact
An attacker who controls the JSON could cause SSRF and, when the H2 driver is present, execute arbitrary code in the application's context.
What the attacker needed
Attacker controls JSON sent to the app; default typing enabled; a gadget class on the classpath; Jackson version not blocking it
The fix
Jackson should block the gadget classes and applications should avoid default typing on untrusted input, but the text does not say a fix was applied.
How it was found
- Configure Jackson with default typing so a JSON property can name the class to instantiate.
- Send JSON naming the logback DriverManagerConnectionSource class with a JDBC URL.
- Jackson calls the setters, then the getConnection getter opens the JDBC connection, giving SSRF.
- Point the JDBC URL at an H2 in-memory database that runs an init script from a remote HTTP server.
- The init script creates a Java alias that executes a shell command, giving 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.
Some Java programs turn JSON text into live objects and let the sender name the class to build. If that name is not checked, an attacker can pick a class with a dangerous side effect, such as opening a network connection or running a database script. Here that led to the server making requests on the attacker's behalf and eventually running commands.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.