Prototype Pollution Vulnerability in Ajv (node-ajv) - CVE-2020-15366
Summary
CVE-2020-15366: An issue was discovered in ajv.validate() in Ajv (aka Another JSON Schema Validator) 6.12.2. Affects node-ajv across 2 version ranges.
< 6.12.4-1
< 521c3a53f15f5502fb4a734194932535d311267c
Fixed in 6.12.4-1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Ajv (Another JSON Schema Validator) is a widely used library for validating JSON objects against JSON Schema specifications. It is known for its speed and flexibility, allowing developers to ensure that their JSON data adheres to defined structures. However, certain versions of Ajv are vulnerable to a prototype pollution attack, which can lead to severe security implications.
Vulnerability Detail
The vulnerability identified as CVE-2020-15366 affects Ajv versions up to 6.12.2. It arises from the improper handling of JSON schemas, allowing an attacker to craft a malicious schema that can manipulate the prototype of JavaScript objects. This can lead to arbitrary code execution, which is a critical security risk. The worst-case scenario should ideally result in a denial of service, but due to this flaw, it can escalate to code execution, compromising the integrity of the application.
How To Fix
Minimum fixed version
6.12.4-1
This is the first release that contains the fix.
sudo apt-get install --only-upgrade node-ajv
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If immediate upgrading is not feasible, consider validating JSON schemas only from trusted sources. Avoid using untrusted schemas in your application to mitigate the risk of prototype pollution. Additionally, you can implement input validation to sanitize incoming schemas before processing them.
Conclusion
The CVE-2020-15366 vulnerability in Ajv poses a significant risk due to its potential for prototype pollution and arbitrary code execution. It is crucial for developers using Ajv to upgrade to the latest version to mitigate these risks. Additionally, employing best practices for schema validation can further enhance security.
See every vulnerability recorded for node-ajv →
FAQ
Prototype pollution is a security vulnerability that allows an attacker to modify the prototype of built-in JavaScript objects, potentially leading to arbitrary code execution or application instability.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
The potential impacts include unauthorized code execution, data corruption, and denial of service, which can severely compromise the security and functionality of your application.
No, using Ajv versions prior to 6.12.4-1 is not safe due to the identified prototype pollution vulnerability. It is recommended to upgrade to the fixed version.
The CVSS score for this vulnerability is 5.6, indicating a moderate severity level that requires attention.
Related vulnerabilities
Recent vulnerabilities recorded for node-ajv.