Skip to content

Commit 4b7d60a

Browse files
authored
Merge pull request github#3803 from esbena/js/more-fs-promises
Approved by erik-krogh
2 parents c52f68e + c7f67fa commit 4b7d60a

File tree

3 files changed

+116
-3
lines changed

3 files changed

+116
-3
lines changed

javascript/ql/src/semmle/javascript/frameworks/NodeJSLib.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,18 @@ module NodeJSLib {
459459
) and
460460
t.start()
461461
or
462-
exists(DataFlow::TypeTracker t2 | result = fsModule(t2).track(t2, t))
462+
exists(DataFlow::TypeTracker t2, DataFlow::SourceNode pred | pred = fsModule(t2) |
463+
result = pred.track(t2, t)
464+
or
465+
t.continue() = t2 and
466+
exists(DataFlow::CallNode promisifyAllCall |
467+
result = promisifyAllCall and
468+
pred.flowsTo(promisifyAllCall.getArgument(0)) and
469+
promisifyAllCall =
470+
[DataFlow::moduleMember("bluebird", "promisifyAll"),
471+
DataFlow::moduleImport("util-promisifyall")].getACall()
472+
)
473+
)
463474
}
464475
}
465476

@@ -605,7 +616,7 @@ module NodeJSLib {
605616
result = callback
606617
or
607618
exists(DataFlow::CallNode promisify |
608-
promisify = DataFlow::moduleMember("util", "promisify").getACall()
619+
promisify = DataFlow::moduleMember(["util", "bluebird"], "promisify").getACall()
609620
|
610621
result = promisify and promisify.getArgument(0).getALocalSource() = callback
611622
)

javascript/ql/test/query-tests/Security/CWE-022/TaintedPath/TaintedPath.expected

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,40 @@ nodes
21682168
| other-fs-libraries.js:40:35:40:38 | path |
21692169
| other-fs-libraries.js:40:35:40:38 | path |
21702170
| other-fs-libraries.js:40:35:40:38 | path |
2171+
| other-fs-libraries.js:41:50:41:53 | path |
2172+
| other-fs-libraries.js:41:50:41:53 | path |
2173+
| other-fs-libraries.js:41:50:41:53 | path |
2174+
| other-fs-libraries.js:41:50:41:53 | path |
2175+
| other-fs-libraries.js:41:50:41:53 | path |
2176+
| other-fs-libraries.js:41:50:41:53 | path |
2177+
| other-fs-libraries.js:41:50:41:53 | path |
2178+
| other-fs-libraries.js:41:50:41:53 | path |
2179+
| other-fs-libraries.js:41:50:41:53 | path |
2180+
| other-fs-libraries.js:41:50:41:53 | path |
2181+
| other-fs-libraries.js:41:50:41:53 | path |
2182+
| other-fs-libraries.js:41:50:41:53 | path |
2183+
| other-fs-libraries.js:41:50:41:53 | path |
2184+
| other-fs-libraries.js:41:50:41:53 | path |
2185+
| other-fs-libraries.js:41:50:41:53 | path |
2186+
| other-fs-libraries.js:41:50:41:53 | path |
2187+
| other-fs-libraries.js:41:50:41:53 | path |
2188+
| other-fs-libraries.js:42:53:42:56 | path |
2189+
| other-fs-libraries.js:42:53:42:56 | path |
2190+
| other-fs-libraries.js:42:53:42:56 | path |
2191+
| other-fs-libraries.js:42:53:42:56 | path |
2192+
| other-fs-libraries.js:42:53:42:56 | path |
2193+
| other-fs-libraries.js:42:53:42:56 | path |
2194+
| other-fs-libraries.js:42:53:42:56 | path |
2195+
| other-fs-libraries.js:42:53:42:56 | path |
2196+
| other-fs-libraries.js:42:53:42:56 | path |
2197+
| other-fs-libraries.js:42:53:42:56 | path |
2198+
| other-fs-libraries.js:42:53:42:56 | path |
2199+
| other-fs-libraries.js:42:53:42:56 | path |
2200+
| other-fs-libraries.js:42:53:42:56 | path |
2201+
| other-fs-libraries.js:42:53:42:56 | path |
2202+
| other-fs-libraries.js:42:53:42:56 | path |
2203+
| other-fs-libraries.js:42:53:42:56 | path |
2204+
| other-fs-libraries.js:42:53:42:56 | path |
21712205
| tainted-access-paths.js:6:7:6:48 | path |
21722206
| tainted-access-paths.js:6:7:6:48 | path |
21732207
| tainted-access-paths.js:6:7:6:48 | path |
@@ -6090,6 +6124,70 @@ edges
60906124
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:40:35:40:38 | path |
60916125
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:40:35:40:38 | path |
60926126
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:40:35:40:38 | path |
6127+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6128+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6129+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6130+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6131+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6132+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6133+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6134+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6135+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6136+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6137+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6138+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6139+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6140+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6141+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6142+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6143+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6144+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6145+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6146+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6147+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6148+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6149+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6150+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6151+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6152+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6153+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6154+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6155+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6156+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6157+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6158+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:41:50:41:53 | path |
6159+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6160+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6161+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6162+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6163+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6164+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6165+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6166+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6167+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6168+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6169+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6170+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6171+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6172+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6173+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6174+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6175+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6176+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6177+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6178+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6179+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6180+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6181+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6182+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6183+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6184+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6185+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6186+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6187+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6188+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6189+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
6190+
| other-fs-libraries.js:38:7:38:48 | path | other-fs-libraries.js:42:53:42:56 | path |
60936191
| other-fs-libraries.js:38:14:38:37 | url.par ... , true) | other-fs-libraries.js:38:14:38:43 | url.par ... ).query |
60946192
| other-fs-libraries.js:38:14:38:37 | url.par ... , true) | other-fs-libraries.js:38:14:38:43 | url.par ... ).query |
60956193
| other-fs-libraries.js:38:14:38:37 | url.par ... , true) | other-fs-libraries.js:38:14:38:43 | url.par ... ).query |
@@ -7470,6 +7568,8 @@ edges
74707568
| other-fs-libraries.js:19:56:19:59 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:19:56:19:59 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |
74717569
| other-fs-libraries.js:24:35:24:38 | path | other-fs-libraries.js:9:24:9:30 | req.url | other-fs-libraries.js:24:35:24:38 | path | This path depends on $@. | other-fs-libraries.js:9:24:9:30 | req.url | a user-provided value |
74727570
| other-fs-libraries.js:40:35:40:38 | path | other-fs-libraries.js:38:24:38:30 | req.url | other-fs-libraries.js:40:35:40:38 | path | This path depends on $@. | other-fs-libraries.js:38:24:38:30 | req.url | a user-provided value |
7571+
| other-fs-libraries.js:41:50:41:53 | path | other-fs-libraries.js:38:24:38:30 | req.url | other-fs-libraries.js:41:50:41:53 | path | This path depends on $@. | other-fs-libraries.js:38:24:38:30 | req.url | a user-provided value |
7572+
| other-fs-libraries.js:42:53:42:56 | path | other-fs-libraries.js:38:24:38:30 | req.url | other-fs-libraries.js:42:53:42:56 | path | This path depends on $@. | other-fs-libraries.js:38:24:38:30 | req.url | a user-provided value |
74737573
| tainted-access-paths.js:8:19:8:22 | path | tainted-access-paths.js:6:24:6:30 | req.url | tainted-access-paths.js:8:19:8:22 | path | This path depends on $@. | tainted-access-paths.js:6:24:6:30 | req.url | a user-provided value |
74747574
| tainted-access-paths.js:12:19:12:25 | obj.sub | tainted-access-paths.js:6:24:6:30 | req.url | tainted-access-paths.js:12:19:12:25 | obj.sub | This path depends on $@. | tainted-access-paths.js:6:24:6:30 | req.url | a user-provided value |
74757575
| tainted-access-paths.js:26:19:26:26 | obj.sub3 | tainted-access-paths.js:6:24:6:30 | req.url | tainted-access-paths.js:26:19:26:26 | obj.sub3 | This path depends on $@. | tainted-access-paths.js:6:24:6:30 | req.url | a user-provided value |

javascript/ql/test/query-tests/Security/CWE-022/TaintedPath/other-fs-libraries.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ http.createServer(function(req, res) {
3838
var path = url.parse(req.url, true).query.path;
3939

4040
util.promisify(fs.readFileSync)(path); // NOT OK
41-
});
41+
require("bluebird").promisify(fs.readFileSync)(path); // NOT OK
42+
require("bluebird").promisifyAll(fs).readFileSync(path); // NOT OK
43+
});

0 commit comments

Comments
 (0)