Denial of Service Vulnerability in libxstream-java: XStream Library CPU Exhaustion Risk
Summary
CVE-2021-21341: XStream is a Java library to serialize objects to XML and back again. Affects libxstream-java across 4 version ranges.
< 1.4.15-2
< 3dd9cc610199802e4f13bd49b02a9f99adaba145
< 7153c74dd0e860d0ca3825cc5a23e976e0242b6e
< a0d4141a00ba5de4afaee160836898b41eb28065
Fixed in 1.4.15-2. 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
XStream is a widely used Java library that facilitates the serialization of objects to XML and vice versa. It is known for its flexibility and ease of use, allowing developers to convert Java objects into XML format seamlessly. However, the library has been found to be vulnerable to a specific issue that can lead to significant performance degradation, particularly under certain input conditions.
Vulnerability Detail
In XStream versions prior to 1.4.16, a vulnerability exists that may allow a remote attacker to manipulate the processed input stream, potentially leading to 100% CPU utilization on the target system. This can result in a denial of service, affecting the availability of the application. The vulnerability arises from the library's handling of input streams without adequate restrictions, making it susceptible to crafted payloads that exploit its processing logic.
How To Fix
Minimum fixed version
1.4.15-2
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 measure, if upgrading is not immediately feasible, you can implement XStream's security framework by configuring a whitelist of allowed types. This will limit the types of objects that can be serialized or deserialized, reducing the risk of exploitation. Example configuration in your code:
XStream xstream = new XStream();
xstream.allowTypes(new Class[] { YourAllowedClass.class });
Conclusion
The vulnerability identified in the XStream library poses a significant risk of denial of service due to CPU exhaustion. Upgrading to version 1.4.16 or later is crucial for mitigating this risk. Additionally, implementing a security framework with a whitelist can further enhance the security posture of applications using XStream.
See every vulnerability recorded for libxstream-java →
FAQ
The CVSS score for this vulnerability is 7.5, indicating a high severity level.
XStream versions prior to 1.4.16 are affected by this vulnerability.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
The vulnerability can lead to a denial of service, causing the application to become unresponsive due to excessive CPU usage.
Yes, it is recommended to implement XStream's security framework with a whitelist of allowed types to minimize risk.
Related vulnerabilities
Recent vulnerabilities recorded for libxstream-java.