File tree Expand file tree Collapse file tree
lib/codeql/swift/regex/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -386,6 +386,14 @@ abstract class RegExp extends Expr {
386386 // wide hex char \Uhhhhhhhh
387387 this .getChar ( start + 1 ) = "U" and end = start + 10
388388 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
389397 // escape not handled above; update when adding a new case
390398 not this .getChar ( start + 1 ) in [ "x" , "u" , "U" ] and
391399 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 {
516516
517517 // BAD TODO: we should get this one
518518 // 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=
520520
521521 // GOOD
522- _ = try Regex ( #"X(\x{061}|b)+Y"# ) . firstMatch ( in: tainted) // $ hasParseFailure
522+ _ = try Regex ( #"X(\x{061}|b)+Y"# ) . firstMatch ( in: tainted)
523523
524524 // BAD
525525 // attack string: "X" + "7" x lots
You can’t perform that action at this time.
0 commit comments