CVE-2021-3918

9.8 CRITICAL

📋 TL;DR

CVE-2021-3918 is a prototype pollution vulnerability in the json-schema 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 json-schema for JSON validation. The vulnerability is particularly dangerous because it can be exploited through malicious JSON input.

💻 Affected Systems

Products:
  • json-schema
  • Any software/library depending on json-schema
Versions: Versions before commit 22f146111f541d9737e832823699ad3528ca7741
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: The vulnerability affects the default configuration when processing untrusted JSON input. Applications using json-schema for validation of user-controlled JSON are particularly vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise, data exfiltration, or persistent backdoor installation.

🟠

Likely Case

Denial of service through application crashes or memory corruption, potentially enabling privilege escalation in multi-user environments.

🟢

If Mitigated

Limited impact with proper input validation and sandboxing, though prototype pollution could still affect application behavior.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires sending malicious JSON payloads to applications using vulnerable json-schema versions. Public proof-of-concept demonstrates the vulnerability.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Versions after commit 22f146111f541d9737e832823699ad3528ca7741

Vendor Advisory: https://github.com/kriszyp/json-schema/commit/22f146111f541d9737e832823699ad3528ca7741

Restart Required: No

Instructions:

1. Update json-schema to version containing commit 22f146111f541d9737e832823699ad3528ca7741 or later. 2. Run 'npm update json-schema' or equivalent package manager command. 3. Verify update with version check. 4. Test application functionality after update.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict input validation to reject JSON with suspicious patterns before passing to json-schema.

Object.freeze() on Prototypes

all

Use Object.freeze() on critical object prototypes to prevent modification.

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

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate vulnerable systems
  • Deploy web application firewall (WAF) rules to block malicious JSON patterns

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list json-schema' to see installed version. Compare against commit hash 22f146111f541d9737e832823699ad3528ca7741.

Check Version:

npm list json-schema | grep json-schema

Verify Fix Applied:

Verify json-schema version is updated beyond vulnerable commit. Test with known malicious payloads to ensure they're rejected.

📡 Detection & Monitoring

Log Indicators:

  • Unusual JSON parsing errors
  • Application crashes during JSON validation
  • Suspicious JSON payloads in request logs

Network Indicators:

  • Large or malformed JSON payloads to validation endpoints
  • Repeated requests with similar JSON structures

SIEM Query:

source="application_logs" AND ("json-schema" OR "JSON validation") AND (error OR crash OR exception)

🔗 References

📤 Share & Export