Skip to content

Commit 321b3f1

Browse files
author
Esben Sparre Andreasen
committed
JS: use ports to sharpen js/incomplete-url-substring-sanitization
1 parent 83e2689 commit 321b3f1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

javascript/ql/src/Security/CWE-020/IncompleteUrlSubstringSanitization.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151
name = "endsWith" and
5252
target.regexpMatch("(?i)\\.([a-z0-9-]+)(\\.[a-z0-9-]+)+")
5353
or
54-
// the trailing slash makes the prefix-check safe
54+
// the trailing port or slash makes the prefix-check safe
5555
(
5656
name = "startsWith"
5757
or
@@ -61,6 +61,6 @@ where
6161
n.getIntValue() = 0
6262
)
6363
) and
64-
target.regexpMatch(".*/")
64+
target.regexpMatch(".*(:[0-9]+|/)")
6565
)
6666
select call, "'$@' may be at an arbitrary position in the sanitized URL.", substring, target

0 commit comments

Comments
 (0)