1- /** Provides classes and predicates for identifying HTTP cookies with insecure attributes . */
1+ /** Provides classes and predicates for identifying HTTP cookies without the `HttpOnly` attribute . */
22
33import go
44import semmle.go.concepts.HTTP
@@ -31,21 +31,6 @@ private module SensitiveCookieNameConfig implements DataFlow::ConfigSig {
3131/** Tracks flow from sensitive names to HTTP cookie writes. */
3232module SensitiveCookieNameFlow = TaintTracking:: Global< SensitiveCookieNameConfig > ;
3333
34- private module BooleanCookieSecureConfig implements DataFlow:: ConfigSig {
35- predicate isSource ( DataFlow:: Node source ) {
36- source .getType ( ) .getUnderlyingType ( ) instanceof BoolType
37- }
38-
39- predicate isSink ( DataFlow:: Node sink ) { exists ( Http:: CookieWrite cw | sink = cw .getSecure ( ) ) }
40-
41- predicate isAdditionalFlowStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
42- exists ( Http:: CookieOptionWrite co | co .getSecure ( ) = pred and co .getCookieOutput ( ) = succ )
43- }
44- }
45-
46- /** Tracks flow from boolean expressions to the `Secure` attribute of HTTP cookie writes. */
47- module BooleanCookieSecureFlow = TaintTracking:: Global< BooleanCookieSecureConfig > ;
48-
4934private module BooleanCookieHttpOnlyConfig implements DataFlow:: ConfigSig {
5035 predicate isSource ( DataFlow:: Node source ) {
5136 source .getType ( ) .getUnderlyingType ( ) instanceof BoolType
@@ -61,23 +46,6 @@ private module BooleanCookieHttpOnlyConfig implements DataFlow::ConfigSig {
6146/** Tracks flow from boolean expressions to the `HttpOnly` attribute of HTTP cookie writes. */
6247module BooleanCookieHttpOnlyFlow = TaintTracking:: Global< BooleanCookieHttpOnlyConfig > ;
6348
64- /** Holds if `cw` has the `Secure` attribute left at its default value of `false`. */
65- predicate isInsecureDefault ( Http:: CookieWrite cw ) {
66- not BooleanCookieSecureFlow:: flow ( _, cw .getSecure ( ) )
67- }
68-
69- /** Holds if `cw` has the `Secure` attribute explicitly set to `false`, from the expression `boolFalse`. */
70- predicate isInsecureDirect ( Http:: CookieWrite cw , Expr boolFalse ) {
71- BooleanCookieSecureFlow:: flow ( DataFlow:: exprNode ( boolFalse ) , cw .getSecure ( ) ) and
72- boolFalse .getBoolValue ( ) = false
73- }
74-
75- /** Holds if `cw` has the `Secure` attribute set to `false`, either explicitly or by default. */
76- predicate isInsecureCookie ( Http:: CookieWrite cw ) {
77- isInsecureDefault ( cw ) or
78- isInsecureDirect ( cw , _)
79- }
80-
8149/** Holds if `cw` has the `HttpOnly` attribute left at its default value of `false`. */
8250predicate isNonHttpOnlyDefault ( Http:: CookieWrite cw ) {
8351 not BooleanCookieHttpOnlyFlow:: flow ( _, cw .getHttpOnly ( ) )
0 commit comments