CVE-2021-28411
CVE-2021-28411
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Description
An issue was discovered in getRememberedSerializedIdentity function in CookieRememberMeManager class in lerry903 RuoYi version 3.4.0, allows remote attackers to escalate privileges.
Comprehensive Technical Analysis of CVE-2021-28411
CVE ID: CVE-2021-28411 CVSS Score: 9.8 (Critical) Affected Software: RuoYi v3.4.0 (Java-based enterprise management framework) Vulnerability Type: Insecure Deserialization Leading to Privilege Escalation
1. Vulnerability Assessment & Severity Evaluation
Vulnerability Overview
CVE-2021-28411 is an insecure deserialization vulnerability in the CookieRememberMeManager class of RuoYi v3.4.0, specifically within the getRememberedSerializedIdentity function. The flaw allows remote attackers to execute arbitrary code or escalate privileges by manipulating the "remember me" cookie, which is deserialized without proper validation.
CVSS v3.1 Breakdown (Score: 9.8 - Critical)
| Metric | Value | Explanation |
|---|---|---|
| Attack Vector (AV) | Network (N) | Exploitable remotely over HTTP/HTTPS. |
| Attack Complexity (AC) | Low (L) | No special conditions required; trivial to exploit. |
| Privileges Required (PR) | None (N) | No authentication needed. |
| User Interaction (UI) | None (N) | No user interaction required. |
| Scope (S) | Changed (C) | Impact extends beyond the vulnerable component (privilege escalation). |
| Confidentiality (C) | High (H) | Full system compromise possible. |
| Integrity (I) | High (H) | Arbitrary code execution enables data tampering. |
| Availability (A) | High (H) | Denial-of-service or full system takeover possible. |
Severity Justification
- Critical Impact: Successful exploitation can lead to remote code execution (RCE), privilege escalation to admin, or complete system compromise.
- Low Barrier to Exploitation: No authentication or user interaction is required, making it highly attractive to attackers.
- Widespread Deployment: RuoYi is widely used in enterprise environments, increasing the potential attack surface.
2. Potential Attack Vectors & Exploitation Methods
Attack Vector: Insecure Deserialization of "Remember Me" Cookie
The vulnerability stems from improper handling of serialized Java objects in the CookieRememberMeManager class. The getRememberedSerializedIdentity function deserializes user-controlled cookie data without:
- Input validation (e.g., checking for malicious payloads).
- Signature verification (e.g., HMAC to ensure integrity).
- Safe deserialization practices (e.g., using
ObjectInputStreamwith a whitelist).
Exploitation Steps
-
Craft a Malicious "Remember Me" Cookie
- An attacker generates a malicious serialized Java object (e.g., using ysoserial or custom payloads).
- Common gadget chains (e.g., CommonsCollections, Groovy, Spring) can be embedded to achieve RCE.
-
Send the Malicious Cookie to the Target
- The attacker sends an HTTP request with the crafted cookie to the vulnerable RuoYi instance.
- Example:
GET /dashboard HTTP/1.1 Host: vulnerable-ruoyi.example.com Cookie: rememberMe=malicious_serialized_payload
-
Deserialization & Code Execution
- The server deserializes the cookie, triggering the malicious payload.
- Depending on the gadget chain, the attacker may:
- Execute arbitrary commands (e.g., reverse shell, file upload).
- Escalate privileges (e.g., gain admin access).
- Exfiltrate sensitive data (e.g., database credentials).
Proof-of-Concept (PoC) Considerations
- Tools:
ysoserial,Burp Suite,Java deserialization payload generators. - Gadget Chains: Commonly exploited chains include:
CommonsCollections1(RCE viaInvokerTransformer).Groovy1(RCE viaMethodClosure).Spring1(RCE viaMethodInvokingFactoryBean).
3. Affected Systems & Software Versions
| Software | Affected Versions | Fixed Versions | Notes |
|---|---|---|---|
| RuoYi | v3.4.0 | v3.4.1+ (or later) | Only v3.4.0 is confirmed vulnerable. |
| Dependencies | Apache Shiro (if used) | N/A | Some RuoYi deployments may use Shiro for auth. |
Detection Methods
- Manual Inspection:
- Check for
CookieRememberMeManagerinshiro.inior Spring configuration. - Verify if
getRememberedSerializedIdentitylacks proper validation.
- Check for
- Automated Scanning:
- Nessus, OpenVAS, Burp Suite (with deserialization checks).
- Custom scripts to detect vulnerable cookie handling.
4. Recommended Mitigation Strategies
Immediate Remediation (Short-Term)
-
Disable "Remember Me" Functionality
- Remove or disable the
CookieRememberMeManagerinshiro.ini:# securityManager.rememberMeManager = $rememberMeManager - Alternatively, set
rememberMe.cookie.maxAge = 0.
- Remove or disable the
-
Upgrade RuoYi
- Apply the latest patch (v3.4.1 or later) from the official repository.
-
Implement Input Validation
- Use HMAC signing for serialized cookies to ensure integrity.
- Example (Java):
byte[] serialized = Base64.decode(cookieValue); if (!verifyHmac(serialized, secretKey)) { throw new SecurityException("Invalid cookie signature"); }
Long-Term Security Hardening
-
Use Safe Deserialization Libraries
- Replace
ObjectInputStreamwith safe alternatives:- Jackson (with
JsonDeserializer). - Gson (for JSON-based serialization).
- Apache Commons Lang (with
SerializationUtilsand whitelisting).
- Jackson (with
- Replace
-
Enable Java Security Manager
- Restrict deserialization to trusted classes:
System.setProperty("java.security.policy", "deserialization.policy");
- Restrict deserialization to trusted classes:
-
Network-Level Protections
- Web Application Firewall (WAF) rules to block malicious cookie patterns.
- Rate limiting to prevent brute-force attacks.
-
Monitoring & Logging
- Log all deserialization attempts (successful/failed).
- Alert on suspicious cookie values (e.g., long Base64 strings).
5. Impact on the Cybersecurity Landscape
Enterprise Risk
- High-Value Target: RuoYi is widely used in Chinese enterprise environments, making it a prime target for APT groups and cybercriminals.
- Supply Chain Risks: Vulnerable RuoYi instances may be embedded in third-party applications, increasing exposure.
Exploitation Trends
- Active Exploitation: Similar deserialization flaws (e.g., CVE-2016-4437 in Apache Shiro) have been exploited in the wild.
- Ransomware & Data Theft: Attackers may use this to deploy ransomware or exfiltrate sensitive data.
Regulatory & Compliance Implications
- GDPR, CCPA, NIST: Unpatched vulnerabilities may lead to data breaches, resulting in fines and legal consequences.
- CISA KEV Catalog: This CVE may be added to the Known Exploited Vulnerabilities list, requiring federal agencies to patch within deadlines.
6. Technical Details for Security Professionals
Root Cause Analysis
The vulnerability exists in the CookieRememberMeManager class, where the getRememberedSerializedIdentity method:
- Decodes a Base64-encoded cookie (
rememberMe). - Deserializes the raw bytes using
ObjectInputStreamwithout validation. - Returns the deserialized object as a
PrincipalCollection, which may contain malicious payloads.
Vulnerable Code Snippet (Pseudocode):
public PrincipalCollection getRememberedSerializedIdentity(SubjectContext subjectContext) {
String base64 = WebUtils.getCookie(subjectContext, "rememberMe");
byte[] serialized = Base64.decode(base64);
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serialized));
return (PrincipalCollection) ois.readObject(); // UNSAFE DESERIALIZATION
}
Exploitation Gadget Chains
Attackers can leverage Java deserialization gadgets to achieve RCE. Common chains include:
| Gadget Chain | Impact | Tools |
|---|---|---|
| CommonsCollections1 | RCE via InvokerTransformer | ysoserial |
| Groovy1 | RCE via MethodClosure | ysoserial |
| Spring1 | RCE via MethodInvokingFactoryBean | Custom payloads |
Forensic & Incident Response Considerations
-
Indicators of Compromise (IoCs):
- Unusual
rememberMecookie values (long Base64 strings). - Suspicious process execution (e.g.,
curl,bash,powershell). - Unexpected network connections (e.g., reverse shells).
- Unusual
-
Memory Forensics:
- Use Volatility or Rekall to detect injected payloads.
- Check for unusual Java threads (e.g.,
ProcessBuilderexecution).
-
Log Analysis:
- Review HTTP access logs for
rememberMecookie anomalies. - Check application logs for deserialization errors.
- Review HTTP access logs for
Conclusion & Recommendations
CVE-2021-28411 is a critical deserialization vulnerability with severe implications for affected RuoYi deployments. Organizations must:
- Patch immediately (upgrade to v3.4.1+).
- Disable "Remember Me" if patching is not feasible.
- Implement safe deserialization practices (HMAC, whitelisting).
- Monitor for exploitation attempts (WAF, logging).
Given the high CVSS score (9.8) and active exploitation risks, this vulnerability should be treated as a top priority in vulnerability management programs.
References: