Skip to content
RCE Write-up Advanced

Gregor Samsa: Exploiting Java's XML Signature Verification

Java's XSLTC compiler, used during XML signature verification, fails to limit the size of the constant pool, so a stylesheet with many constants causes an integer truncation when the class file is serialised. An attacker could supply a crafted XSLT transform inside a SAML response to achieve arbitrary code execution in Java-based identity providers and web applications.

Felix Wilhelm Follow

Published on googleprojectzero.blogspot.com

Earlier this year, I discovered a surprising attack surface hidden deep inside Java’s standard library: A custom JIT compiler processing untrusted XSLT programs, exposed to remote attackers during XML signature verification. This post discusses CVE-2022-34169, an integer truncation bug in this JIT compiler resulting…

Felix Wilhelm (@_fel1x), on googleprojectzero.blogspot.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 constant pool count is truncated to a 16-bit value when the class file is serialised, while the full attacker-controlled pool is still written out, so pool entries are reinterpreted as class fields.

Impact

An attacker who can get a crafted XSLT transform processed during signature verification could achieve arbitrary code execution, though the text notes the attack requires a valid signature for the SignedInfo element and that secure validation settings can block XSLT transforms.

What the attacker needed

Attacker-controlled XSLT in a signed XML document; valid signature on SignedInfo; secure validation disabled

The fix

OpenJDK fixed the issue in July 2022 and the Apache BCEL project released a patch in September 2022.

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.

SAML is a single-sign-on standard where a login provider sends a signed XML document to an application. To check the signature, Java runs a transformation program (XSLT) that the sender controls, and Java compiles that program into a class file. A counting field in that class file is only two bytes wide, so a program with too many constants makes the count wrap around and the extra data is misread as class structure, letting an attacker shape what the JVM loads.

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.