GHSA-VM64-CFQX-3698
Vulnerability from github – Published: 2022-02-10 20:18 – Updated: 2023-09-11 23:08This affects all versions of package jsen. If an attacker can control the schema file, it could run arbitrary JavaScript code on the victim machine. In the module description and README file there is no mention about the risks of untrusted schema files, so it is assumed that this is applicable. In particular the required field of the schema is not properly sanitized. The resulting string that is build based on the schema definition is then passed to a Function.apply();, leading to an Arbitrary Code Execution.
PoC
const jsen = require('jsen');
let schema = JSON.parse(
{ "type": "object", "properties": { "username": { "type": "string" } }, "required": ["\\"+process.mainModule.require(\'child_process\').execSync(\'touch malicious\')+\\""] }
);
const validate = jsen(schema); validate({});
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "jsen"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "0.6.6"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-7777"
],
"database_specific": {
"cwe_ids": [
"CWE-94"
],
"github_reviewed": true,
"github_reviewed_at": "2021-04-14T19:49:04Z",
"nvd_published_at": "2020-11-23T16:15:00Z",
"severity": "HIGH"
},
"details": "This affects all versions of package jsen. If an attacker can control the schema file, it could run arbitrary JavaScript code on the victim machine. In the module description and README file there is no mention about the risks of untrusted schema files, so it is assumed that this is applicable. In particular the required field of the schema is not properly sanitized. The resulting string that is build based on the schema definition is then passed to a `Function.apply();`, leading to an Arbitrary Code Execution.\n\n### PoC\n```js\nconst jsen = require(\u0027jsen\u0027);\nlet schema = JSON.parse(\n{ \u0026quot;type\u0026quot;: \u0026quot;object\u0026quot;, \u0026quot;properties\u0026quot;: { \u0026quot;username\u0026quot;: { \u0026quot;type\u0026quot;: \u0026quot;string\u0026quot; } }, \u0026quot;required\u0026quot;: [\u0026quot;\\\\\u0026quot;+process.mainModule.require(\\\u0026#39;child_process\\\u0026#39;).execSync(\\\u0026#39;touch malicious\\\u0026#39;)+\\\\\u0026quot;\u0026quot;] }\n);\n\nconst validate = jsen(schema); validate({});\n```",
"id": "GHSA-vm64-cfqx-3698",
"modified": "2023-09-11T23:08:53Z",
"published": "2022-02-10T20:18:37Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-7777"
},
{
"type": "WEB",
"url": "https://github.com/bugventure/jsen/blob/master/lib/jsen.js#L875"
},
{
"type": "WEB",
"url": "https://security.snyk.io/vuln/SNYK-JS-JSEN-1014670"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "Code Injection in jsen"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.