Skip to content

Commit 87518ba

Browse files
committed
JS: Update tainted-sendFile.js
This file was added on main while this branch was in progress. Porting the whole file in one step.
1 parent bb67a0e commit 87518ba

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@
161161
| tainted-sendFile.js:15:43:15:58 | req.param("dir") | tainted-sendFile.js:15:43:15:58 | req.param("dir") | tainted-sendFile.js:15:43:15:58 | req.param("dir") | This path depends on a $@. | tainted-sendFile.js:15:43:15:58 | req.param("dir") | user-provided value |
162162
| tainted-sendFile.js:21:16:21:49 | path.re ... rams.x) | tainted-sendFile.js:21:37:21:48 | req.params.x | tainted-sendFile.js:21:16:21:49 | path.re ... rams.x) | This path depends on a $@. | tainted-sendFile.js:21:37:21:48 | req.params.x | user-provided value |
163163
| tainted-sendFile.js:22:16:22:46 | path.jo ... rams.x) | tainted-sendFile.js:22:34:22:45 | req.params.x | tainted-sendFile.js:22:16:22:46 | path.jo ... rams.x) | This path depends on a $@. | tainted-sendFile.js:22:34:22:45 | req.params.x | user-provided value |
164-
| tainted-sendFile.js:27:16:27:33 | req.param("gimme") | tainted-sendFile.js:27:16:27:33 | req.param("gimme") | tainted-sendFile.js:27:16:27:33 | req.param("gimme") | This path depends on a $@. | tainted-sendFile.js:27:16:27:33 | req.param("gimme") | user-provided value |
165-
| tainted-sendFile.js:30:16:30:48 | homeDir ... arams.x | tainted-sendFile.js:30:37:30:48 | req.params.x | tainted-sendFile.js:30:16:30:48 | homeDir ... arams.x | This path depends on a $@. | tainted-sendFile.js:30:37:30:48 | req.params.x | user-provided value |
166-
| tainted-sendFile.js:32:16:32:46 | path.jo ... rams.x) | tainted-sendFile.js:32:34:32:45 | req.params.x | tainted-sendFile.js:32:16:32:46 | path.jo ... rams.x) | This path depends on a $@. | tainted-sendFile.js:32:34:32:45 | req.params.x | user-provided value |
167-
| tainted-sendFile.js:35:43:35:58 | req.param("dir") | tainted-sendFile.js:35:43:35:58 | req.param("dir") | tainted-sendFile.js:35:43:35:58 | req.param("dir") | This path depends on a $@. | tainted-sendFile.js:35:43:35:58 | req.param("dir") | user-provided value |
164+
| tainted-sendFile.js:26:16:26:33 | req.param("gimme") | tainted-sendFile.js:26:16:26:33 | req.param("gimme") | tainted-sendFile.js:26:16:26:33 | req.param("gimme") | This path depends on a $@. | tainted-sendFile.js:26:16:26:33 | req.param("gimme") | user-provided value |
165+
| tainted-sendFile.js:28:16:28:48 | homeDir ... arams.x | tainted-sendFile.js:28:37:28:48 | req.params.x | tainted-sendFile.js:28:16:28:48 | homeDir ... arams.x | This path depends on a $@. | tainted-sendFile.js:28:37:28:48 | req.params.x | user-provided value |
166+
| tainted-sendFile.js:30:16:30:46 | path.jo ... rams.x) | tainted-sendFile.js:30:34:30:45 | req.params.x | tainted-sendFile.js:30:16:30:46 | path.jo ... rams.x) | This path depends on a $@. | tainted-sendFile.js:30:34:30:45 | req.params.x | user-provided value |
167+
| tainted-sendFile.js:32:43:32:58 | req.param("dir") | tainted-sendFile.js:32:43:32:58 | req.param("dir") | tainted-sendFile.js:32:43:32:58 | req.param("dir") | This path depends on a $@. | tainted-sendFile.js:32:43:32:58 | req.param("dir") | user-provided value |
168168
| tainted-string-steps.js:8:18:8:34 | path.substring(4) | tainted-string-steps.js:6:24:6:30 | req.url | tainted-string-steps.js:8:18:8:34 | path.substring(4) | This path depends on a $@. | tainted-string-steps.js:6:24:6:30 | req.url | user-provided value |
169169
| tainted-string-steps.js:9:18:9:37 | path.substring(0, i) | tainted-string-steps.js:6:24:6:30 | req.url | tainted-string-steps.js:9:18:9:37 | path.substring(0, i) | This path depends on a $@. | tainted-string-steps.js:6:24:6:30 | req.url | user-provided value |
170170
| tainted-string-steps.js:10:18:10:31 | path.substr(4) | tainted-string-steps.js:6:24:6:30 | req.url | tainted-string-steps.js:10:18:10:31 | path.substr(4) | This path depends on a $@. | tainted-string-steps.js:6:24:6:30 | req.url | user-provided value |
@@ -571,8 +571,8 @@ edges
571571
| tainted-promise-steps.js:12:20:12:23 | path | tainted-promise-steps.js:12:44:12:47 | path | provenance | |
572572
| tainted-sendFile.js:21:37:21:48 | req.params.x | tainted-sendFile.js:21:16:21:49 | path.re ... rams.x) | provenance | Config |
573573
| tainted-sendFile.js:22:34:22:45 | req.params.x | tainted-sendFile.js:22:16:22:46 | path.jo ... rams.x) | provenance | Config |
574-
| tainted-sendFile.js:30:37:30:48 | req.params.x | tainted-sendFile.js:30:16:30:48 | homeDir ... arams.x | provenance | Config |
575-
| tainted-sendFile.js:32:34:32:45 | req.params.x | tainted-sendFile.js:32:16:32:46 | path.jo ... rams.x) | provenance | Config |
574+
| tainted-sendFile.js:28:37:28:48 | req.params.x | tainted-sendFile.js:28:16:28:48 | homeDir ... arams.x | provenance | Config |
575+
| tainted-sendFile.js:30:34:30:45 | req.params.x | tainted-sendFile.js:30:16:30:46 | path.jo ... rams.x) | provenance | Config |
576576
| tainted-string-steps.js:6:7:6:48 | path | tainted-string-steps.js:8:18:8:21 | path | provenance | |
577577
| tainted-string-steps.js:6:7:6:48 | path | tainted-string-steps.js:9:18:9:21 | path | provenance | |
578578
| tainted-string-steps.js:6:7:6:48 | path | tainted-string-steps.js:10:18:10:21 | path | provenance | |
@@ -1080,12 +1080,12 @@ nodes
10801080
| tainted-sendFile.js:21:37:21:48 | req.params.x | semmle.label | req.params.x |
10811081
| tainted-sendFile.js:22:16:22:46 | path.jo ... rams.x) | semmle.label | path.jo ... rams.x) |
10821082
| tainted-sendFile.js:22:34:22:45 | req.params.x | semmle.label | req.params.x |
1083-
| tainted-sendFile.js:27:16:27:33 | req.param("gimme") | semmle.label | req.param("gimme") |
1084-
| tainted-sendFile.js:30:16:30:48 | homeDir ... arams.x | semmle.label | homeDir ... arams.x |
1085-
| tainted-sendFile.js:30:37:30:48 | req.params.x | semmle.label | req.params.x |
1086-
| tainted-sendFile.js:32:16:32:46 | path.jo ... rams.x) | semmle.label | path.jo ... rams.x) |
1087-
| tainted-sendFile.js:32:34:32:45 | req.params.x | semmle.label | req.params.x |
1088-
| tainted-sendFile.js:35:43:35:58 | req.param("dir") | semmle.label | req.param("dir") |
1083+
| tainted-sendFile.js:26:16:26:33 | req.param("gimme") | semmle.label | req.param("gimme") |
1084+
| tainted-sendFile.js:28:16:28:48 | homeDir ... arams.x | semmle.label | homeDir ... arams.x |
1085+
| tainted-sendFile.js:28:37:28:48 | req.params.x | semmle.label | req.params.x |
1086+
| tainted-sendFile.js:30:16:30:46 | path.jo ... rams.x) | semmle.label | path.jo ... rams.x) |
1087+
| tainted-sendFile.js:30:34:30:45 | req.params.x | semmle.label | req.params.x |
1088+
| tainted-sendFile.js:32:43:32:58 | req.param("dir") | semmle.label | req.param("dir") |
10891089
| tainted-string-steps.js:6:7:6:48 | path | semmle.label | path |
10901090
| tainted-string-steps.js:6:14:6:37 | url.par ... , true) | semmle.label | url.par ... , true) |
10911091
| tainted-string-steps.js:6:14:6:43 | url.par ... ).query | semmle.label | url.par ... ).query |

javascript/ql/test/query-tests/Security/CWE-022/TaintedPath/tainted-sendFile.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,14 @@ app.get('/some/path/:x', function(req, res) {
2323

2424
res.sendFile(homeDir + path.join('data', req.params.x)); // kinda OK - can only escape from 'data/'
2525

26-
// BAD: downloading a file based on un-sanitized query parameters
27-
res.download(req.param("gimme"));
26+
res.download(req.param("gimme")); // $ Alert
2827

29-
// BAD: download allows ../
30-
res.download(homeDir + '/data/' + req.params.x);
28+
res.download(homeDir + '/data/' + req.params.x); // $ Alert
3129

32-
res.download(path.join('data', req.params.x)); // NOT OK
30+
res.download(path.join('data', req.params.x)); // $ Alert
3331

34-
// BAD: doesn't help if user controls root
35-
res.download(req.param("file"), { root: req.param("dir") });
32+
res.download(req.param("file"), { root: req.param("dir") }); // $ Alert
3633

37-
// GOOD: ensures files cannot be accessed outside of root folder
34+
// OK - ensures files cannot be accessed outside of root folder
3835
res.download(req.param("gimme"), { root: process.cwd() });
3936
});

0 commit comments

Comments
 (0)