CVE-2021-39371
📋 TL;DR
This CVE describes an XML External Entity (XXE) injection vulnerability in PyWPS and potentially OWSLib. It allows attackers to read arbitrary files on the application server filesystem by manipulating XML entities. Systems running PyWPS before version 4.4.5 or OWSLib 0.24.1 are affected.
💻 Affected Systems
- PyWPS
- OWSLib
📦 What is this software?
Owslib by Osgeo
Pywps by Osgeo
⚠️ Risk & Real-World Impact
Worst Case
Complete server filesystem disclosure including sensitive configuration files, credentials, and system files leading to full system compromise.
Likely Case
Unauthorized reading of application files, configuration files, and potentially sensitive data stored on the server.
If Mitigated
Limited or no impact if XML external entity processing is disabled or proper input validation is implemented.
🎯 Exploit Status
XXE vulnerabilities are well-understood with readily available exploitation techniques. The vulnerability requires XML input processing.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: PyWPS 4.4.5
Vendor Advisory: https://github.com/geopython/pywps/pull/616
Restart Required: Yes
Instructions:
1. Update PyWPS to version 4.4.5 or later using pip: pip install --upgrade pywps>=4.4.5
2. Restart the PyWPS service
3. For OWSLib, ensure proper XML parser configuration or update if newer versions address the issue
🔧 Temporary Workarounds
Disable XML External Entity Processing
allConfigure XML parser to disable external entity resolution
Configure XML parser with: xmlparser.setFeature('http://xml.org/sax/features/external-general-entities', false)
xmlparser.setFeature('http://xml.org/sax/features/external-parameter-entities', false)
Input Validation and Sanitization
allImplement strict input validation for XML content
Implement XML schema validation
Use allowlists for acceptable XML elements and attributes
🧯 If You Can't Patch
- Implement network segmentation to restrict access to vulnerable systems
- Deploy web application firewall (WAF) with XXE protection rules
🔍 How to Verify
Check if Vulnerable:
Check PyWPS version: python -c "import pywps; print(pywps.__version__)" and verify if < 4.4.5
Check Version:
python -c "import pywps; print(pywps.__version__)"
Verify Fix Applied:
Confirm PyWPS version is >= 4.4.5 and test XML processing with malicious XXE payloads
📡 Detection & Monitoring
Log Indicators:
- Unusual file access patterns in application logs
- XML parsing errors with external entity references
- Large XML payloads with file:// or other URI schemes
Network Indicators:
- XML requests containing external entity declarations
- Requests with file://, http://, or ftp:// in XML content
SIEM Query:
source="application_logs" AND ("XXE" OR "external entity" OR "file://" OR "ENTITY")
🔗 References
- https://github.com/geopython/OWSLib/issues/790
- https://github.com/geopython/pywps/pull/616
- https://lists.debian.org/debian-lts-announce/2021/09/msg00001.html
- https://github.com/geopython/OWSLib/issues/790
- https://github.com/geopython/pywps/pull/616
- https://lists.debian.org/debian-lts-announce/2021/09/msg00001.html