mirror of
https://github.com/elicpeter/nyx.git
synced 2026-07-03 20:41:00 +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/fastify/benign.js
Normal file
28
tests/dynamic_fixtures/js_frameworks/fastify/benign.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Phase 13 (Track L.11) — Fastify CMDI benign fixture.
|
||||
//
|
||||
// The `/run` route accepts a `cmd` query parameter but rejects
|
||||
// everything outside an allowlist before invoking
|
||||
// `child_process.execFile` with a fixed argv.
|
||||
|
||||
const fastify = require('fastify')();
|
||||
const { execFile } = require('child_process');
|
||||
|
||||
const ALLOW = new Set(['status', 'uptime', 'version']);
|
||||
|
||||
async function runCmd(request, reply) {
|
||||
const cmd = request.query.cmd || '';
|
||||
if (!ALLOW.has(cmd)) {
|
||||
reply.code(400).send('rejected');
|
||||
return;
|
||||
}
|
||||
const out = await new Promise((resolve) => {
|
||||
execFile('/usr/bin/echo', [cmd], (err, stdout) => {
|
||||
resolve(err ? String(err) : stdout);
|
||||
});
|
||||
});
|
||||
reply.send(out);
|
||||
}
|
||||
|
||||
fastify.get('/run', runCmd);
|
||||
|
||||
module.exports = { app: fastify, runCmd };
|
||||
20
tests/dynamic_fixtures/js_frameworks/fastify/vuln.js
Normal file
20
tests/dynamic_fixtures/js_frameworks/fastify/vuln.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Phase 13 (Track L.11) — Fastify CMDI vuln fixture.
|
||||
//
|
||||
// The `/run` route forwards a `cmd` query parameter straight into
|
||||
// `child_process.exec`. Adapter binding: `fastify.get('/run', runCmd)`
|
||||
// with `cmd` flowing through `request.query.cmd`.
|
||||
|
||||
const fastify = require('fastify')();
|
||||
const { exec } = require('child_process');
|
||||
|
||||
async function runCmd(request, reply) {
|
||||
const cmd = request.query.cmd || '';
|
||||
const out = await new Promise((resolve) => {
|
||||
exec('ls ' + cmd, (err, stdout) => resolve(err ? String(err) : stdout));
|
||||
});
|
||||
reply.send(out);
|
||||
}
|
||||
|
||||
fastify.get('/run', runCmd);
|
||||
|
||||
module.exports = { app: fastify, runCmd };
|
||||
Loading…
Add table
Add a link
Reference in a new issue