CVE-2020-15366 Overview
CVE-2020-15366 is a prototype pollution vulnerability discovered in the ajv.validate() function of Ajv (Another JSON Schema Validator) version 6.12.2. This vulnerability allows an attacker to craft a malicious JSON schema that, when processed by the validator, enables prototype pollution attacks that can lead to arbitrary code execution. While the Ajv documentation recommends against using untrusted schemas, the expected worst-case scenario for an untrusted schema should be denial of service—not code execution, making this vulnerability particularly concerning.
Critical Impact
A carefully crafted JSON schema can pollute JavaScript object prototypes, potentially enabling remote code execution in applications that process untrusted JSON schemas through Ajv validation.
Affected Products
- Ajv (Another JSON Schema Validator) version 6.12.2
- Applications using ajv.js ajv for JSON schema validation
- Node.js applications with vulnerable Ajv dependencies
Discovery Timeline
- 2020-07-15 - CVE-2020-15366 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2020-15366
Vulnerability Analysis
This prototype pollution vulnerability exists within the JSON schema validation logic of Ajv version 6.12.2. Prototype pollution is a class of vulnerabilities specific to JavaScript where an attacker manipulates the prototype chain of JavaScript objects. By exploiting this flaw, an attacker can inject properties into existing JavaScript object prototypes, which then become accessible to all objects that inherit from those prototypes.
In the context of Ajv, the vulnerability manifests when the ajv.validate() function processes a specially crafted JSON schema. The malicious schema exploits insufficient property validation during schema compilation, allowing an attacker to modify the Object.prototype or other built-in prototypes. This can cascade into serious security implications including arbitrary code execution, denial of service, or property injection attacks.
Root Cause
The root cause of CVE-2020-15366 lies in improper handling of object properties during JSON schema processing. The Ajv library failed to adequately sanitize or validate schema properties that could reference or modify prototype chain elements. Specifically, the vulnerability stems from the library's handling of special JavaScript property names like __proto__, constructor, or prototype within schema definitions. When these properties are encountered in a malicious schema, they are processed in a way that allows modification of the JavaScript prototype chain rather than being treated as regular schema properties.
Attack Vector
The attack vector for this vulnerability is network-based and requires no authentication or user interaction, though it does have high attack complexity. An attacker must be able to supply a malicious JSON schema to an application using vulnerable versions of Ajv. Attack scenarios include:
Applications that accept JSON schemas from external sources, such as API endpoints that allow users to define validation rules, configuration systems that load schemas from untrusted locations, or development tools that process user-provided schemas.
Once a malicious schema is processed by ajv.validate(), the prototype pollution occurs during schema compilation. The attacker-controlled properties are then injected into the prototype chain, affecting the behavior of the application. Depending on the application's logic, this can be leveraged to bypass security checks, manipulate application state, or achieve remote code execution through gadget chains.
The vulnerability mechanism exploits the way JavaScript handles property assignment on objects when special prototype-related keys are provided in the JSON schema. Detailed technical information can be found in the HackerOne Bug Report #894259 and the GitHub AJV Release v6.12.3 notes.
Detection Methods for CVE-2020-15366
Indicators of Compromise
- Unexpected modifications to Object.prototype or other built-in prototypes in application runtime
- Application behavior changes indicating polluted prototype properties affecting object operations
- JSON schemas containing suspicious properties like __proto__, constructor, or prototype
- Error logs showing unexpected property access or type coercion failures
Detection Strategies
- Implement dependency scanning to identify Ajv versions prior to 6.12.3 in your application's dependency tree
- Use static analysis tools to detect code patterns that pass external input to ajv.validate() without sanitization
- Monitor for npm audit warnings related to the ajv package in CI/CD pipelines
- Deploy runtime application self-protection (RASP) solutions that detect prototype pollution attempts
Monitoring Recommendations
- Enable logging for JSON schema validation operations to capture potentially malicious schema inputs
- Implement integrity monitoring for JavaScript object prototypes in production environments
- Set up alerts for dependency vulnerability notifications affecting the ajv package
- Review application logs for validation errors that may indicate exploitation attempts
How to Mitigate CVE-2020-15366
Immediate Actions Required
- Upgrade Ajv to version 6.12.3 or later immediately, as this release contains the security fix
- Audit application code to identify all locations where JSON schemas are processed from external sources
- Implement input validation to reject schemas containing prototype-related properties before passing to Ajv
- Review and restrict which sources can provide JSON schemas to your application
Patch Information
The vulnerability has been addressed in Ajv version 6.12.3. The fix implements proper sanitization of schema properties to prevent prototype pollution during schema compilation. Organizations should upgrade to version 6.12.3 or the latest available version to remediate this vulnerability.
Patch and release information is available at the GitHub AJV Release v6.12.3 page. Additional vendor security information is available through the NetApp Security Advisory NTAP-20240621-0007.
Workarounds
- Avoid processing JSON schemas from untrusted or external sources until patching is complete
- Implement a schema whitelist approach where only pre-approved schemas are accepted for validation
- Use Object.freeze() on critical prototype objects to prevent modification, though this may have compatibility implications
- Deploy web application firewalls (WAF) with rules to detect and block requests containing prototype pollution payloads
# Update Ajv to patched version
npm update ajv@^6.12.3
# Or install the latest version
npm install ajv@latest
# Verify installed version
npm list ajv
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

