Exploiting OGNL Injection

Recently during a penetration test Burp Suite reported a “Expression Language Injection” issue.

Burp Suite recognizes the issue thanks to the following payload:

gk6q${“zkz”.toString().replace(“k”, “x”)}doap2

The value returned was “igk6qzxzdoap2”, indicating of the execution of the expression.

From an analysis of the returned stack trace and from the results of various failed EL Injection payloads, we understood that we faced with a OGNL Injection of Apache Struts.

After some researches, we discovered that J2EEScan contains a detection payload for this particular issue, but in our situation the check failed, because the vector currently is inserted only in a specifica parameter (“method”) and not in all application entry points.

After some coding work, we succeeded in getting some working vectors for the detection (direct and blind) and for the exploitation (local file include, directory listing and remote code execution). To simplify the detection and the exploitation, we added an additional parameter, “INJPARAM”, used to insert the commands comfortably in the exploit vectors.

And now, let’s look at the exploit vectors. Those are the detection vectors:

    • J2EEScan Detection vector (sobstitute the content of the response body with the content of the “INJPARAM” parameter concatenated with a sum of integer):

    • Blind detection vector (sleep during 10 seconds):

Those are the exploitation vectors:

    • Remote file inclusion:

    • Directory listing:

    • Remote code execution (Linux):

    • Remote code execution (Windows – NOT TESTED):

Probably this particular issue has been reported as CVE-2016-3081.

Enjoy!