Learn about CVE-2022-46175, a critical security vulnerability in JSON5 library versions 1.0.1 and 2.2.1 allowing prototype pollution. Understand the impact, affected systems, and mitigation steps.
A security vulnerability (CVE-2022-46175) has been identified in the JSON5 library versions 1.0.1 and 2.2.1. This vulnerability allows specially crafted strings to pollute the prototype of the resulting object when using the
parse
method, potentially leading to severe security risks.
Understanding CVE-2022-46175
JSON5 is an extension of the JSON file format, aiming to enhance readability and maintenance of JSON files by humans, such as configuration files.
What is CVE-2022-46175?
The vulnerability in JSON5 library versions 1.0.1 and 2.2.1 enables the parsing of keys named
__proto__
, which can contaminate the prototype of the returned object, posing security threats when the object is later used in trusted operations.
The Impact of CVE-2022-46175
The potential impact of this vulnerability includes denial of service, cross-site scripting, elevation of privilege, and in extreme cases, remote code execution. Although it affects a single object's prototype, the consequences can be severe depending on how the returned object is utilized and unwanted keys are filtered.
Technical Details of CVE-2022-46175
Vulnerability Description
The vulnerability arises from the failure to restrict the parsing of
__proto__
keys in the JSON5.parse
method, diverging from the behavior of JSON.parse
in JavaScript which ignores such keys.
Affected Systems and Versions
The JSON5 library versions before 2.2.2 are affected by this vulnerability.
Exploitation Mechanism
By manipulating the parsing of specially crafted strings containing
__proto__
keys, an attacker can set arbitrary and unexpected keys on the object returned from JSON5.parse
.
Mitigation and Prevention
Immediate Steps to Take
To mitigate this vulnerability, users should update to JSON5 library versions 1.0.2, 2.2.2, or later. Additionally, substituting
JSON5.parse
with JSON.parse
in affected code segments can prevent exploitation.
Long-Term Security Practices
Developers should follow secure coding practices, validate and sanitize inputs, and implement proper filtering mechanisms to prevent similar vulnerabilities.
Patching and Updates
It is crucial to regularly update software libraries and dependencies to address known security issues and apply patches promptly.