# json-ptr arbitrary code execution in .get() method

Source: https://junglewise.ai/threats/json-ptr-arbitrary-code-execution-in-get-method-2eb60ebe  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2021-05-26. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: info · CVSS 8.6 · Published 2021-05-26

json-ptr is a JavaScript library for accessing values within JSON objects using pointer notation. If an application passes unsanitized user input to the library's .get() method, an attacker can inject malicious code that will be executed on the server, potentially leading to data theft, service disruption, or system compromise.

Technologies: [json-ptr (npm)](https://junglewise.ai/threats/technologies/json-ptr). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Informational severity, with a CVSS score of 8.6, published 26 May 2021.

**Which products and versions are affected?** json-ptr (npm) SEMVER:introduced=0,fixed=2.1.0.

**Is there a fix for This vulnerability?** Yes. json-ptr (npm): upgrade to 2.1.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network.

**Am I affected?** Check whether you run json-ptr (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- json-ptr (npm): upgrade to 2.1.0 or later

  ```sh
  npm install json-ptr@2.1.0
  ```


## Technical details

This is an code injection vulnerability (CWE-74) in json-ptr versions prior to v2.1.0, specifically in the .get() method. The vulnerability stems from insufficient input sanitization when processing user-supplied pointer locations; attackers can break out of the intended expression context by injecting single quotes and additional code. An attacker who can control the pointer parameter passed to .get() (for example, via HTTP requests) can achieve arbitrary code execution. The fix, released in v2.1.0, implements proper escaping of single quotes and backslashes in the pointer path.

## Affected products

- flitbit json-ptr prior to v2.1.0

## Timeline

- 2021-05-26: disclosed
- 2021-05-26: patched: v2.1.0 released with security fix

## References

- [https://github.com/418sec/json-ptr/pull/3](https://github.com/418sec/json-ptr/pull/3)
- [https://github.com/flitbit/json-ptr/blob/456a1728b45c8663bb1ac20a249c5fb17495ec6b/README.md](https://github.com/flitbit/json-ptr/blob/456a1728b45c8663bb1ac20a249c5fb17495ec6b/README.md)

## Related threats

- [json-ptr prototype pollution via type confusion](https://junglewise.ai/threats/cve-2021-23509-json-ptr-prototype-pollution-via-type-confusion)
- [json-ptr prototype pollution leading to code execution](https://junglewise.ai/threats/cve-2020-7766-json-ptr-prototype-pollution-leading-to-code-execution)
