CVE-2021-28040

7.5 HIGH

📋 TL;DR

This vulnerability allows attackers to cause a denial of service (DoS) in OSSEC HIDS by sending specially crafted XML with excessive nested tags, triggering uncontrolled recursion that leads to a segmentation fault and crashes the service. It affects all systems running OSSEC 3.6.0. The vulnerability is exploitable remotely if OSSEC is configured to process XML from untrusted sources.

💻 Affected Systems

Products:
  • OSSEC HIDS
Versions: 3.6.0
Operating Systems: All platforms running OSSEC
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability exists in core XML parsing library, so all configurations using XML processing are affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service disruption of OSSEC HIDS, disabling security monitoring and alerting capabilities across the protected infrastructure.

🟠

Likely Case

Temporary DoS affecting OSSEC's XML parsing functionality, potentially causing missed security events until service restart.

🟢

If Mitigated

Minimal impact if XML input validation is implemented or if OSSEC only processes trusted XML sources.

🌐 Internet-Facing: MEDIUM - Exploitable if OSSEC processes XML from external sources, but requires specific configuration.
🏢 Internal Only: LOW - Most OSSEC deployments process internal logs and events, reducing attack surface.

🎯 Exploit Status

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

Proof of concept involves sending XML with deeply nested tags. No authentication required if attacker can submit XML to vulnerable parser.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.6.1 and later

Vendor Advisory: https://github.com/ossec/ossec-hids/releases/tag/3.6.1

Restart Required: Yes

Instructions:

1. Backup current OSSEC configuration. 2. Download OSSEC 3.6.1 or later from official repository. 3. Stop OSSEC service. 4. Install/upgrade to patched version. 5. Restart OSSEC service.

🔧 Temporary Workarounds

XML Input Validation

all

Implement XML validation to reject documents with excessive nesting depth before they reach OSSEC parser.

# Use XML validation tool or custom script to check nesting depth
# Example: xmlstarlet val --err --maxdepth 50 input.xml

Process Isolation

linux

Run OSSEC XML parsing in isolated container/process with memory limits to contain crashes.

# Use systemd resource limits
MemoryLimit=100M
Restart=on-failure

🧯 If You Can't Patch

  • Implement network segmentation to restrict XML sources to trusted internal systems only.
  • Deploy monitoring to detect and alert on OSSEC service crashes with automatic restart mechanisms.

🔍 How to Verify

Check if Vulnerable:

Check OSSEC version: cat /etc/ossec-init.conf | grep VERSION or /var/ossec/bin/ossec-control --version

Check Version:

/var/ossec/bin/ossec-control --version | grep 'OSSEC HIDS'

Verify Fix Applied:

Confirm version is 3.6.1 or later and test with sample XML containing deeply nested tags (use caution).

📡 Detection & Monitoring

Log Indicators:

  • OSSEC service crash logs
  • Segmentation fault errors in system logs
  • OSSEC process termination without normal shutdown

Network Indicators:

  • Unusual XML traffic to OSSEC ports
  • Multiple XML submissions with similar structure

SIEM Query:

source="ossec" AND ("segmentation fault" OR "crash" OR "SIGSEGV")

🔗 References

📤 Share & Export