by Manish Sardiwal
In mid of August, Apache released a security bulletin S2-059 to address a vulnerability CVE-2019-0230. CVE-2019-0230 is an OGNL expression language vulnerability, which may lead to Remote Code Execution in the context of Apache Server process. Object-Graph Navigation Language (OGNL) is an expression language for Java which is used to get and set properties and execute methods of Java classes in Java web applications. Expression language is a popular and widely used language in web applications, but it also has security flaws due to its capability of creating and executing codes. In this blog we will discuss exploitation of this vulnerability and detection by Prismo.
Exploitation details of CVE-2019-0230 The vulnerability is in using ognl expression syntax in Apache Struts tag attributes. If an application is using ognl expression syntax in Struts tag attributes, it gets evaluated as an ognl expression. If the input value for such attributes is getting modified or controlled from user input, an attacker can send a crafted input to execute malicious ognl expression. A working exploit POC and test application was released on github after the release of Apache security advisory. In the following statement the “id” attribute is evaluated as an ognl expression, if the value of ‘id’ is getting modified using raw and unsanitized user input, an attacker can send a crafted request to exploit it and execute malicious ognl expression. <s:a id="%{id}" href="onlytest">CVE-2019-0230 Exploit</s:a> The following HTTP request to POC test application is leading to remote code execution and listing the files in the current directory. The “id” parameter of HTTP GET request is consumed as input value for the “id” attribute of Struts “a” tag. This results in executing malicious expression language string in the context of the Apache server process.
The exploitation of this vulnerability depends on how the web application is consuming the user input in struts tag attributes. The http request parameter can be different and requires to be application specific.