CVE-2022-25352
📋 TL;DR
CVE-2022-25352 is a prototype pollution vulnerability in the libnested JavaScript library that allows attackers to modify object prototypes, potentially leading to denial of service, remote code execution, or privilege escalation. This affects any application using vulnerable versions of libnested. The vulnerability stems from an incomplete fix for CVE-2020-28283.
💻 Affected Systems
- libnested
📦 What is this software?
Libnested by Libnested Project
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise, data theft, or ransomware deployment.
Likely Case
Denial of service, application crashes, or limited privilege escalation within the application context.
If Mitigated
Minimal impact if proper input validation and sandboxing are implemented.
🎯 Exploit Status
Exploitation requires attacker-controlled input to the vulnerable set() function.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 1.5.2
Vendor Advisory: https://github.com/dominictarr/libnested/commit/c1129865d75fbe52b5a4f755ad3110ca5420f2e1
Restart Required: Yes
Instructions:
1. Update package.json to require libnested version 1.5.2 or higher. 2. Run 'npm update libnested' or 'yarn upgrade libnested'. 3. Restart your application.
🔧 Temporary Workarounds
Input validation wrapper
allWrap libnested set() calls with strict input validation to reject prototype pollution attempts
// Example: Validate keys don't contain __proto__ or constructor
function safeSet(obj, path, value) {
if (typeof path === 'string' && (path.includes('__proto__') || path.includes('constructor'))) {
throw new Error('Invalid path');
}
return libnested.set(obj, path, value);
}
🧯 If You Can't Patch
- Implement strict Content Security Policy (CSP) headers to limit script execution
- Deploy web application firewall (WAF) rules to detect and block prototype pollution attempts
🔍 How to Verify
Check if Vulnerable:
Check package.json or package-lock.json for libnested version <1.5.2, or run 'npm list libnested'
Check Version:
npm list libnested | grep libnested
Verify Fix Applied:
Confirm libnested version is 1.5.2 or higher with 'npm list libnested'
📡 Detection & Monitoring
Log Indicators:
- Unusual application crashes
- Unexpected property modifications in objects
- Error logs containing '__proto__' or 'constructor' in paths
Network Indicators:
- HTTP requests with suspicious object paths in payloads
- Unusual API calls to set() endpoints
SIEM Query:
source="application.logs" AND ("__proto__" OR "constructor") AND "libnested"
🔗 References
- https://github.com/dominictarr/libnested/blob/master/index.js%23L22
- https://github.com/dominictarr/libnested/commit/c1129865d75fbe52b5a4f755ad3110ca5420f2e1
- https://snyk.io/vuln/SNYK-JS-LIBNESTED-2342117
- https://github.com/dominictarr/libnested/blob/master/index.js%23L22
- https://github.com/dominictarr/libnested/commit/c1129865d75fbe52b5a4f755ad3110ca5420f2e1
- https://snyk.io/vuln/SNYK-JS-LIBNESTED-2342117