Why it matters
Loading it can run code chosen by the caller.
How to fix it
Accept JSON and parse it with JSON.parse, then validate the result against a schema.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
const serialize = require("node-serialize");
const express = require("express");
const app = express();
app.post("/restore", (req, res) => {
const state = serialize.unserialize(req.body.state);
res.json({ keys: Object.keys(state) });
});const express = require("express");
const app = express();
app.post("/restore", (req, res) => {
const state = JSON.parse(req.body.state);
res.json({ keys: Object.keys(state) });
});What TrustIvan reads
Runs on repository scans of JavaScript source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- DOM XSS from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-dom-xss - Code injection from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-code-injection - Reflected XSS from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-reflected-xss - Open redirect from request input (JavaScript)
JavaScriptSeverity: Medium
trustivan-javascript-taint-open-redirect - SSRF from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-ssrf - NoSQL injection from request input (JavaScript)
JavaScriptSeverity: High
trustivan-javascript-taint-nosql-injection
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation