Skip to content

Commit b25e867

Browse files
committed
Java SSRF query: comment on sanitizing regex
1 parent a665d5d commit b25e867

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

java/ql/src/semmle/code/java/security/RequestForgery.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ private class HostnameSanitizingPrefix extends CompileTimeConstantExpr {
222222
int offset;
223223

224224
HostnameSanitizingPrefix() {
225+
// Matches strings that look like when prepended to untrusted input, they will restrict
226+
// the host or entity addressed: for example, anything containing `?` or `#`, or a slash that
227+
// doesn't appear to be a protocol specifier (e.g. `http://` is not sanitizing), or specifically
228+
// the string "/".
225229
exists(
226230
this.getStringValue()
227231
.regexpFind(".*([?#]|[^?#:/\\\\][/\\\\]).*|[/\\\\][^/\\\\].*|^/$", 0, offset)

0 commit comments

Comments
 (0)