Remote Code Execution Vulnerability in libxstream-java: CVE-2021-39148
Summary
CVE-2021-39148: XStream is a simple library to serialize objects to XML and back again. Affects libxstream-java across 2 version ranges.
< 1.4.15-3+deb11u1
< b9ad1c02724c2b1636a8794c8e1bcd630f46c0b3
Fixed in 1.4.15-3+deb11u1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
libxstream-java is a library that facilitates the serialization of Java objects to XML and vice versa. It is widely used in various applications for its simplicity and efficiency in handling XML data. However, the library has been found to have a critical vulnerability that can be exploited if not properly configured, allowing unauthorized remote code execution.
Vulnerability Detail
CVE-2021-39148 is a vulnerability in the XStream library that allows remote attackers to load and execute arbitrary code from a remote host by manipulating the processed input stream. This issue arises from the library's default configuration, which no longer employs a blacklist for security. If users do not implement the recommended security framework with a whitelist of minimal required types, they may expose their applications to significant risks, including unauthorized access and data compromise.
How To Fix
Minimum fixed version
1.4.15-3+deb11u1
This is the first release that contains the fix.
sudo apt-get install --only-upgrade libxstream-java
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, users can implement a security framework that restricts the types of objects that can be deserialized by XStream. This can be achieved by using the following code snippet:
XStream xstream = new XStream();
// Add allowed classes to the whitelist
xstream.allowTypes(new Class[]{AllowedClass1.class, AllowedClass2.class});
This code ensures that only the specified classes can be processed, mitigating the risk of remote code execution.
Conclusion
CVE-2021-39148 represents a significant security risk for applications using the libxstream-java library. By understanding the nature of this vulnerability and taking appropriate action, such as upgrading to the latest versions and configuring security settings, developers can protect their applications from potential attacks.
See every vulnerability recorded for libxstream-java →
FAQ
CVE-2021-39148 is a vulnerability in the XStream library that allows remote code execution through manipulated input streams.
Affected versions include all versions prior to 1.4.15-3+deb11u1 for Debian 11 and 1.4.18-1 for Debian 12 and 13.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
The CVSS score of CVE-2021-39148 is 8.5, indicating a high severity level.
If immediate upgrading is not possible, implement a security framework that whitelists allowed classes to mitigate the risk of exploitation.
Related vulnerabilities
Recent vulnerabilities recorded for libxstream-java.