@@ -20,14 +20,18 @@ import codeql.rust.security.InsecureCookieExtensions
2020
2121/**
2222 * A data flow configuration for tracking values representing cookies without the
23- * 'secure' attribute set.
23+ * 'secure' attribute set. This is the primary data flow configurationn for this
24+ * query.
2425 */
2526module InsecureCookieConfig implements DataFlow:: ConfigSig {
2627 import InsecureCookie
2728
2829 predicate isSource ( DataFlow:: Node node ) {
2930 // creation of a cookie or cookie configuration with default, insecure settings
3031 node instanceof Source
32+ or
33+ // setting the 'secure' attribute to false (or an unknown value)
34+ cookieSetNode ( node , "secure" , false )
3135 }
3236
3337 predicate isSink ( DataFlow:: Node node ) {
@@ -36,6 +40,37 @@ module InsecureCookieConfig implements DataFlow::ConfigSig {
3640 }
3741
3842 predicate isBarrier ( DataFlow:: Node node ) {
43+ // setting the 'secure' attribute to true
44+ cookieSetNode ( node , "secure" , true )
45+ or
46+ node instanceof Barrier
47+ }
48+
49+ predicate observeDiffInformedIncrementalMode ( ) { any ( ) }
50+ }
51+
52+ /**
53+ * A data flow configuration for tracking values representing cookies with the
54+ * 'partitioned' attribute set. This is a secondary data flow configuration used
55+ * to filter out unwanted results.
56+ */
57+ module PartitionedCookieConfig implements DataFlow:: ConfigSig {
58+ import InsecureCookie
59+
60+ predicate isSource ( DataFlow:: Node node ) {
61+ // setting the 'partitioned' attribute to true
62+ cookieSetNode ( node , "partitioned" , true )
63+ }
64+
65+ predicate isSink ( DataFlow:: Node node ) {
66+ // use of a cookie or cookie configuration
67+ node instanceof Sink
68+ }
69+
70+ predicate isBarrier ( DataFlow:: Node node ) {
71+ // setting the 'partitioned' attribute to false (or an unknown value)
72+ cookieSetNode ( node , "partitioned" , false )
73+ or
3974 node instanceof Barrier
4075 }
4176
@@ -44,9 +79,12 @@ module InsecureCookieConfig implements DataFlow::ConfigSig {
4479
4580module InsecureCookieFlow = TaintTracking:: Global< InsecureCookieConfig > ;
4681
82+ module PartitionedCookieFlow = TaintTracking:: Global< PartitionedCookieConfig > ;
83+
4784import InsecureCookieFlow:: PathGraph
4885
4986from InsecureCookieFlow:: PathNode sourceNode , InsecureCookieFlow:: PathNode sinkNode
5087where
51- InsecureCookieFlow:: flowPath ( sourceNode , sinkNode )
88+ InsecureCookieFlow:: flowPath ( sourceNode , sinkNode ) and
89+ not PartitionedCookieFlow:: flow ( _, sinkNode .getNode ( ) )
5290select sinkNode .getNode ( ) , sourceNode , sinkNode , "Cookie attribute 'Secure' is not set to true."
0 commit comments