CVE-2021-21249
📋 TL;DR
CVE-2021-21249 is a post-authentication remote code execution vulnerability in OneDev DevOps platform. It allows authenticated attackers to execute arbitrary code on the server by exploiting insecure YAML deserialization via SnakeYaml library. This affects all OneDev instances before version 4.0.3.
💻 Affected Systems
- OneDev
📦 What is this software?
Onedev by Onedev Project
⚠️ Risk & Real-World Impact
Worst Case
Complete system compromise allowing attacker to execute arbitrary commands, access sensitive data, deploy malware, or pivot to other systems in the network.
Likely Case
Attacker gains full control of the OneDev server, potentially accessing source code, CI/CD pipelines, credentials, and deploying malicious code to downstream systems.
If Mitigated
With proper network segmentation and least privilege, impact limited to the OneDev application server only.
🎯 Exploit Status
Exploit requires authentication but is straightforward once authenticated. Public proof-of-concept available in GitHub advisory.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 4.0.3 and later
Vendor Advisory: https://github.com/theonedev/onedev/security/advisories/GHSA-7xhq-m2q9-6hpm
Restart Required: Yes
Instructions:
1. Backup your OneDev instance. 2. Stop the OneDev service. 3. Update to version 4.0.3 or later. 4. Restart the OneDev service. 5. Verify the update was successful.
🔧 Temporary Workarounds
Restrict YAML uploads
allTemporarily disable or restrict YAML file uploads/processing in OneDev until patched.
Network segmentation
allIsolate OneDev server from critical systems and implement strict firewall rules.
🧯 If You Can't Patch
- Implement strict access controls and monitor for suspicious YAML file uploads
- Deploy WAF rules to block malicious YAML payloads and monitor for exploitation attempts
🔍 How to Verify
Check if Vulnerable:
Check OneDev version via web interface or by examining the installation directory. Versions below 4.0.3 are vulnerable.
Check Version:
Check web interface or run: java -jar onedev.jar --version
Verify Fix Applied:
Verify version is 4.0.3 or higher and test YAML file processing functionality.
📡 Detection & Monitoring
Log Indicators:
- Unusual YAML file uploads
- Java class loading errors
- ScriptEngineManager instantiation in logs
- Unusual process execution from OneDev
Network Indicators:
- Outbound connections from OneDev to unusual destinations
- Unexpected network traffic patterns
SIEM Query:
source="onedev" AND ("YAML" OR "SnakeYaml" OR "ScriptEngineManager") AND severity=HIGH
🔗 References
- https://github.com/theonedev/onedev/commit/d6fc4212b1ac1e9bbe3ce444e95f9af1e3ab8b66
- https://github.com/theonedev/onedev/security/advisories/GHSA-7xhq-m2q9-6hpm
- https://github.com/theonedev/onedev/commit/d6fc4212b1ac1e9bbe3ce444e95f9af1e3ab8b66
- https://github.com/theonedev/onedev/security/advisories/GHSA-7xhq-m2q9-6hpm