Patch transitive json5 prototype-pollution vulnerability via minimal npm override - #2691
Draft
jainakanksha-msft with Copilot wants to merge 2 commits into
Draft
Patch transitive json5 prototype-pollution vulnerability via minimal npm override#2691jainakanksha-msft with Copilot wants to merge 2 commits into
json5 prototype-pollution vulnerability via minimal npm override#2691jainakanksha-msft with Copilot wants to merge 2 commits into
Conversation
Copilot
AI
changed the title
[WIP] Fix prototype pollution vulnerability in JSON5 library
Patch transitive Aug 3, 2026
json5 prototype-pollution vulnerability via minimal npm override
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dependabot flagged
json5@0.5.1(CVE-2022-46175 / GHSA-9c47-m6qq-7p4h), whereJSON5.parsecan set__proto__on parsed objects. This PR upgrades to the lowest patched line (1.0.2) with a scoped transitive override to minimize change surface.Dependency remediation
json5to force resolution to1.0.2(lowest patched version).0.5.1entry is replaced by1.0.2.Reachability assessment
JSON5.parse.JSON5/JSON5.parseusage in runtime or test codepaths.cross-var→babel-register→babel-core→json5), so this change primarily removes scanner-detected vulnerable resolution rather than an actively exercised Azurite runtime path.Minimal change excerpt
{ "overrides": { "json5": "1.0.2", "undici": "^7.28.0" } }Original prompt
This section details the Dependabot vulnerability alert you should resolve
<alert_title>Prototype Pollution in JSON5 via Parse Method</alert_title>
<alert_description>The
parsemethod of the JSON5 library before and including version2.2.1does not restrict parsing of keys named__proto__, allowing specially crafted strings to pollute the prototype of the resulting object.This vulnerability pollutes the prototype of the object returned by
JSON5.parseand not the global Object prototype, which is the commonly understood definition of Prototype Pollution. However, polluting the prototype of a single object can have significant security impact for an application if the object is later used in trusted operations.Impact
This vulnerability could allow an attacker to set arbitrary and unexpected keys on the object returned from
JSON5.parse. The actual impact will depend on how applications utilize the returned object and how they filter unwanted keys, but could include denial of service, cross-site scripting, elevation of privilege, and in extreme cases, remote code execution.Mitigation
This vulnerability is patched in json5 v2.2.2 and later. A patch has also been backported for json5 v1 in versions v1.0.2 and later.
Details
Suppose a developer wants to allow users and admins to perform some risky operation, but they want to restrict what non-admins can do. To accomplish this, they accept a JSON blob from the user, parse it using
JSON5.parse, confirm that the provided data does not set some sensitive keys, and then performs the risky operation using the validated data:If the user attempts to set the
isAdminkey, their request will be rejected:However, users can instead set the
__proto__key to{"isAdmin": true}.JSON5will parse this key and will set theisAdminkey on the prototype of the returned object, allowing the user to bypass the security check and run their request as an admin: