CVE-2021-21351 Overview
CVE-2021-21351 is a critical insecure deserialization vulnerability in XStream, a popular Java library used to serialize objects to XML and back again. In XStream versions prior to 1.4.16, a remote attacker can load and execute arbitrary code from a remote host by manipulating the processed input stream. This vulnerability affects applications that rely on XStream's default blacklist security configuration rather than implementing a strict whitelist approach.
The vulnerability is particularly dangerous because XStream is widely used across enterprise Java applications, including products from Oracle, Apache, NetApp, and various Linux distributions. Organizations that have not configured XStream with a whitelist limited to minimal required types are at risk of complete system compromise.
Critical Impact
Remote attackers can achieve arbitrary code execution by exploiting insecure deserialization in XStream, potentially leading to complete system compromise, data exfiltration, and lateral movement within affected networks.
Affected Products
- XStream versions prior to 1.4.16
- Apache ActiveMQ (versions 5.16.0 and 5.16.1)
- Apache JMeter
- NetApp OnCommand Insight
- Oracle Banking Platform (versions 2.4.0 through 2.12.0)
- Oracle Banking Virtual Account Management (versions 14.2.0, 14.3.0, 14.5.0)
- Oracle MySQL Server
- Oracle Communications Unified Inventory Management (versions 7.3.2 through 7.4.1)
- Oracle WebCenter Portal
- Debian Linux (versions 9.0, 10.0, 11.0)
- Fedora (versions 33, 34, 35)
Discovery Timeline
- 2021-03-23 - CVE-2021-21351 published to NVD
- 2025-05-23 - Last updated in NVD database
Technical Details for CVE-2021-21351
Vulnerability Analysis
This vulnerability stems from insufficient input validation during XML deserialization in XStream. The library processes XML input streams and converts them back into Java objects, but versions prior to 1.4.16 fail to adequately restrict which classes can be instantiated during this process.
XStream's security framework relies on either a whitelist (recommended) or blacklist approach to control which types can be deserialized. The default blacklist configuration was found to be insufficient, allowing attackers to craft malicious XML payloads that reference classes capable of executing arbitrary code. This is classified under CWE-434 (Unrestricted Upload of File with Dangerous Type) in the context of processing dangerous serialized objects.
The attack can be executed entirely over the network without requiring any authentication, though administrative privileges may be needed in some deployment scenarios to reach vulnerable endpoints. The vulnerability has a scope change impact, meaning successful exploitation can affect resources beyond the vulnerable component itself.
Root Cause
The root cause of CVE-2021-21351 lies in XStream's reliance on an incomplete blacklist for security enforcement. The blacklist approach is fundamentally flawed because it attempts to enumerate all dangerous classes that should not be deserialized, rather than explicitly allowing only safe, expected types.
Attackers discovered bypass techniques that leverage Java classes not included in the blacklist but capable of triggering arbitrary code execution when instantiated with attacker-controlled data. This is a common pattern in Java deserialization vulnerabilities where gadget chains can be constructed from seemingly innocuous classes.
Attack Vector
The attack is network-based and requires the attacker to submit a specially crafted XML payload to an application using XStream for deserialization. The attack flow typically involves:
- The attacker identifies an endpoint that processes XML input using XStream
- A malicious XML payload is constructed containing references to exploitable Java classes that bypass the blacklist
- The payload is submitted to the vulnerable endpoint
- XStream deserializes the XML and instantiates the malicious classes
- The gadget chain executes, loading and running arbitrary code from a remote host controlled by the attacker
The exploitation requires no user interaction and can be automated, making it particularly dangerous for internet-facing applications. According to the GitHub Security Advisory GHSA-hrcp-8f3q-4w2c, successful exploitation allows complete remote code execution on the target system.
Detection Methods for CVE-2021-21351
Indicators of Compromise
- Unusual outbound network connections from Java applications to unknown external hosts
- XML payloads in logs containing suspicious class references such as javax.imageio.ImageIO, com.sun.org.apache.xalan, or other known gadget chain classes
- Process spawning from Java applications that typically do not spawn child processes
- Unexpected file system modifications in application directories
- Memory anomalies or increased resource usage in Java processes handling XML deserialization
Detection Strategies
- Deploy network intrusion detection rules to identify malicious XStream payloads containing known deserialization gadget class names
- Monitor application logs for deserialization errors or exceptions related to blacklisted classes, which may indicate exploitation attempts
- Implement runtime application self-protection (RASP) to detect and block deserialization of dangerous classes
- Use SentinelOne's behavioral AI to identify anomalous process activity originating from Java applications
- Conduct regular vulnerability scanning to identify applications using vulnerable XStream versions
Monitoring Recommendations
- Enable detailed logging for all XML deserialization operations in affected applications
- Monitor Java process behavior for suspicious activities including unexpected network connections, file operations, and process creation
- Implement alerting on any attempts to load classes from remote URLs during deserialization
- Track XStream version usage across your environment using software composition analysis tools
- Review and correlate security events from web application firewalls with backend application logs
How to Mitigate CVE-2021-21351
Immediate Actions Required
- Upgrade XStream to version 1.4.16 or later immediately across all affected applications
- If immediate upgrade is not possible, implement XStream's security framework with a strict whitelist limited to only the minimal required types
- Audit all applications in your environment for XStream usage and prioritize patching based on exposure
- Review network segmentation to limit potential lateral movement if exploitation occurs
- Apply available vendor patches for affected products including Oracle, Apache, and NetApp components
Patch Information
The XStream development team addressed this vulnerability in version 1.4.16. The fix improves the security framework to prevent the bypass techniques used in this attack. Organizations should upgrade to XStream 1.4.16 or later as the primary remediation.
For detailed patch information, refer to the XStream Change Log 1.4.16. Multiple vendors have released their own patches incorporating the fixed XStream library - consult the Oracle January 2022 Security Alerts for Oracle products and the NetApp Security Advisory ntap-20210430-0002 for NetApp products.
Workarounds
- Configure XStream with a strict whitelist using the security framework as documented in the XStream Workaround Information
- Block or filter incoming XML payloads at the web application firewall level if they contain known malicious class patterns
- Disable XML deserialization endpoints if they are not required for application functionality
- Implement input validation to reject XML containing unexpected or suspicious element types
// XStream security configuration with whitelist (recommended workaround)
XStream xstream = new XStream();
// Clear all default permissions
xstream.addPermission(NoTypePermission.NONE);
// Only allow specific safe types required by your application
xstream.addPermission(NullPermission.NULL);
xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
xstream.allowTypes(new Class[] { MyAllowedClass.class });
xstream.allowTypesByWildcard(new String[] { "com.mycompany.models.**" });
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

