mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-30 20:39:39 +02:00
Dynamic (#77)
This commit is contained in:
parent
55247b7fcd
commit
991c84a1eb
1464 changed files with 225448 additions and 1985 deletions
28
tests/dynamic_fixtures/js_frameworks/express/benign.js
Normal file
28
tests/dynamic_fixtures/js_frameworks/express/benign.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Phase 13 (Track L.11) — Express CMDI benign fixture.
|
||||
//
|
||||
// The `/run` route accepts a `cmd` query parameter but rejects
|
||||
// everything outside an allowlist before invoking `child_process.exec`
|
||||
// with a fixed argv, so the sink call is unreachable for
|
||||
// attacker-controlled values.
|
||||
|
||||
const express = require('express');
|
||||
const { execFile } = require('child_process');
|
||||
|
||||
const app = express();
|
||||
|
||||
const ALLOW = new Set(['status', 'uptime', 'version']);
|
||||
|
||||
function runCmd(req, res) {
|
||||
const cmd = req.query.cmd || '';
|
||||
if (!ALLOW.has(cmd)) {
|
||||
return res.status(400).send('rejected');
|
||||
}
|
||||
execFile('/usr/bin/echo', [cmd], (err, stdout) => {
|
||||
if (err) return res.status(500).send(String(err));
|
||||
res.send(stdout);
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/run', runCmd);
|
||||
|
||||
module.exports = { app, runCmd };
|
||||
23
tests/dynamic_fixtures/js_frameworks/express/vuln.js
Normal file
23
tests/dynamic_fixtures/js_frameworks/express/vuln.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Phase 13 (Track L.11) — Express CMDI vuln fixture.
|
||||
//
|
||||
// The `/run` route forwards a `cmd` query parameter straight into
|
||||
// `child_process.exec`, so any attacker who reaches the route can
|
||||
// execute arbitrary shell. Adapter binding:
|
||||
// `app.get('/run', runCmd)` with `cmd` flowing through `req.query.cmd`.
|
||||
|
||||
const express = require('express');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
const app = express();
|
||||
|
||||
function runCmd(req, res) {
|
||||
const cmd = req.query.cmd || '';
|
||||
exec('ls ' + cmd, (err, stdout) => {
|
||||
if (err) return res.status(500).send(String(err));
|
||||
res.send(stdout);
|
||||
});
|
||||
}
|
||||
|
||||
app.get('/run', runCmd);
|
||||
|
||||
module.exports = { app, runCmd };
|
||||
Loading…
Add table
Add a link
Reference in a new issue