Skip to content

Commit 22ec12b

Browse files
committed
use split("?")[0] sanitizer is both DomBasedXSS and ClientSideUrlRedirect
1 parent 89f4537 commit 22ec12b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/ClientSideUrlRedirectCustomizations.qll

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import semmle.javascript.security.dataflow.RemoteFlowSources
99
import UrlConcatenation
1010

1111
module ClientSideUrlRedirect {
12+
private import Xss::DomBasedXss as DomBasedXss
13+
1214
/**
1315
* A data flow source for unvalidated URL redirect vulnerabilities.
1416
*/
@@ -69,15 +71,7 @@ module ClientSideUrlRedirect {
6971
/**
7072
* A sanitizer that reads the first part a location split by "?", e.g. `location.href.split('?')[0]`.
7173
*/
72-
class QueryPrefixSanitizer extends Sanitizer {
73-
StringSplitCall splitCall;
74-
75-
QueryPrefixSanitizer() {
76-
this = splitCall.getAnElementRead(0) and
77-
splitCall.getSplitAt() = "?" and
78-
splitCall.getUnsplit() = [DOM::locationRef(), DOM::locationRef().getAPropertyRead("href")]
79-
}
80-
}
74+
class QueryPrefixSanitizer extends Sanitizer, DomBasedXss::QueryPrefixSanitizer { }
8175

8276
/**
8377
* A sink which is used to set the window location.

javascript/ql/src/semmle/javascript/security/dataflow/Xss.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,19 @@ module DomBasedXss {
278278
}
279279
}
280280

281+
/**
282+
* A sanitizer that reads the first part a location split by "?", e.g. `location.href.split('?')[0]`.
283+
*/
284+
class QueryPrefixSanitizer extends Sanitizer {
285+
StringSplitCall splitCall;
286+
287+
QueryPrefixSanitizer() {
288+
this = splitCall.getAnElementRead(0) and
289+
splitCall.getSplitAt() = "?" and
290+
splitCall.getUnsplit() = [DOM::locationRef(), DOM::locationRef().getAPropertyRead("href")]
291+
}
292+
}
293+
281294
/**
282295
* A regexp replacement involving an HTML meta-character, viewed as a sanitizer for
283296
* XSS vulnerabilities.

0 commit comments

Comments
 (0)