WebLogic EJBTaglibDescriptor XXE漏洞(CVE-2019-2888)分析
作者:Longofo@知道创宇404实验室
时间:2019年10月16日
这个漏洞和之前@Matthias Kaiser提交的几个XXE漏洞是类似的,而EJBTaglibDescriptor
应该是漏掉的一个,可以参考之前几个XXE的分析。我和@Badcode师傅反编译了WebLogic所有的Jar包,根据之前几个XXE漏洞的特征进行了搜索匹配到了这个EJBTaglibDescriptor类,这个类在反序列化时也会进行XML解析。
Oracle发布了10月份的补丁,详情见链接(https://www.oracle.com/technetwork/security-advisory/cpuoct2019-5072832.html)
环境
- Windows 10
- WebLogic 10.3.6.0.190716(安装了19年7月补丁)
- Jdk160_29(WebLogic 自带的JDK)
漏洞分析
weblogic.jar!\weblogic\servlet\ejb2jsp\dd\EJBTaglibDescriptor.class
这个类继承自java\io\Externalizable

因此在序列化与反序列化时会自动调用子类重写的writeExternal
与readExternal
看下writeExternal
的逻辑与readExternal
的逻辑,

在readExternal
中,使用ObjectIutput.readUTF
读取反序列化数据中的String数据,然后调用了load方法,

在load方法中,使用DocumentBuilder.parse
解析了反序列化中传递的XML数据,因此这里是可能存在XXE漏洞的
在writeExternal
中,调用了本身的toString
方法,在其中又调用了自身的toXML
方法


toXML
的作用应该是将this.beans
转换为对应的xml数据。看起来要构造payload稍微有点麻烦,但是序列化操作是攻击者可控制的,所以我们可以直接修改writeExternal
的逻辑来生成恶意的序列化数据:

漏洞复现
1.重写 EJBTaglibDescriptor
中的writeExternal
函数,生成payload

2.发送payload到服务器

在我们的HTTP服务器和FTP服务器接收到了my.dtd的请求与win.ini的数据

3.在打了7月份最新补丁的服务器上能看到报错信息


本文由 Seebug Paper 发布,如需转载请注明来源。本文地址:https://paper.seebug.org/1067/