Skip to content

Commit 42600c9

Browse files
committed
Added tests which shows false positive SSRF via matchAll
1 parent 449cee9 commit 42600c9

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

javascript/ql/test/experimental/Security/CWE-918/SSRF.expected

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ nodes
5151
| check-regex.js:41:13:41:43 | "test.c ... tainted |
5252
| check-regex.js:41:27:41:43 | req.query.tainted |
5353
| check-regex.js:41:27:41:43 | req.query.tainted |
54+
| check-regex.js:58:15:58:42 | baseURL ... tainted |
55+
| check-regex.js:58:15:58:42 | baseURL ... tainted |
56+
| check-regex.js:58:25:58:42 | req.params.tainted |
57+
| check-regex.js:58:25:58:42 | req.params.tainted |
58+
| check-regex.js:61:15:61:42 | baseURL ... tainted |
59+
| check-regex.js:61:15:61:42 | baseURL ... tainted |
60+
| check-regex.js:61:25:61:42 | req.params.tainted |
61+
| check-regex.js:61:25:61:42 | req.params.tainted |
62+
| check-regex.js:63:15:63:42 | baseURL ... tainted |
63+
| check-regex.js:63:15:63:42 | baseURL ... tainted |
64+
| check-regex.js:63:25:63:42 | req.params.tainted |
65+
| check-regex.js:63:25:63:42 | req.params.tainted |
5466
| check-validator.js:15:15:15:45 | "test.c ... tainted |
5567
| check-validator.js:15:15:15:45 | "test.c ... tainted |
5668
| check-validator.js:15:29:15:45 | req.query.tainted |
@@ -127,6 +139,18 @@ edges
127139
| check-regex.js:41:27:41:43 | req.query.tainted | check-regex.js:41:13:41:43 | "test.c ... tainted |
128140
| check-regex.js:41:27:41:43 | req.query.tainted | check-regex.js:41:13:41:43 | "test.c ... tainted |
129141
| check-regex.js:41:27:41:43 | req.query.tainted | check-regex.js:41:13:41:43 | "test.c ... tainted |
142+
| check-regex.js:58:25:58:42 | req.params.tainted | check-regex.js:58:15:58:42 | baseURL ... tainted |
143+
| check-regex.js:58:25:58:42 | req.params.tainted | check-regex.js:58:15:58:42 | baseURL ... tainted |
144+
| check-regex.js:58:25:58:42 | req.params.tainted | check-regex.js:58:15:58:42 | baseURL ... tainted |
145+
| check-regex.js:58:25:58:42 | req.params.tainted | check-regex.js:58:15:58:42 | baseURL ... tainted |
146+
| check-regex.js:61:25:61:42 | req.params.tainted | check-regex.js:61:15:61:42 | baseURL ... tainted |
147+
| check-regex.js:61:25:61:42 | req.params.tainted | check-regex.js:61:15:61:42 | baseURL ... tainted |
148+
| check-regex.js:61:25:61:42 | req.params.tainted | check-regex.js:61:15:61:42 | baseURL ... tainted |
149+
| check-regex.js:61:25:61:42 | req.params.tainted | check-regex.js:61:15:61:42 | baseURL ... tainted |
150+
| check-regex.js:63:25:63:42 | req.params.tainted | check-regex.js:63:15:63:42 | baseURL ... tainted |
151+
| check-regex.js:63:25:63:42 | req.params.tainted | check-regex.js:63:15:63:42 | baseURL ... tainted |
152+
| check-regex.js:63:25:63:42 | req.params.tainted | check-regex.js:63:15:63:42 | baseURL ... tainted |
153+
| check-regex.js:63:25:63:42 | req.params.tainted | check-regex.js:63:15:63:42 | baseURL ... tainted |
130154
| check-validator.js:15:29:15:45 | req.query.tainted | check-validator.js:15:15:15:45 | "test.c ... tainted |
131155
| check-validator.js:15:29:15:45 | req.query.tainted | check-validator.js:15:15:15:45 | "test.c ... tainted |
132156
| check-validator.js:15:29:15:45 | req.query.tainted | check-validator.js:15:15:15:45 | "test.c ... tainted |
@@ -166,6 +190,9 @@ edges
166190
| check-regex.js:31:15:31:45 | "test.c ... tainted | check-regex.js:31:29:31:45 | req.query.tainted | check-regex.js:31:15:31:45 | "test.c ... tainted | The URL of this request depends on a user-provided value. |
167191
| check-regex.js:34:15:34:42 | baseURL ... tainted | check-regex.js:34:25:34:42 | req.params.tainted | check-regex.js:34:15:34:42 | baseURL ... tainted | The URL of this request depends on a user-provided value. |
168192
| check-regex.js:41:13:41:43 | "test.c ... tainted | check-regex.js:41:27:41:43 | req.query.tainted | check-regex.js:41:13:41:43 | "test.c ... tainted | The URL of this request depends on a user-provided value. |
193+
| check-regex.js:58:15:58:42 | baseURL ... tainted | check-regex.js:58:25:58:42 | req.params.tainted | check-regex.js:58:15:58:42 | baseURL ... tainted | The URL of this request depends on a user-provided value. |
194+
| check-regex.js:61:15:61:42 | baseURL ... tainted | check-regex.js:61:25:61:42 | req.params.tainted | check-regex.js:61:15:61:42 | baseURL ... tainted | The URL of this request depends on a user-provided value. |
195+
| check-regex.js:63:15:63:42 | baseURL ... tainted | check-regex.js:63:25:63:42 | req.params.tainted | check-regex.js:63:15:63:42 | baseURL ... tainted | The URL of this request depends on a user-provided value. |
169196
| check-validator.js:15:15:15:45 | "test.c ... tainted | check-validator.js:15:29:15:45 | req.query.tainted | check-validator.js:15:15:15:45 | "test.c ... tainted | The URL of this request depends on a user-provided value. |
170197
| check-validator.js:27:15:27:45 | "test.c ... tainted | check-validator.js:27:29:27:45 | req.query.tainted | check-validator.js:27:15:27:45 | "test.c ... tainted | The URL of this request depends on a user-provided value. |
171198
| check-validator.js:50:15:50:45 | "test.c ... tainted | check-validator.js:50:29:50:45 | req.query.tainted | check-validator.js:50:15:50:45 | "test.c ... tainted | The URL of this request depends on a user-provided value. |

javascript/ql/test/experimental/Security/CWE-918/check-regex.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,17 @@ app.get('/check-with-axios', req => {
5151
const isValidPath = path => path.match(/^[0-9a-z]+$/);
5252

5353
const isInBlackList = path => path.match(/^[/\.%]+$/);
54+
55+
app.get('/check-with-axios', req => {
56+
const baseURL = "test.com/"
57+
if (isValidPathMatchAll(req.params.tainted) ) {
58+
axios.get(baseURL + req.params.tainted); // OK
59+
}
60+
if (!isValidPathMatchAll(req.params.tainted) ) {
61+
axios.get(baseURL + req.params.tainted); // SSRF
62+
} else {
63+
axios.get(baseURL + req.params.tainted); // OK
64+
}
65+
});
66+
67+
const isValidPathMatchAll = path => path.matchAll(/^[0-9a-z]+$/g);

0 commit comments

Comments
 (0)