This repository was archived by the owner on Jan 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
ql/src/semmle/go/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,15 +64,18 @@ module ReflectedXss {
6464 or
6565 exists ( DataFlow:: CallNode call | call .getTarget ( ) .hasQualifiedName ( "fmt" , "Fprintf" ) |
6666 body = call .getAnArgument ( ) and
67- // checks that the format value does not start with:
67+ // checks that the format value does not start with (ignoring whitespace as defined by
68+ // https://mimesniff.spec.whatwg.org/#whitespace-byte):
6869 // - '<', which could lead to an HTML content type being detected, or
6970 // - '%', which could be a format string.
70- call .getArgument ( 1 ) .getStringValue ( ) .regexpMatch ( "(?s)^ [^<%].*" )
71+ call .getArgument ( 1 ) .getStringValue ( ) .regexpMatch ( "(?s)[\\t\\n\\x0c\\r ]*+ [^<%].*" )
7172 )
7273 or
7374 exists ( DataFlow:: Node pred | body = pred .getASuccessor * ( ) |
74- // data starting with a character other than `<` cannot cause an HTML content type to be detected.
75- pred .getStringValue ( ) .regexpMatch ( "(?s)^[^<].*" )
75+ // data starting with a character other than `<` (ignoring whitespace as defined by
76+ // https://mimesniff.spec.whatwg.org/#whitespace-byte) cannot cause an HTML content type to
77+ // be detected.
78+ pred .getStringValue ( ) .regexpMatch ( "(?s)[\\t\\n\\x0c\\r ]*+[^<].*" )
7679 or
7780 // json data cannot begin with `<`
7881 exists ( EncodingJson:: MarshalFunction mf | pred = mf .getOutput ( ) .getNode ( mf .getACall ( ) ) )
You can’t perform that action at this time.
0 commit comments