CVE-2017-16615
📋 TL;DR
This vulnerability allows remote code execution through YAML parsing in MLAlchemy. Attackers can inject arbitrary Python commands via YAML queries, leading to full system compromise. Any application using vulnerable versions of MLAlchemy for YAML-based data queries is affected.
💻 Affected Systems
- MLAlchemy
📦 What is this software?
Mlalchemy by Mlalchemy Project
Mlalchemy by Mlalchemy Project
Mlalchemy by Mlalchemy Project
Mlalchemy by Mlalchemy Project
Mlalchemy by Mlalchemy Project
⚠️ Risk & Real-World Impact
Worst Case
Full system compromise with attacker gaining complete control over the server, data exfiltration, lateral movement, and persistent backdoor installation.
Likely Case
Remote code execution leading to data theft, service disruption, and potential ransomware deployment.
If Mitigated
No impact if proper input validation and safe YAML parsing are implemented.
🎯 Exploit Status
Exploitation is straightforward - attacker simply needs to submit malicious YAML containing Python code. Public proof-of-concept examples exist.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 0.2.2 and later
Vendor Advisory: https://github.com/thanethomson/MLAlchemy/commit/bc795757febdcce430d89f9d08f75c32d6989d3c
Restart Required: No
Instructions:
1. Upgrade MLAlchemy to version 0.2.2 or later using pip: pip install --upgrade MLAlchemy>=0.2.2
2. Verify the fix by checking that safe_load is used instead of load in parser.py
3. Test YAML query functionality to ensure compatibility
🔧 Temporary Workarounds
Input Validation and Sanitization
allImplement strict input validation to reject YAML containing Python code constructs
# Implement custom YAML validator that checks for dangerous patterns
# Example: Reject YAML containing '!!python' tags or '__' patterns
Use Safe YAML Parser
allReplace yaml.load() with yaml.safe_load() in custom code
# Replace: yaml.load(yaml_data)
# With: yaml.safe_load(yaml_data)
🧯 If You Can't Patch
- Implement network segmentation to isolate vulnerable systems from critical infrastructure
- Deploy web application firewall (WAF) rules to block YAML payloads containing Python code patterns
🔍 How to Verify
Check if Vulnerable:
Check parser.py for use of yaml.load() instead of yaml.safe_load() in parse_yaml_query method. Test with malicious YAML: '!!python/object/apply:os.system ["whoami"]'
Check Version:
python -c "import MLAlchemy; print(MLAlchemy.__version__)"
Verify Fix Applied:
Verify parser.py uses yaml.safe_load() and test that malicious YAML payloads are rejected or safely parsed without execution
📡 Detection & Monitoring
Log Indicators:
- Unusual YAML parsing errors
- Python execution errors in YAML context
- Suspicious process spawns from web application
Network Indicators:
- HTTP requests containing YAML with Python code patterns
- Unusual outbound connections from application servers
SIEM Query:
source="web_logs" AND ("!!python" OR "__import__" OR "os.system" OR "subprocess") AND uri_path="*/yaml-query*"
🔗 References
- https://github.com/thanethomson/MLAlchemy/commit/bc795757febdcce430d89f9d08f75c32d6989d3c
- https://github.com/thanethomson/MLAlchemy/issues/1
- https://joel-malwarebenchmark.github.io/blog/2017/11/08/cve-2017-16615-critical-restful-web-applications-vulnerability/
- https://github.com/thanethomson/MLAlchemy/commit/bc795757febdcce430d89f9d08f75c32d6989d3c
- https://github.com/thanethomson/MLAlchemy/issues/1
- https://joel-malwarebenchmark.github.io/blog/2017/11/08/cve-2017-16615-critical-restful-web-applications-vulnerability/