CVE-2022-22822

9.8 CRITICAL

📋 TL;DR

CVE-2022-22822 is an integer overflow vulnerability in Expat's XML parser that can lead to heap buffer overflow. This allows attackers to execute arbitrary code or cause denial of service by processing specially crafted XML files. Any application using vulnerable versions of libexpat (2.4.2 and earlier) is affected.

💻 Affected Systems

Products:
  • Expat (libexpat)
  • Any software using libexpat library
Versions: Expat versions before 2.4.3
Operating Systems: Linux, Windows, macOS, BSD, Embedded systems
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability triggers when parsing XML with specific element bindings. Many Linux distributions package libexpat system-wide.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, or ransomware deployment.

🟠

Likely Case

Denial of service through application crashes, potentially leading to service disruption.

🟢

If Mitigated

Limited impact if proper input validation and memory protections are in place.

🌐 Internet-Facing: HIGH - XML parsing is common in web services and APIs exposed to untrusted input.
🏢 Internal Only: MEDIUM - Internal applications processing XML from untrusted sources remain vulnerable.

🎯 Exploit Status

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

Proof-of-concept available in security advisories. Exploitation requires attacker to supply malicious XML to vulnerable parser.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Expat 2.4.3 and later

Vendor Advisory: https://github.com/libexpat/libexpat/blob/R_2_4_3/expat/Changes

Restart Required: Yes

Instructions:

1. Update libexpat to version 2.4.3 or later. 2. For Linux systems: Use package manager (apt-get update && apt-get upgrade libexpat1, yum update expat, etc.). 3. For embedded systems: Recompile with patched library. 4. Restart affected services.

🔧 Temporary Workarounds

Input Validation

all

Validate and sanitize XML input before parsing

Memory Protection

linux

Enable ASLR and other memory protection mechanisms

sysctl -w kernel.randomize_va_space=2

🧯 If You Can't Patch

  • Implement strict XML schema validation to reject malformed documents
  • Use network segmentation to isolate vulnerable systems from untrusted networks

🔍 How to Verify

Check if Vulnerable:

Check libexpat version: expat --version or check package version (dpkg -l | grep expat, rpm -q expat)

Check Version:

expat --version 2>/dev/null || dpkg -l | grep expat || rpm -q expat || find /usr -name '*expat*' -exec strings {} \; | grep -i 'expat version'

Verify Fix Applied:

Confirm version is 2.4.3 or higher and test with known malicious XML samples

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with segmentation faults
  • Unusual XML parsing errors
  • Memory allocation failures

Network Indicators:

  • Unusually large XML payloads
  • XML with malformed element structures

SIEM Query:

source="application.log" AND ("segmentation fault" OR "SIGSEGV") AND process="*expat*"

🔗 References

📤 Share & Export