Skip to content
RCE Advisory Advanced CVE-2020-17530

GHSL-2020-205: Remote Code Execution in Apache Struts 2 - S2-061 - CVE-2020-17530

Apache Struts 2 performs double or triple evaluation of dynamic tag attributes, allowing an attacker to inject OGNL expressions that are executed. This can lead to remote code execution.

Alvaro Muñoz Follow

Originally disclosed on GitHub Security Lab

Double evaluation of Struts tag dynamic attributes leads to Remote Code Execution

pwntester, on GitHub Security Lab

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 report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, dynamic attributes are evaluated once when set and again when rendered, and FreeMarker and Velocity tags add extra evaluations, so user-controlled input can be evaluated multiple times.

Impact

This issue may lead to remote code execution.

What the attacker needed

A Struts 2 application using affected tags; Attacker can control a parameter used in a dynamic attribute

The fix

The issue was fixed in Struts 2.5.26.

How it was found

  1. Visit a URL with a parameter containing a percent-encoded OGNL expression.
  2. The parameter is evaluated by the tag's setDynamicAttribute method.
  3. The result is evaluated again by the FreeMarker template's translateVariables.
  4. The expression executes, potentially running arbitrary 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 report has not been written yet. The Original tab links to the source.

Apache Struts is a framework for building Java web applications. It uses a language called OGNL to evaluate expressions in web pages. The bug is that some user input gets evaluated twice, so an attacker can sneak in a malicious expression that gets run as code on the server.

What is RCE?

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

More by Alvaro Muñoz

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

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.