Skip to content

Commit 3260658

Browse files
committed
JS: add enumeration taint flow to Remote Property Injection query
1 parent c39c04c commit 3260658

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/RemotePropertyInjectionQuery.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import javascript
1212
import RemotePropertyInjectionCustomizations::RemotePropertyInjection
13+
private import semmle.javascript.DynamicPropertyAccess
1314

1415
/**
1516
* A taint-tracking configuration for reasoning about remote property injection.
@@ -24,6 +25,10 @@ module RemotePropertyInjectionConfig implements DataFlow::ConfigSig {
2425
node = StringConcatenation::getRoot(any(ConstantString str).flow())
2526
}
2627

28+
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
29+
node1 = node2.(EnumeratedPropName).getSourceObject()
30+
}
31+
2732
predicate observeDiffInformedIncrementalMode() { any() }
2833
}
2934

javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/RemotePropertyInjection.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| tst.js:13:15:13:18 | prop | tst.js:8:28:8:51 | req.que ... trolled | tst.js:13:15:13:18 | prop | A property name to write to depends on a $@. | tst.js:8:28:8:51 | req.que ... trolled | user-provided value |
44
| tst.js:14:31:14:34 | prop | tst.js:8:28:8:51 | req.que ... trolled | tst.js:14:31:14:34 | prop | A property name to write to depends on a $@. | tst.js:8:28:8:51 | req.que ... trolled | user-provided value |
55
| tst.js:16:10:16:13 | prop | tst.js:8:28:8:51 | req.que ... trolled | tst.js:16:10:16:13 | prop | A property name to write to depends on a $@. | tst.js:8:28:8:51 | req.que ... trolled | user-provided value |
6+
| tst.js:22:10:22:12 | key | tst.js:20:14:20:21 | req.body | tst.js:22:10:22:12 | key | A property name to write to depends on a $@. | tst.js:20:14:20:21 | req.body | user-provided value |
67
| tstNonExpr.js:8:17:8:23 | userVal | tstNonExpr.js:5:17:5:23 | req.url | tstNonExpr.js:8:17:8:23 | userVal | A header name depends on a $@. | tstNonExpr.js:5:17:5:23 | req.url | user-provided value |
78
edges
89
| tst.js:8:6:8:52 | prop | tst.js:9:8:9:11 | prop | provenance | |
@@ -12,6 +13,8 @@ edges
1213
| tst.js:8:13:8:52 | myCoolL ... rolled) | tst.js:8:6:8:52 | prop | provenance | |
1314
| tst.js:8:28:8:51 | req.que ... trolled | tst.js:8:13:8:52 | myCoolL ... rolled) | provenance | |
1415
| tst.js:8:28:8:51 | req.que ... trolled | tst.js:27:25:27:25 | x | provenance | |
16+
| tst.js:20:14:20:21 | req.body | tst.js:21:3:21:5 | key | provenance | Config |
17+
| tst.js:21:3:21:5 | key | tst.js:22:10:22:12 | key | provenance | |
1518
| tst.js:27:25:27:25 | x | tst.js:28:15:28:15 | x | provenance | |
1619
| tst.js:28:6:28:15 | result | tst.js:29:9:29:14 | result | provenance | |
1720
| tst.js:28:15:28:15 | x | tst.js:28:6:28:15 | result | provenance | |
@@ -26,6 +29,9 @@ nodes
2629
| tst.js:13:15:13:18 | prop | semmle.label | prop |
2730
| tst.js:14:31:14:34 | prop | semmle.label | prop |
2831
| tst.js:16:10:16:13 | prop | semmle.label | prop |
32+
| tst.js:20:14:20:21 | req.body | semmle.label | req.body |
33+
| tst.js:21:3:21:5 | key | semmle.label | key |
34+
| tst.js:22:10:22:12 | key | semmle.label | key |
2935
| tst.js:27:25:27:25 | x | semmle.label | x |
3036
| tst.js:28:6:28:15 | result | semmle.label | result |
3137
| tst.js:28:15:28:15 | x | semmle.label | x |

javascript/ql/test/query-tests/Security/CWE-400/RemotePropertyInjection/tst.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ app.get('/user/:id', function(req, res) {
1717
res.set(headers);
1818
myCoolLocalFct[req.query.x](); // OK - flagged by method name injection
1919

20-
Object.keys(req.body).forEach( // $ MISSING: Source
20+
Object.keys(req.body).forEach( // $ Source
2121
key => {
22-
myObj[key] = 42; // $ MISSING: Alert
22+
myObj[key] = 42; // $ Alert
2323
}
2424
);
2525
});

0 commit comments

Comments
 (0)