Skip to content
RCE Write-up Advanced

CVE-2019-0230: Apache Struts OGNL Remote Code Execution

Apache Struts forced a second OGNL evaluation of tag attributes such as id when they came from raw user input, and the class/package blocklist could be bypassed with existing gadgets. An attacker could send a crafted request to run arbitrary code with the server's privileges.

thezdi.com

Published on thezdi.com

A remote code execution has been reported in the Apache Struts framework. The vulnerability is due to insufficient input validation leading to a forced double Object Graph Navigation Library (OGNL) evaluation when evaluating raw user input.

The author, on thezdi.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 alt-syntax forced evaluation of tag attributes caused a second OGNL evaluation of user input, and the class/package exclusions did not cover gadget classes such as FreeMarker's TaglibFactory and Guice's ContainerBuilder.

Impact

Successful exploitation could result in the execution of arbitrary code with the privileges of the server.

What the attacker needed

Vulnerable Struts version before 2.5.22; app passes raw user input into a tag attribute; attacker can send HTTP requests to the server

The fix

It was fixed in Struts 2.5.22 by validating each incoming value and how it is used in tag attributes, and developers are advised not to force evaluation of attributes other than value.

How it was found

  1. Send a crafted HTTP request containing a malicious parameter to a vulnerable Struts server.
  2. The parameter value is placed into a tag attribute such as id and evaluated once during populateParams().
  3. The same attribute is evaluated again during evaluateParams() via findStringIfAltSyntax().
  4. Use the FreeMarker TaglibFactory and Guice ContainerBuilder gadgets to obtain restricted classes.
  5. Load and define an arbitrary class, or write a JSP file into the web root, to run code.

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.

Struts is a Java framework for building web pages. It can evaluate small expressions written in a mini-language called OGNL to fill in page content, and it sometimes evaluates the same value twice. If a user-supplied value is evaluated as an expression, the attacker can make the server run their own code.

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.