Skip to content
RCE Write-up Advanced

Java Deserialization Tricks

During a red team engagement, Java applications accepted untrusted serialized data, allowing a known gadget chain to reach remote code execution. A WAF and an EDR blocked the first exploit, so the author describes modified gadget chains that inject custom Java classes instead of spawning shell commands, letting data be exfiltrated without detection.

Clément Amic Follow

Published on synacktiv.com

Written by Clément Amic - 19/03/2024 - in Pentest - Download

Clément Amic (@loadlow), on synacktiv.com

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 deserialized untrusted user-supplied data, letting attacker-controlled object graphs reach dangerous JDK and library classes that execute code.

Impact

An attacker could run arbitrary code on the server and exfiltrate data, though a WAF and an EDR blocked the first, noisy exploit and strict outbound filtering including DNS limited exfiltration.

What the attacker needed

Vulnerable Java app deserializes user data; a usable gadget chain on the classpath; ability to send serialized data to the app

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 rebuild objects from a stream of bytes, and if an app rebuilds objects sent by a user, an attacker can craft bytes that make the app run code of the attacker's choosing. This is called deserialization, and a 'gadget chain' is a sequence of existing classes that, when rebuilt, ends up executing something. Here the attacker already had a working chain but security tools spotted it, so the article shows quieter variants.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.