很遗憾地告诉大家,本次更新实际上并没有真实地修复该反序列化安全漏洞,仅是增加了安全检查:仅要求配置系统属性,属性名称为“org.apache.commons.collections.enableUnsafeSerialization”,属性值为“true”,否则会抛出UnsupportedOperationException异常。
分析过程: 由于手上没有3.2.1版本的源代码,因此采用的是反编译3.2.1和本次的3.2.2版本jar包,然后使用对比工具 对比反编译后的源代码,得出下面的结果:在 org.apache.commons.collections.functors.FunctorUtils 类中新增加检查属性配置代码如下(注意该新增方法的可访问性是包内可访问):
static void checkUnsafeSerialization(Class clazz) { String unsafeSerializableProperty; try { unsafeSerializableProperty = (String) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty("org.apache.commons.collections.enableUnsafeSerialization"); } }); } catch (SecurityException ex) { unsafeSerializableProperty = null; } if (!"true".equalsIgnoreCase(unsafeSerializableProperty)) { throw new UnsupportedOperationException("Serialization support for " + clazz.getName() + " is disabled for security reasons. " + "To enable it set system property '" + "org.apache.commons.collections.enableUnsafeSerialization" + "' to 'true', " + "but you must ensure that your application does not de-serialize objects from untrusted sources."); } }
在该包下的若干实现类中增加了如下两个私有方法:
private void writeObject(ObjectOutputStream os) throws IOException { FunctorUtils.checkUnsafeSerialization(CloneTransformer.class); os.defaultWriteObject(); } private void readObject(ObjectInputStream is) throws ClassNotFoundException, IOException { FunctorUtils.checkUnsafeSerialization(CloneTransformer.class); is.defaultReadObject(); }
(以上两个私有方法初步估计是通过反射调用的)
总结: 除了其他方面的bug更新以外,针对此次的反序列化安全问题并没有得到解决,因为想要正常使用的话,你会被强制要求配置上述系统属性。来自乌云的反序列化安全漏洞分析报告: http://drops.wooyun.org/papers/10467