Lucene search

K
osvGoogleOSV:GHSA-VM64-CFQX-3698
HistoryFeb 10, 2022 - 8:18 p.m.

Code Injection in jsen

2022-02-1020:18:37
Google
osv.dev
5

0.002 Low

EPSS

Percentile

53.2%

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.

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({});
CPENameOperatorVersion
jsenle0.6.6

0.002 Low

EPSS

Percentile

53.2%

Related for OSV:GHSA-VM64-CFQX-3698