CVE-2021-23386

7.7 HIGH

📋 TL;DR

CVE-2021-23386 is a memory disclosure vulnerability in the dns-packet npm package where uninitialized buffers can leak internal application memory over unencrypted DNS queries. Attackers can exploit this by sending crafted invalid domain names to expose sensitive data like encryption keys or session tokens. This affects any application using vulnerable versions of dns-packet for DNS query handling.

💻 Affected Systems

Products:
  • dns-packet npm package
Versions: All versions before 5.2.2
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Affects any application using dns-packet for DNS query construction, particularly when handling malformed domain names.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full memory disclosure leading to exposure of sensitive data like API keys, passwords, or encryption secrets, potentially enabling further system compromise.

🟠

Likely Case

Partial memory disclosure exposing application state, configuration data, or user session information that could be used for reconnaissance or targeted attacks.

🟢

If Mitigated

Limited impact with proper network segmentation and monitoring, though some information leakage may still occur.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires sending crafted DNS queries to vulnerable applications, which is straightforward for attackers with network access.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 5.2.2

Vendor Advisory: https://github.com/mafintosh/dns-packet/commit/25f15dd0fedc53688b25fd053ebbdffe3d5c1c56

Restart Required: Yes

Instructions:

1. Update package.json to require dns-packet version 5.2.2 or higher. 2. Run 'npm update dns-packet' or 'yarn upgrade dns-packet'. 3. Restart all affected applications and services.

🔧 Temporary Workarounds

Network Filtering

all

Block or filter DNS queries containing malformed domain names at network perimeter.

🧯 If You Can't Patch

  • Implement strict input validation for domain names before passing to dns-packet
  • Isolate vulnerable applications in segmented network zones with limited external access

🔍 How to Verify

Check if Vulnerable:

Check package.json or node_modules/dns-packet/package.json for version number. If version is below 5.2.2, the system is vulnerable.

Check Version:

npm list dns-packet | grep dns-packet

Verify Fix Applied:

Verify dns-packet version is 5.2.2 or higher after update and test with known malicious domain queries.

📡 Detection & Monitoring

Log Indicators:

  • Unusual DNS query patterns with malformed domain names
  • Increased memory usage or unusual process behavior

Network Indicators:

  • DNS queries containing unusually long or malformed domain names
  • Repeated DNS queries to the same domain with variations

SIEM Query:

source="dns" AND (query contains ".." OR query contains "--" OR query length > 255)

🔗 References

📤 Share & Export