CVE-2022-31471

7.5 HIGH
XXE

📋 TL;DR

CVE-2022-31471 is an XML External Entity (XXE) vulnerability in the untangle Python library that allows attackers to read local files on systems processing untrusted XML data. This affects any application using untangle versions 1.2.0 or earlier to parse XML from untrusted sources. Remote unauthenticated attackers can exploit this to access sensitive files on vulnerable systems.

💻 Affected Systems

Products:
  • untangle Python library
Versions: 1.2.0 and earlier
Operating Systems: All operating systems where Python runs
Default Config Vulnerable: ⚠️ Yes
Notes: Only vulnerable when parsing XML from untrusted sources. Applications that only parse trusted XML are not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise through reading sensitive files like /etc/passwd, SSH keys, configuration files, or database credentials, potentially leading to further attacks.

🟠

Likely Case

Information disclosure of local files accessible to the application process, including configuration files, logs, or other sensitive data.

🟢

If Mitigated

No impact if XML parsing is restricted to trusted sources or proper input validation is implemented.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

XXE vulnerabilities are well-understood with many public exploit examples. The vulnerability requires the application to process attacker-controlled XML.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.2.1

Vendor Advisory: https://github.com/stchris/untangle/releases/tag/1.2.1

Restart Required: No

Instructions:

1. Update untangle to version 1.2.1 or later using pip: pip install --upgrade untangle>=1.2.1
2. Verify the update with: pip show untangle
3. No application restart required for library updates in Python.

🔧 Temporary Workarounds

Disable external entity processing

all

Configure XML parser to disable external entity resolution before passing to untangle

import untangle
import defusedxml.ElementTree as ET
# Parse XML with defusedxml first
safe_tree = ET.parse(xml_file)
# Then convert to untangle object
obj = untangle.parse(safe_tree)

Input validation and sanitization

all

Validate and sanitize XML input before processing with untangle

# Implement XML schema validation or content filtering
# Remove DOCTYPE declarations and external entity references
import re
sanitized_xml = re.sub(r'<!DOCTYPE.*?>', '', xml_content, flags=re.DOTALL)
sanitized_xml = re.sub(r'<!ENTITY.*?>', '', sanitized_xml, flags=re.DOTALL)

🧯 If You Can't Patch

  • Implement strict input validation to only accept XML from trusted sources
  • Deploy network segmentation to isolate systems using vulnerable untangle versions

🔍 How to Verify

Check if Vulnerable:

Check untangle version with: python -c "import untangle; print(untangle.__version__)" or pip show untangle

Check Version:

pip show untangle | grep Version

Verify Fix Applied:

Verify version is 1.2.1 or higher: python -c "import untangle; print('VULNERABLE' if tuple(map(int, untangle.__version__.split('.'))) <= (1,2,0) else 'PATCHED')"

📡 Detection & Monitoring

Log Indicators:

  • Unusual file access patterns from XML parsing processes
  • Errors related to XML parsing or file not found from untangle operations

Network Indicators:

  • XML payloads containing DOCTYPE declarations or external entity references sent to applications

SIEM Query:

source="application_logs" AND ("untangle" OR "XML parse") AND ("DOCTYPE" OR "ENTITY" OR "SYSTEM")

🔗 References

📤 Share & Export