CVE-2024-47875

10.0 CRITICAL

📋 TL;DR

DOMPurify versions before 2.5.0 and 3.1.3 contain a nesting-based mutation XSS (mXSS) vulnerability that allows attackers to bypass HTML sanitization and execute arbitrary JavaScript in victim browsers. This affects any web application using vulnerable DOMPurify versions to sanitize user-controlled HTML input. The vulnerability is particularly dangerous because it bypasses a security library specifically designed to prevent XSS attacks.

💻 Affected Systems

Products:
  • DOMPurify
Versions: All versions before 2.5.0 and 3.1.3
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using DOMPurify to sanitize HTML, MathML, or SVG content from untrusted sources is vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete compromise of user sessions, account takeover, data theft, and full control over victim browser sessions through persistent XSS payloads.

🟠

Likely Case

Attackers inject malicious scripts that steal session cookies, credentials, or perform actions on behalf of authenticated users.

🟢

If Mitigated

Limited impact if input validation and output encoding are also implemented, but still represents a significant security bypass.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Proof of concept exists in the test suite and security advisory. The vulnerability bypasses DOMPurify's primary security function.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.5.0 or 3.1.3

Vendor Advisory: https://github.com/cure53/DOMPurify/security/advisories/GHSA-gx9m-whjm-85jf

Restart Required: No

Instructions:

1. Update DOMPurify dependency to version 2.5.0 or higher (for v2) or 3.1.3 or higher (for v3). 2. For npm: 'npm update dompurify'. 3. For yarn: 'yarn upgrade dompurify'. 4. Verify the updated version is being used.

🔧 Temporary Workarounds

Input Validation Enhancement

all

Implement additional input validation and output encoding layers alongside DOMPurify

Content Security Policy

all

Implement strict Content Security Policy headers to mitigate XSS impact

🧯 If You Can't Patch

  • Implement additional HTML sanitization using alternative libraries or custom validation
  • Disable features that accept HTML input from untrusted sources until patching is possible

🔍 How to Verify

Check if Vulnerable:

Check package.json or lock files for DOMPurify version below 2.5.0 (for v2) or below 3.1.3 (for v3)

Check Version:

npm list dompurify | grep dompurify (for npm) or check package.json directly

Verify Fix Applied:

Verify DOMPurify version is 2.5.0+ or 3.1.3+ in package.json and that the application loads the updated version

📡 Detection & Monitoring

Log Indicators:

  • Unusual HTML patterns with nested elements in user input
  • JavaScript execution from sanitized content

Network Indicators:

  • Suspicious script tags in POST/PUT requests to endpoints that process HTML

SIEM Query:

source=web_logs AND (http_method=POST OR http_method=PUT) AND (body CONTAINS "<script>" OR body CONTAINS "javascript:")

🔗 References

📤 Share & Export