Skip to content

chore(deps): update dependency json5 to v2.2.2 [security] - #268

Open
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-json5-vulnerability
Open

chore(deps): update dependency json5 to v2.2.2 [security]#268
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-json5-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Feb 25, 2024

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
json5 (source) 2.2.02.2.2 age confidence

Prototype Pollution in JSON5 via Parse Method

CVE-2022-46175 / GHSA-9c47-m6qq-7p4h

More information

Details

The parse method of the JSON5 library before and including version 2.2.1 does 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.parse and 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:

const JSON5 = require('json5');

const doSomethingDangerous = (props) => {
  if (props.isAdmin) {
    console.log('Doing dangerous thing as admin.');
  } else {
    console.log('Doing dangerous thing as user.');
  }
};

const secCheckKeysSet = (obj, searchKeys) => {
  let searchKeyFound = false;
  Object.keys(obj).forEach((key) => {
    if (searchKeys.indexOf(key) > -1) {
      searchKeyFound = true;
    }
  });
  return searchKeyFound;
};

const props = JSON5.parse('{"foo": "bar"}');
if (!secCheckKeysSet(props, ['isAdmin', 'isMod'])) {
  doSomethingDangerous(props); // "Doing dangerous thing as user."
} else {
  throw new Error('Forbidden...');
}

If the user attempts to set the isAdmin key, their request will be rejected:

const props = JSON5.parse('{"foo": "bar", "isAdmin": true}');
if (!secCheckKeysSet(props, ['isAdmin', 'isMod'])) {
  doSomethingDangerous(props);
} else {
  throw new Error('Forbidden...'); // Error: Forbidden...
}

However, users can instead set the __proto__ key to {"isAdmin": true}. JSON5 will parse this key and will set the isAdmin key on the prototype of the returned object, allowing the user to bypass the security check and run their request as an admin:

const props = JSON5.parse('{"foo": "bar", "__proto__": {"isAdmin": true}}');
if (!secCheckKeysSet(props, ['isAdmin', 'isMod'])) {
  doSomethingDangerous(props); // "Doing dangerous thing as admin."
} else {
  throw new Error('Forbidden...');
}

Severity

  • CVSS Score: 7.1 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:L/A:H

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

json5/json5 (json5)

v2.2.2

Compare Source

  • Fix: Properties with the name __proto__ are added to objects and arrays.
    ([#​199]) This also fixes a prototype pollution vulnerability reported by
    Jonathan Gregson! ([#​295]).

v2.2.1

Compare Source


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch 2 times, most recently from 22bf9f4 to a81def3 Compare January 30, 2025 18:09
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from a81def3 to 5246d47 Compare February 9, 2025 17:16
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 5246d47 to 44a9014 Compare March 3, 2025 16:55
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 44a9014 to 03d6dfa Compare March 13, 2025 19:36
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 03d6dfa to d4918a3 Compare April 1, 2025 14:30
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from d4918a3 to ea53873 Compare May 19, 2025 20:26
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from ea53873 to 8ecd937 Compare May 28, 2025 07:48
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 8ecd937 to 0128cba Compare June 22, 2025 12:30
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 0128cba to 9c56a5e Compare July 2, 2025 17:53
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 9c56a5e to be28f26 Compare August 4, 2025 23:30
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from be28f26 to 79c95cd Compare September 25, 2025 15:28
@renovate renovate Bot changed the title fix(deps): update dependency json5 to v2.2.2 [security] chore(deps): update dependency json5 to v2.2.2 [security] Sep 25, 2025
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 79c95cd to 4f7b022 Compare November 10, 2025 20:12
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 4f7b022 to 98d4e3b Compare January 19, 2026 15:58
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 98d4e3b to 1dcc9a7 Compare February 2, 2026 14:47
@renovate renovate Bot changed the title chore(deps): update dependency json5 to v2.2.2 [security] chore(deps): update dependency json5 to v2.2.2 [security] - autoclosed Mar 27, 2026
@renovate renovate Bot closed this Mar 27, 2026
@renovate
renovate Bot deleted the renovate/npm-json5-vulnerability branch March 27, 2026 01:17
@renovate renovate Bot changed the title chore(deps): update dependency json5 to v2.2.2 [security] - autoclosed chore(deps): update dependency json5 to v2.2.2 [security] Mar 30, 2026
@renovate renovate Bot reopened this Mar 30, 2026
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from 1dcc9a7 to e8529a9 Compare March 30, 2026 17:40
@renovate
renovate Bot force-pushed the renovate/npm-json5-vulnerability branch from e8529a9 to 7ba97bb Compare May 23, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants