File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
lib/codeql/swift/regex/internal Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -386,6 +386,14 @@ abstract class RegExp extends Expr {
386
386
// wide hex char \Uhhhhhhhh
387
387
this .getChar ( start + 1 ) = "U" and end = start + 10
388
388
or
389
+ // variable width hex char \x{hh...} or \u{hh...} (1-6 digits)
390
+ this .getChar ( start + 1 ) = [ "x" , "u" ] and
391
+ this .getChar ( start + 2 ) = "{" and
392
+ this .getChar ( end - 1 ) = "}" and
393
+ end > start and
394
+ end <= start + 10 and
395
+ not exists ( int i | start + 2 < i and i < end - 1 | this .getChar ( i ) = "}" )
396
+ or
389
397
// escape not handled above; update when adding a new case
390
398
not this .getChar ( start + 1 ) in [ "x" , "u" , "U" ] and
391
399
not exists ( this .getChar ( start + 1 ) .toInt ( ) ) and
Original file line number Diff line number Diff line change @@ -516,10 +516,10 @@ func myRegexpVariantsTests(myUrl: URL) throws {
516
516
517
517
// BAD TODO: we should get this one
518
518
// attack string: "X" + "a" x lots
519
- _ = try Regex ( #"X(\x{061}|a)*Y"# ) . firstMatch ( in: tainted) // $ hasParseFailure= MISSING: redos-vulnerable=
519
+ _ = try Regex ( #"X(\x{061}|a)*Y"# ) . firstMatch ( in: tainted) // $ MISSING: redos-vulnerable=
520
520
521
521
// GOOD
522
- _ = try Regex ( #"X(\x{061}|b)+Y"# ) . firstMatch ( in: tainted) // $ hasParseFailure
522
+ _ = try Regex ( #"X(\x{061}|b)+Y"# ) . firstMatch ( in: tainted)
523
523
524
524
// BAD
525
525
// attack string: "X" + "7" x lots
You can’t perform that action at this time.
0 commit comments