CVE-2021-25948

9.8 CRITICAL

📋 TL;DR

CVE-2021-25948 is a prototype pollution vulnerability in the 'expand-hash' npm package that allows attackers to modify JavaScript object prototypes. This can lead to denial of service or potentially remote code execution by polluting base objects. Anyone using affected versions of expand-hash in their Node.js applications is vulnerable.

💻 Affected Systems

Products:
  • expand-hash npm package
Versions: 0.1.0 through 1.0.1
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using expand-hash to process untrusted input is vulnerable. The vulnerability exists in the core library functionality.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data theft, or ransomware deployment.

🟠

Likely Case

Denial of service through application crashes or instability, with potential for limited code execution in specific configurations.

🟢

If Mitigated

Application instability or crashes without code execution if input validation blocks malicious payloads.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Prototype pollution vulnerabilities are well-understood and often have public proof-of-concept exploits available.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.0.2 and later

Vendor Advisory: https://github.com/doowb/expand-hash/security/advisories

Restart Required: Yes

Instructions:

1. Update package.json to specify 'expand-hash': '^1.0.2' or higher. 2. Run 'npm update expand-hash' or 'yarn upgrade expand-hash'. 3. Restart your Node.js application.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation to reject any objects containing __proto__ or constructor properties.

Object.freeze on Prototypes

all

Freeze Object.prototype and other base prototypes to prevent pollution.

Object.freeze(Object.prototype);
Object.freeze(Object);

🧯 If You Can't Patch

  • Implement strict input validation to reject objects with __proto__ or constructor properties
  • Use alternative libraries that don't have prototype pollution vulnerabilities

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list expand-hash' to see installed version. If version is between 0.1.0 and 1.0.1 inclusive, you are vulnerable.

Check Version:

npm list expand-hash | grep expand-hash

Verify Fix Applied:

After updating, run 'npm list expand-hash' and verify version is 1.0.2 or higher. Test with known malicious inputs to confirm protection.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with prototype-related errors
  • Unusual object property modifications in logs
  • Unexpected __proto__ or constructor references in input

Network Indicators:

  • HTTP requests containing __proto__ or constructor in JSON payloads
  • Unusual patterns of requests to endpoints using expand-hash

SIEM Query:

source="application.logs" AND ("__proto__" OR "constructor" OR "prototype pollution")

🔗 References

📤 Share & Export