From c39c04cb86c074ae2684c5997bf13d4728cd1d3c Mon Sep 17 00:00:00 2001 From: Napalys Klicius Date: Wed, 27 Aug 2025 10:20:38 +0000 Subject: [PATCH] JS: added new test case for remote prop injection via `Object.keys` --- .../RemotePropertyInjection.expected | 22 +++++++++---------- .../CWE-400/RemotePropertyInjection/tst.js | 9 ++++++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/RemotePropertyInjection.expected b/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/RemotePropertyInjection.expected index 9b486b59333..0352205e30b 100644 --- a/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/RemotePropertyInjection.expected +++ b/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/RemotePropertyInjection.expected @@ -11,11 +11,11 @@ edges | tst.js:8:6:8:52 | prop | tst.js:16:10:16:13 | prop | provenance | | | tst.js:8:13:8:52 | myCoolL ... rolled) | tst.js:8:6:8:52 | prop | provenance | | | tst.js:8:28:8:51 | req.que ... trolled | tst.js:8:13:8:52 | myCoolL ... rolled) | provenance | | -| tst.js:8:28:8:51 | req.que ... trolled | tst.js:21:25:21:25 | x | provenance | | -| tst.js:21:25:21:25 | x | tst.js:22:15:22:15 | x | provenance | | -| tst.js:22:6:22:15 | result | tst.js:23:9:23:14 | result | provenance | | -| tst.js:22:15:22:15 | x | tst.js:22:6:22:15 | result | provenance | | -| tst.js:23:9:23:14 | result | tst.js:23:9:23:42 | result. ... length) | provenance | | +| tst.js:8:28:8:51 | req.que ... trolled | tst.js:27:25:27:25 | x | provenance | | +| tst.js:27:25:27:25 | x | tst.js:28:15:28:15 | x | provenance | | +| tst.js:28:6:28:15 | result | tst.js:29:9:29:14 | result | provenance | | +| tst.js:28:15:28:15 | x | tst.js:28:6:28:15 | result | provenance | | +| tst.js:29:9:29:14 | result | tst.js:29:9:29:42 | result. ... length) | provenance | | | tstNonExpr.js:5:7:5:23 | userVal | tstNonExpr.js:8:17:8:23 | userVal | provenance | | | tstNonExpr.js:5:17:5:23 | req.url | tstNonExpr.js:5:7:5:23 | userVal | provenance | | nodes @@ -26,13 +26,13 @@ nodes | tst.js:13:15:13:18 | prop | semmle.label | prop | | tst.js:14:31:14:34 | prop | semmle.label | prop | | tst.js:16:10:16:13 | prop | semmle.label | prop | -| tst.js:21:25:21:25 | x | semmle.label | x | -| tst.js:22:6:22:15 | result | semmle.label | result | -| tst.js:22:15:22:15 | x | semmle.label | x | -| tst.js:23:9:23:14 | result | semmle.label | result | -| tst.js:23:9:23:42 | result. ... length) | semmle.label | result. ... length) | +| tst.js:27:25:27:25 | x | semmle.label | x | +| tst.js:28:6:28:15 | result | semmle.label | result | +| tst.js:28:15:28:15 | x | semmle.label | x | +| tst.js:29:9:29:14 | result | semmle.label | result | +| tst.js:29:9:29:42 | result. ... length) | semmle.label | result. ... length) | | tstNonExpr.js:5:7:5:23 | userVal | semmle.label | userVal | | tstNonExpr.js:5:17:5:23 | req.url | semmle.label | req.url | | tstNonExpr.js:8:17:8:23 | userVal | semmle.label | userVal | subpaths -| tst.js:8:28:8:51 | req.que ... trolled | tst.js:21:25:21:25 | x | tst.js:23:9:23:42 | result. ... length) | tst.js:8:13:8:52 | myCoolL ... rolled) | +| tst.js:8:28:8:51 | req.que ... trolled | tst.js:27:25:27:25 | x | tst.js:29:9:29:42 | result. ... length) | tst.js:8:13:8:52 | myCoolL ... rolled) | diff --git a/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/tst.js b/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/tst.js index 301b7b80881..122e9a4c51f 100644 --- a/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/tst.js +++ b/javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/tst.js @@ -16,10 +16,15 @@ app.get('/user/:id', function(req, res) { headers[prop] = 42; // $ Alert res.set(headers); myCoolLocalFct[req.query.x](); // OK - flagged by method name injection + + Object.keys(req.body).forEach( // $ MISSING: Source + key => { + myObj[key] = 42; // $ MISSING: Alert + } + ); }); function myCoolLocalFct(x) { var result = x; return result.substring(0, result.length); - -} \ No newline at end of file +}