Skip to content
RCE Write-up Advanced

Finding gadgets like it's 2015: part 2

A new Java deserialization gadget chain was found in the Mojarra JSF library that allows arbitrary code execution via Expression Language when an attacker can trigger deserialization of untrusted data. The chain uses the AttributesMap class to evaluate a controlled ValueExpression.

synacktiv.com

Published on synacktiv.com

Rédigé par Hugo Vincent - 28/10/2021 - dans - Téléchargement

The author, 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

The AttributesMap class in Mojarra deserializes a ValueExpression and later evaluates it without proper validation, allowing code execution when the map's get method is called during deserialization.

Impact

An attacker who can trigger deserialization of untrusted data in an application using Mojarra JSF can achieve arbitrary code execution.

What the attacker needed

Application deserializes untrusted data; Mojarra JSF library version 2.3 or 3.0

How it was found

  1. Identify that the application deserializes untrusted data.
  2. Use gadget-inspector to find potential gadget chains in libraries.
  3. Manually analyze the AttributesMap class and discover that its get method evaluates a ValueExpression.
  4. Construct an AttributesMap with a malicious ValueExpression using Java reflection.
  5. Combine with a Hashtable and another Map to trigger the get method during deserialization.
  6. Add a dummy ValueExpression to resolve class loading issues and achieve 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 applications sometimes turn data back into objects, a process called deserialization. If an attacker can supply the data, they might craft it so that the objects created during deserialization run harmful code. This report found a new way to do that in a common library, but it only works if the application deserializes untrusted input.

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.