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.
Originally disclosed on GitHub Security Lab
Double evaluation of Struts tag dynamic attributes leads to Remote Code Execution
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
- Visit a URL with a parameter containing a percent-encoded OGNL expression.
- The parameter is evaluated by the tag's setDynamicAttribute method.
- The result is evaluated again by the FreeMarker template's translateVariables.
- 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.