提交 701ea95a 编写于 作者: D Daniel Beck

[SECURITY-503] Prevent deserialization of void/Void

上级 d5dd69be
......@@ -145,6 +145,9 @@ public class XStream2 extends XStream {
// list up types that should be marshalled out like a value, without referential integrity tracking.
addImmutableType(Result.class);
// http://www.openwall.com/lists/oss-security/2017/04/03/4
denyTypes(new Class[] { void.class, Void.class });
registerConverter(new RobustCollectionConverter(getMapper(),getReflectionProvider()),10);
registerConverter(new RobustMapConverter(getMapper()), 10);
registerConverter(new ImmutableMapConverter(getMapper(),getReflectionProvider()),10);
......
......@@ -28,6 +28,7 @@ import static org.junit.Assert.*;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.thoughtworks.xstream.XStreamException;
import com.thoughtworks.xstream.security.ForbiddenClassException;
import hudson.XmlFile;
import hudson.model.Result;
import hudson.model.Run;
......@@ -296,4 +297,15 @@ public class XStream2Test {
assertEquals("3.2.1", XStream2.trimVersion("3.2.1"));
assertEquals("3.2-SNAPSHOT", XStream2.trimVersion("3.2-SNAPSHOT (private-09/23/2012 12:26-jhacker)"));
}
@Issue("SECURITY-503")
@Test
public void crashXstream() throws Exception {
try {
new XStream2().fromXML("<void/>");
fail("expected to throw ForbiddenClassException, but why are we still alive?");
} catch (ForbiddenClassException ex) {
// pass
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册