Skip to content

Commit ffcfe40

Browse files
committed
Convert reflected xss sanitizer to MaD
1 parent 0bc652c commit ffcfe40

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

go/ql/lib/ext/net.http.model.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ extensions:
77
- ["net/http", "", False, "ServeFile", "", "", "Argument[2]", "path-injection", "manual"]
88
# url-redirection
99
- ["net/http", "", False, "Redirect", "", "", "Argument[2]", "url-redirection[0]", "manual"]
10+
- addsTo:
11+
pack: codeql/go-all
12+
extensible: barrierModel
13+
data:
14+
# Returns the request cookie, which is not user controlled in reflected XSS context.
15+
- ["net/http", "Request", False, "Cookie", "", "", "ReturnValue[0]", "reflected-xss", "manual"]
1016
- addsTo:
1117
pack: codeql/go-all
1218
extensible: summaryModel

go/ql/lib/semmle/go/security/ReflectedXssCustomizations.qll

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import go
66
import Xss
7+
private import semmle.go.dataflow.ExternalFlow
78

89
/**
910
* Provides extension points for customizing the taint-tracking configuration for reasoning about
@@ -22,16 +23,8 @@ module ReflectedXss {
2223
/** A shared XSS sanitizer as a sanitizer for reflected XSS. */
2324
private class SharedXssSanitizer extends Sanitizer instanceof SharedXss::Sanitizer { }
2425

25-
/**
26-
* A request.Cookie method returns the request cookie, which is not user controlled in reflected XSS context.
27-
*/
28-
class CookieSanitizer extends Sanitizer {
29-
CookieSanitizer() {
30-
exists(Method m, DataFlow::CallNode call | call = m.getACall() |
31-
m.hasQualifiedName("net/http", "Request", "Cookie") and
32-
this = call.getResult(0)
33-
)
34-
}
26+
private class DefaultSanitizer extends Sanitizer {
27+
DefaultSanitizer() { barrierNode(this, "reflected-xss") }
3528
}
3629

3730
/**

0 commit comments

Comments
 (0)