CVE-2022-4904

8.6 HIGH

📋 TL;DR

CVE-2022-4904 is a stack buffer overflow vulnerability in the c-ares DNS library's ares_set_sortlist function. Attackers can trigger denial of service or potentially execute arbitrary code by providing malicious input. Any system or application using vulnerable versions of c-ares is affected.

💻 Affected Systems

Products:
  • c-ares library
  • Applications using c-ares (curl, Node.js, etc.)
Versions: c-ares versions before 1.19.1
Operating Systems: Linux, Unix-like systems, Windows
Default Config Vulnerable: ⚠️ Yes
Notes: Applications must call ares_set_sortlist with untrusted input to be exploitable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise if exploit chains with other vulnerabilities.

🟠

Likely Case

Denial of service causing application crashes or instability.

🟢

If Mitigated

Limited impact with proper input validation and memory protections.

🌐 Internet-Facing: MEDIUM - Requires specific conditions and attacker control over input to ares_set_sortlist.
🏢 Internal Only: LOW - Typically requires local access or specific application configurations.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires control over input to ares_set_sortlist function.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: c-ares 1.19.1 and later

Vendor Advisory: https://github.com/c-ares/c-ares/releases/tag/cares-1_19_1

Restart Required: Yes

Instructions:

1. Update c-ares to version 1.19.1 or later. 2. Rebuild applications using c-ares. 3. Restart affected services.

🔧 Temporary Workarounds

Input validation wrapper

all

Add input validation before calling ares_set_sortlist

Implement custom validation for sortlist parameter length and format

🧯 If You Can't Patch

  • Restrict network access to applications using c-ares
  • Implement strict input validation for all ares_set_sortlist calls

🔍 How to Verify

Check if Vulnerable:

Check c-ares version: `ares_version --version` or check package manager

Check Version:

ares_version --version

Verify Fix Applied:

Verify c-ares version is 1.19.1 or later

📡 Detection & Monitoring

Log Indicators:

  • Application crashes
  • Segmentation faults in c-ares related processes

Network Indicators:

  • Unusual DNS query patterns to affected systems

SIEM Query:

Process crashes with c-ares or libcares in stack trace

🔗 References

📤 Share & Export