Files
codeql/javascript/ql/test/experimental/Security/CWE-099/EnvValueAndKeyInjection/test.js
2024-06-13 14:52:22 +02:00

19 lines
441 B
JavaScript

const http = require('node:http');
http.createServer((req, res) => {
const { EnvValue, EnvKey } = req.body;
process.env[EnvKey] = EnvValue; // NOT OK
process.env[EnvKey] = EnvValue; // NOT OK
res.end('env has been injected!');
});
http.createServer((req, res) => {
const { EnvValue, EnvKey } = req.body;
process.env[EnvKey] = "constant" // OK
process.env.constant = EnvValue // OK
res.end('env has been injected!');
});