CVE-2021-21344 - Deserialization of Untrusted Data

Severity

98%

Complexity

39%

Confidentiality

98%

XStream is a Java library to serialize objects to XML and back again. In XStream before version 1.4.16, there is a vulnerability which may allow a remote attacker to load and execute arbitrary code from a remote host only by manipulating the processed input stream. No user is affected, who followed the recommendation to setup XStream's security framework with a whitelist limited to the minimal required types. If you rely on XStream's default blacklist of the Security Framework, you will have to use at least version 1.4.16.

CVSS 3.1 Base Score 9.8. CVSS Attack Vector: network. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

CVSS 2.0 Base Score 7.5. CVSS Attack Vector: network. CVSS Attack Complexity: low. CVSS Vector: (AV:N/AC:L/Au:N/C:P/I:P/A:P).

Demo Examples

Deserialization of Untrusted Data

CWE-502

This code snippet deserializes an object from a file and uses it as a UI button:


               
}
in.close();

This code does not attempt to verify the source or contents of the file before deserializing it. An attacker may be able to replace the intended file with a file that contains arbitrary malicious code which will be executed when the button is pressed.

To mitigate this, explicitly define final readObject() to prevent deserialization. An example of this is:


               
throw new java.io.IOException("Cannot be deserialized"); }

Deserialization of Untrusted Data

CWE-502

In Python, the Pickle library handles the serialization and deserialization processes. In this example derived from [R.502.7], the code receives and parses data, and afterwards tries to authenticate a user based on validating a token.


               
}
raise AuthFail

Unfortunately, the code does not verify that the incoming data is legitimate. An attacker can construct a illegitimate, serialized object "AuthToken" that instantiates one of Python's subprocesses to execute arbitrary commands. For instance,the attacker could construct a pickle that leverages Python's subprocess module, which spawns new processes and includes a number of arguments for various uses. Since Pickle allows objects to define the process for how they should be unpickled, the attacker can direct the unpickle process to call Popen in the subprocess module and execute /bin/sh.

Demo Examples

Unrestricted Upload of File with Dangerous Type

CWE-434

The following code intends to allow a user to upload a picture to the web server. The HTML code that drives the form on the user end has an input field of type "file".


               
</form>

Once submitted, the form above sends the file to upload_picture.php on the web server. PHP stores the file in a temporary location until it is retrieved (or discarded) by the server side code. In this example, the file is moved to a more permanent pictures/ directory.


               
}// Define the target location where the picture being// uploaded is going to be saved.// Move the uploaded file to the new location.
echo "The picture has been successfully uploaded.";
echo "There was an error uploading the picture, please try again.";

The problem with the above code is that there is no check regarding type of file being uploaded. Assuming that pictures/ is available in the web document root, an attacker could upload a file with the name:


               
malicious.php

Since this filename ends in ".php" it can be executed by the web server. In the contents of this uploaded file, the attacker could use:


               
?>
system($_GET['cmd']);

Once this file has been installed, the attacker can enter arbitrary commands to execute using a URL such as:


               
http://server.example.com/upload_dir/malicious.php?cmd=ls%20-l

which runs the "ls -l" command - or any other type of command that the attacker wants to specify.

Unrestricted Upload of File with Dangerous Type

CWE-434

The following code demonstrates the unrestricted upload of a file with a Java servlet and a path traversal vulnerability. The HTML code is the same as in the previous example with the action attribute of the form sending the upload file request to the Java servlet instead of the PHP code.


               
</form>

When submitted the Java servlet's doPost method will receive the request, extract the name of the file from the Http request header, read the file contents from the request and output the file to the local upload directory.


               
}
{...}
// output successful upload response HTML page
bw.close();
}
bw.flush();
...

As with the previous example this code does not perform a check on the type of the file being uploaded. This could allow an attacker to upload any executable file or other file with malicious code.

Additionally, the creation of the BufferedWriter object is subject to relative path traversal (CWE-22, CWE-23). Depending on the executing environment, the attacker may be able to specify arbitrary files to write to, leading to a wide variety of consequences, from code execution, XSS (CWE-79), or system crash.

Overview

First reported 3 years ago

2021-03-23 00:15:00

Last updated 3 years ago

2021-11-30 22:09:00

Affected Software

Debian Linux 9.0

9.0

Oracle Communications Policy Management 12.5.0

12.5.0

Oracle Communications Unified Inventory Management 7.3.2

7.3.2

Oracle Communications Unified Inventory Management 7.3.4

7.3.4

Oracle Communications Unified Inventory Management 7.3.5

7.3.5

Oracle Communications Unified Inventory Management 7.4.0

7.4.0

Oracle WebCenter Portal 11.1.1.9.0

11.1.1.9.0

Oracle WebCenter Portal 12.2.1.3.0

12.2.1.3.0

References

http://x-stream.github.io/changes.html#1.4.16

https://github.com/x-stream/xstream/security/advisories/GHSA-59jw-jqf4-3wq3

https://x-stream.github.io/CVE-2021-21344.html

https://x-stream.github.io/security.html#workaround

http://x-stream.github.io/changes.html#1.4.16

Release Notes, Third Party Advisory

https://github.com/x-stream/xstream/security/advisories/GHSA-59jw-jqf4-3wq3

Third Party Advisory

https://x-stream.github.io/CVE-2021-21344.html

Exploit, Third Party Advisory

https://x-stream.github.io/security.html#workaround

Mitigation, Third Party Advisory

[debian-lts-announce] 20210403 [SECURITY] [DLA 2616-1] libxstream-java security update

[jmeter-dev] 20210406 [GitHub] [jmeter] sseide opened a new pull request #655: update x-stream to 1.4.16 (from 1.4.15)

[debian-lts-announce] 20210403 [SECURITY] [DLA 2616-1] libxstream-java security update

Mailing List, Third Party Advisory

[jmeter-dev] 20210406 [GitHub] [jmeter] sseide opened a new pull request #655: update x-stream to 1.4.16 (from 1.4.15)

Mailing List, Third Party Advisory

[activemq-users] 20210427 Release date for ActiveMQ v5.16.2 to fix CVEs

Mailing List, Third Party Advisory

https://security.netapp.com/advisory/ntap-20210430-0002/

https://security.netapp.com/advisory/ntap-20210430-0002/

Third Party Advisory

N/A

FEDORA-2021-fbad11014a

FEDORA-2021-d894ca87dc

https://www.oracle.com/security-alerts/cpuoct2021.html

FEDORA-2021-5e376c0ed9

DSA-5004

N/A

Third Party Advisory

FEDORA-2021-fbad11014a

Mailing List, Third Party Advisory

FEDORA-2021-d894ca87dc

Mailing List, Third Party Advisory

https://www.oracle.com/security-alerts/cpuoct2021.html

Third Party Advisory

FEDORA-2021-5e376c0ed9

Mailing List, Third Party Advisory

DSA-5004

Third Party Advisory

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.