CVE-2024-21541

7.3 HIGH

📋 TL;DR

This vulnerability allows arbitrary code execution in applications using vulnerable versions of the dom-iterator package. Attackers can inject malicious JavaScript that gets executed via the Function constructor, similar to eval() vulnerabilities. Any application using dom-iterator before version 1.0.1 is affected.

💻 Affected Systems

Products:
  • dom-iterator JavaScript package
Versions: All versions before 1.0.1
Operating Systems: All platforms running Node.js or browser JavaScript
Default Config Vulnerable: ⚠️ Yes
Notes: Affects any application that uses the vulnerable dom-iterator package, particularly web applications processing user-controlled DOM content.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise allowing attackers to execute arbitrary code with application privileges, potentially leading to data theft, ransomware deployment, or lateral movement.

🟠

Likely Case

Remote code execution leading to data exfiltration, credential theft, or installation of backdoors in affected web applications.

🟢

If Mitigated

Limited impact if proper input validation and sanitization are implemented, though the vulnerability still exists in the library.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires attacker-controlled input to reach the vulnerable Function constructor usage. The vulnerability pattern is well-known and similar to eval() exploitation.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.0.1

Vendor Advisory: https://github.com/matthewmueller/dom-iterator/commit/9e0e0fad5a251de5b42feb326c4204eb04080805

Restart Required: Yes

Instructions:

1. Update package.json to specify dom-iterator version 1.0.1 or higher. 2. Run 'npm update dom-iterator' or 'yarn upgrade dom-iterator'. 3. Restart your application to load the patched version.

🔧 Temporary Workarounds

Input Sanitization

all

Implement strict input validation and sanitization for any data that reaches dom-iterator functions

Content Security Policy

all

Implement strict CSP headers to limit script execution capabilities

🧯 If You Can't Patch

  • Implement network segmentation to isolate affected systems
  • Deploy web application firewall rules to detect and block suspicious JavaScript patterns

🔍 How to Verify

Check if Vulnerable:

Check package.json or package-lock.json for dom-iterator version. If version is less than 1.0.1, the system is vulnerable.

Check Version:

npm list dom-iterator or check package.json for version

Verify Fix Applied:

Verify dom-iterator version is 1.0.1 or higher in package.json and that the application loads this version.

📡 Detection & Monitoring

Log Indicators:

  • Unusual JavaScript execution patterns
  • Suspicious Function constructor usage in application logs

Network Indicators:

  • Unexpected outbound connections from web application servers
  • Suspicious payloads in HTTP requests containing JavaScript

SIEM Query:

Search for patterns of eval() or Function() constructor usage in application logs, particularly with user-supplied input

🔗 References

📤 Share & Export