Skip to content
This repository was archived by the owner on Mar 20, 2020. It is now read-only.

Commit 033261a

Browse files
author
ao10
committed
Add DangerousPaths route
1 parent d4a43f9 commit 033261a

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

lib/routes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ module.exports = {
1717
inputs: ['query'],
1818
sinks: sinks.cmdInjectionSemanticChainedCommands
1919
},
20+
cmdInjectionSemanticDangerousPaths: {
21+
base: '/cmdInjectionSemanticDangerousPaths',
22+
name: 'Command Injection Semantic Dangerous Paths',
23+
link: 'https://www.owasp.org/index.php/Command_Injection',
24+
products: ['Protect'],
25+
inputs: ['query'],
26+
sinks: sinks.cmdInjectionSemanticDangerousPaths
27+
},
2028
nosqlInjection: {
2129
base: '/nosqlInjection',
2230
name: 'NoSQL Injection',
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use strict';
2+
const cp = require('child_process');
3+
4+
const pre = (str) => `<pre>${str}</pre>`;
5+
6+
/**
7+
* @param {string} input user input string
8+
* @param {Object} opts
9+
* @param {boolean=} opts.safe are we calling the sink safely?
10+
* @param {boolean=} opts.noop are we calling the sink as a noop?
11+
*/
12+
module.exports['child_process.exec'] = async function exec(
13+
input,
14+
{ safe = false, noop = false } = {}
15+
) {
16+
if (safe) return 'SAFE';
17+
if (noop) return 'NOOP';
18+
19+
return new Promise((resolve) => {
20+
cp.exec("/bin/sh -c 'cat /tmp/foo.txt /etc/passwd'", (err, data) => {
21+
if (err) {
22+
console.log(
23+
`exec failed on /bin/sh -c 'cat /tmp/foo.txt /etc/passwd', err: ${err.message}`
24+
);
25+
}
26+
resolve(pre(data.toString()));
27+
});
28+
});
29+
};

lib/sinks/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
sqlInjection: require('./sqlInjection'),
66
cmdInjection: require('./cmdInjection'),
77
cmdInjectionSemanticChainedCommands: require('./cmdInjectionSemanticChainedCommands'),
8+
cmdInjectionSemanticDangerousPaths: require('./cmdInjectionSemanticDangerousPaths'),
89
pathTraversal: require('./pathTraversal'),
910
ssjs: require('./ssjs'),
1011
ssrf: require('./ssrf'),

0 commit comments

Comments
 (0)