Skip to content

Commit 2a30b26

Browse files
committed
[XSS] Fixed regression in invalid characters optimization causing false negatives (thanks Tsubasa for reporting).
1 parent b9121e6 commit 2a30b26

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/test/XSS_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ if (UA.isMozilla) {
3131
() => y("https://vulnerabledoma.in/char_test?body=%3Ca%20href=javascript%26colo%u0000n%3balert%281%u0029%3ECLICK"),
3232
() => y("https://vulnerabledoma.in/xss_link?url=javascript%26colo%00n%3Balert%u00281%29"),
3333
() => y("https://vulnerabledoma.in/xss_link?url=javascript:\\u{%0A6e}ame"),
34+
() => y("https://sandbox.hack.vet/issue/noscript/bypass/multibyte/?q=alert(document.cookie)//<"),
35+
() => y("https://sandbox.hack.vet/issue/noscript/bypass/multibyte/?q=/**🚫*/alert(document.cookie)"),
3436
].map(t => Test.run(t))
3537
);
3638

src/xss/InjectionChecker.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ XSS.InjectionChecker = (async () => {
530530
let value;
531531
try {
532532
// see https://mathiasbynens.be/notes/javascript-identifiers-es6#acceptable-unicode-symbols
533-
value = new RegExp(preamble + "[^$_\\p{ID_Start}\\p{ID_Continue}\\u200c\\u200d\\u2028\\u2029]", "u");
533+
value = new RegExp(preamble + "[^\\x00-\\x7E\\p{ID_Start}\\p{ID_Continue}\\u200c\\u200d\\u2028\\u2029]", "u");
534534
} catch (e) {
535535
// Unicode entities are not supported in Gecko <= 77
536536
value = new RegExp(preamble + `[${this._createInvalidRanges()}]`, "u");
@@ -665,13 +665,14 @@ XSS.InjectionChecker = (async () => {
665665

666666
lastExpr = expr;
667667

668-
if (invalidCharsRx && invalidCharsRx.test(expr)) {
669-
this.log("Quick skipping invalid chars");
670-
break;
668+
if (invalidCharsRx) {
669+
let m = invalidCharsRx.test(expr);
670+
if (m) {
671+
this.log(`Quick skipping invalid chars on ${expr}, (${JSON.stringify(m)}).`);
672+
break;
673+
}
671674
}
672675

673-
674-
675676
if (quote) {
676677
if (this.checkNonTrivialJSSyntax(expr)) {
677678
this.log("Non-trivial JS inside quoted string detected", iterations);

0 commit comments

Comments
 (0)