CVE-2022-46175 in
Your scanner flagged json5. Here is what the flaw is, who is at risk, and how to clear the warning.
CVE-2022-46175 is a prototype pollution flaw in the parse() function of the reference JavaScript library. It is fixed in json5 2.2.2 and 1.0.2. The current release on npm is 2.2.3, so most projects only need to move one dependency forward.
We reproduced the flaw on five versions of the library, then fixed a project with an npm override. The real output is below, so you can judge your own exposure and not just clear a red line in a report.
TL;DR: Affected: json5 2.0.0 up to 2.2.1, and everything before 1.0.2. Fixed in 2.2.2 and 1.0.2; 2.2.3 is the current release. GitHub rates it High (CVSS 3.1 score 7.1) and NVD scores it 8.8. Only the returned object is polluted, not the global Object.prototype. You are at risk if your code parses untrusted JSON5 and then reads inherited properties. Fix it with npm update json5 or an overrides entry. See the security tutorial for the wider checklist.
What CVE-2022-46175 Is
In affected releases, JSON5.parse() treated a key named __proto__ as a prototype assignment instead of an ordinary property. Crafted input could therefore set properties on the prototype of the object that parse() returned. Code that later read those properties, for example an isAdmin check, saw values the document's author chose.
The GitHub advisory, GHSA-9c47-m6qq-7p4h, is titled "Prototype Pollution in JSON5 via Parse Method" and files it under CWE-1321. It points out that JSON.parse() ignores __proto__ keys in the same situation. The two scores differ, and the scoring source matters when a scanner shows you a number:
| Source | CVSS 3.1 score | Vector |
|---|---|---|
| GitHub advisory (High) | 7.1 | AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:H |
| NVD, primary score (High) | 8.8 | AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H |
Both are High. They disagree on two metrics: GitHub's CNA record rates attack complexity High and integrity impact Low, while NVD rates attack complexity Low and integrity impact High. We read the NVD figures from its CVE API on 12-01-2026; the same record lists the GitHub score as a secondary entry. Scanners show whichever source they follow, which is why two tools can print 7.1 and 8.8 for the same finding. Neither number says whether your code is exposed. Section Who Is at Risk does.
Affected and Fixed Versions
The GitHub advisory lists the npm package json5 as affected in two ranges and patched in two releases. The NVD configuration uses the same boundaries.
| Line | Affected | Patched |
|---|---|---|
| 2.x | >= 2.0.0, < 2.2.2 | 2.2.2 and later (2.2.3 is current) |
| 1.x and earlier | < 1.0.2 | 1.0.2 and later |
Two details trip people up. The advisory text says "up to and including 2.2.1", which is the same set as "below 2.2.2". And 1.0.2 is a real fix for the 1.x line, so a scanner that still flags 1.0.2 is out of date. The npm registry listed 2.2.3 as the latest tag and 1.0.2 as previous when we read it on 12-01-2026. Newer work on the repository's main branch is unreleased as of that date, so 2.2.3 is the version to install.
What Is Polluted, and What Is Not
We installed each version into its own empty project and ran the same script with Node.js 24.22.1 on 12-01-2026. The input is a document with a harmless key and a __proto__ key:
const JSON5 = require('json5');
const text = '{"user": "guest", "__proto__": {"isAdmin": true}}';
const obj = JSON5.parse(text);
console.log('obj.isAdmin:', obj.isAdmin);
console.log('own keys:', Object.keys(obj).join(','));
console.log('proto is Object.prototype:', Object.getPrototypeOf(obj) === Object.prototype);
console.log('({}).isAdmin:', ({}).isAdmin);
console.log('JSON.parse isAdmin:', JSON.parse(text).isAdmin);The results, with the package version printed by the script:
| json5 | obj.isAdmin | Own keys of obj | Prototype is Object.prototype | ({}).isAdmin |
|---|---|---|---|---|
| 2.2.1 | true | user | false | undefined |
| 2.2.2 | undefined | user,__proto__ | true | undefined |
| 2.2.3 | undefined | user,__proto__ | true | undefined |
| 1.0.1 | true | user | false | undefined |
| 1.0.2 | undefined | user,__proto__ | true | undefined |
Read the table row by row. On 2.2.1 and 1.0.1 the parsed object inherited isAdmin: true, its prototype was replaced, and __proto__ never appeared as a key. A fresh {} in the same process was untouched, so the global Object.prototype was not polluted. That matches the advisory, which says the flaw pollutes the object returned by parse() and not the global prototype. On 2.2.2, 2.2.3 and 1.0.2 the same input produced an ordinary own key named __proto__, the prototype stayed Object.prototype, and isAdmin was undefined. JSON.parse() behaved like the fixed versions.
"Not global" is not "harmless". The advisory states that polluting one object can still matter if the application later uses it in trusted operations. The next sections show where that happens.
Who Is Actually at Risk
Exposure needs three things at once: an attacker controls the JSON5 text, your code parses it with an affected version, and your code then trusts a property the document did not set itself. That is a narrow target, so triage by what your program does with the result.
Realistic exposure
- A server that accepts JSON5 from users, uploads or third parties and reads
role,isAdminoroptionsflags off the parsed object. - Code that merges parsed data into other objects, then checks a missing key.
- Tools that read project files from untrusted repositories, such as a service that analyzes uploaded config.
Usually not exposed
- Build tools that parse only the config files in your own repository.
- Dev dependencies that never run in production.
- Code that only prints or counts the parsed values and never checks inherited properties.
A build tool that reads your own config is not an attack path unless someone else can write that config. A pull request from a stranger can change a file the CI job parses, so the line is trust in the author, not the file type. Even then, the flaw needs a downstream check that reads an inherited property. When a transitive dependency is flagged, the honest answer is usually "low practical risk, update at the next chance". We do not rank it Critical, and we do not claim that no one can exploit it: the advisory itself lists denial of service, cross-site scripting, elevation of privilege and, in extreme cases, remote code execution as possible impacts, depending on the application.
Updating is still the right move for any deployed service. It costs one install, and it removes the finding from your reports.
How to Check Your Project
Start by finding every copy. A project often holds several, one per dependency that pins its own range. We built a test project whose only dependency, a small package we called legacy-tool, depends on json5 2.2.1 exactly. With npm 11.6.4:
$ npm ls json5
[email protected]
`-- [email protected]
`-- [email protected] npm why json5 and npm explain json5 printed the same chain, ending at the dependency that asks for it:
$ npm why json5
[email protected]
node_modules/json5
json5@"2.2.1" from [email protected]
node_modules/legacy-tool
legacy-tool@"file:../legacy-tool/legacy-tool-1.0.0.tgz" from the root project That last line is the one that matters: it names the package you must update or override. npm audit reported the range 2.0.0 - 2.2.1, linked the GitHub advisory and said "No fix available", because the vulnerable copy is exact-pinned by its parent. We cover that case in the next section.
To read a lockfile directly, search for the package entry. In an npm package-lock.json it looks like this, and the version line is the one to compare against the table above:
"node_modules/json5": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", There can be more than one such entry, for example node_modules/foo/node_modules/json5 for a nested copy, so look for every key that ends in /json5. We tested only npm's lockfile format. Yarn and pnpm have their own list and why commands, which we did not run.
How to Fix It
In order of preference: update the package that pulls in json5; if it has no update, override the version; and if you depend on json5 directly, bump your own range to ^2.2.3.
npm: overrides
npm's overrides field replaces a package anywhere in the tree. It only works in the root package.json of the project, and npm's docs say you may not override a package you depend on directly unless the spec matches. We added this to the test project from the previous section:
{
"name": "app",
"dependencies": {
"legacy-tool": "file:../legacy-tool/legacy-tool-1.0.0.tgz"
},
"overrides": {
"json5": "^2.2.3"
}
} After npm install the tree and the audit looked like this. The parent's own manifest still says 2.2.1; npm resolves around it:
$ npm ls json5
[email protected]
`-- [email protected]
`-- [email protected]
$ npm audit
found 0 vulnerabilitiesThe lockfile entry changed to 2.2.3 too. An override can break a package that really needs the older API, so run your tests afterwards. Going from 2.2.1 to 2.2.3 is a patch-level change in the same major line.
Yarn and pnpm
We did not run these two, so the syntax below comes from each project's documentation, read on 12-01-2026. Yarn uses a resolutions field in the root package.json; its docs show a bare package name as a key ("relay-compiler": "3.0.0") and a scoped key such as "@babel/core/json5": "2.1.0" that targets one parent only. pnpm's docs put overrides in pnpm-workspace.yaml, at the root of the project only:
# pnpm-workspace.yaml
overrides:
"json5": "^2.2.3"{
"resolutions": {
"json5": "2.2.3"
}
}After any of these, reinstall, then run the check from the previous section again and confirm that the version moved.
Why the 1.x Line Got a Fix
The 1.0.2 release notes say the same __proto__ change was backported to version 1. The likely reason is visible in the dependency data: some packages declared a range inside the 1.x line, and a range like ^1.0.1 never reaches 2.x. When we read the npm registry on 12-01-2026:
| Package | Declares | Published |
|---|---|---|
loader-utils 1.4.2 | json5: ^1.0.1 | 11-11-2022 |
loader-utils 2.0.4 | json5: ^2.1.2 | 11-11-2022 |
tsconfig-paths 3.15.0 | json5: ^1.0.2 | 12-14-2023 |
tsconfig-paths 4.2.0 | json5: ^2.2.2 | 03-29-2023 |
So a project on an old loader-utils or tsconfig-paths major could not receive the 2.x fix through a normal update, and the 1.0.2 release closes that gap. We have no primary source that states the maintainers' intent, and we make no claim about which other tools stayed on 1.x. Run npm ls json5 to see your own.
A side effect explains one confusing scanner result. The 1.0.2 release was published after 2.2.2, and npm moved its latest tag to it. The 2.2.3 changelog entry reads: "[email protected] is now the 'latest' release according to npm instead of v1.0.2."
Timeline
| Date | Event | Source |
|---|---|---|
| 06-06-2019 | Issue #199 asks whether __proto__ should be treated specially in parse() | GitHub issue |
| 12-16-2022 | Issue #295 reports the prototype pollution; json5 2.2.2 is published the same day | GitHub issue, npm registry |
| 12-17-2022 | Issue #295 closed as completed | GitHub issue |
| 12-23-2022 | GitHub advisory published | GHSA-9c47-m6qq-7p4h |
| 12-24-2022 | NVD publishes CVE-2022-46175 | NVD |
| 12-29-2022 | Advisory reviewed and added to the GitHub Advisory Database | GHSA-9c47-m6qq-7p4h |
| 12-30-2022 | json5 1.0.2 published (backport) | npm registry, GitHub releases |
| 12-31-2022 | json5 2.2.3 published; npm latest returns to the 2.x line | npm registry, changelog |
| 02-22-2024 | GitHub advisory last updated | GHSA-9c47-m6qq-7p4h |
Release dates are the publish times in the npm registry, read on 12-01-2026 (UTC). The advisory credits jdgregson as the reporter and lists jordanbtucker as publisher. The advisory links two fix commits, 62a6540 and 7774c10, in the json5 repository, and the release page for 2.2.2 links 14f8cb1. In the first, the parser stops assigning parsed values with a plain parent[key] = value and defines them with Object.defineProperty instead, which turns a __proto__ key into an ordinary own property. That is the behavior the table in the reproduction section shows.
Hardening Beyond the CVE
Upgrading closes this hole. The habit that protects you from the next one is to treat every parsed document as untrusted data until its shape is checked. The fixed parser still returns an own key named __proto__, which is correct, and some later code can undo the protection. We ran this on json5 2.2.3:
const obj = JSON5.parse('{"user": "guest", "__proto__": {"isAdmin": true}}');
const copy = Object.assign({}, obj);
console.log(copy.isAdmin); // true
console.log(({ ...obj }).isAdmin); // undefined
console.log(Object.hasOwn(obj, 'isAdmin')); // false Object.assign() reads the own __proto__ key and assigns it with normal set semantics, so the copy inherited isAdmin even though the parser was patched. Object spread did not. That is why a patched parser alone is not a security design. Three habits cover it:
- Validate the shape right after parsing. Accept only the keys and types you expect and reject the rest. The schema validation tutorial shows how, and the same applies to model output in the LLM JSON output guide.
- Check own properties for security decisions. Use
Object.hasOwn(obj, 'isAdmin')and notobj.isAdmin. - Be careful with merge helpers. Do not feed parsed documents to deep-merge or
Object.assign()code that you have not read.
For the full list, including input size limits and why never to use eval, read the security tutorial. Language-specific setup is in the JavaScript guide and the Node.js guide.
CVE-2022-46175: Common Questions
Is json5 2.2.3 safe from CVE-2022-46175?
Yes. The flaw is fixed from 2.2.2 on, and in our test 2.2.2 and 2.2.3 both kept the prototype as Object.prototype.
My scanner flags 1.0.2. Is that right?
No. The advisory lists 1.0.2 as patched and our test of 1.0.2 behaved like 2.2.2. Update the scanner data, or confirm the installed version with npm ls json5.
Does it pollute Object.prototype for my whole app?
No. In our test ({}).isAdmin stayed undefined on the affected 2.2.1. Only the returned object changed.
Why do GitHub and NVD show different scores?
GitHub scores 7.1 and NVD scores 8.8. They disagree on attack complexity and integrity impact. Both are High.
npm audit says no fix is available. What now?
An exact pin in a parent blocks the fix. Add an overrides entry for json5 in your root package.json, as in our test, or update the parent package.
Do I need to worry if json5 is only in my build tools?
Usually the practical risk is low, because those tools parse your own files. Update anyway so the finding clears, and be more careful if anyone untrusted can change those files.
Parse Untrusted JSON5 Carefully
Update the library, then check the shape of every document before you trust it.
Sources
(13)
- GitHub Advisory GHSA-9c47-m6qq-7p4h: Prototype Pollution in JSON5 via Parse Method
- NVD: CVE-2022-46175 (scores read from the NVD CVE API on 12-01-2026)
- json5 releases on GitHub (2.2.2, 2.2.3, 1.0.2)
- json5 CHANGELOG at v2.2.3
- json5 issue 295: Prototype Pollution in JSON5
- json5 issue 199: Should __proto__ property be treated specially?
- json5 commit 62a6540: add __proto__ to objects and arrays
- json5 on npm (publish dates and dist-tags from the registry)
- npm docs: package.json overrides
- Yarn docs: resolutions
- pnpm docs: dependency resolution settings (overrides)
- loader-utils on npm (dependency ranges per version)
- tsconfig-paths on npm (dependency ranges per version)
Last reviewed: December 1, 2026. Tested with Node.js 24.22.1 and npm 11.6.4.
JavaScript
Python
TypeScript
Node.js
Rust
Java
C#
Ruby
Kotlin
Lua
Babel
Vite
webpack
ESLint
Prettier
VS Code
JetBrains