@@ -24,10 +24,12 @@ module NormalHashFunction {
2424 import WeakSensitiveDataHashingCustomizations:: NormalHashFunction
2525
2626 /**
27+ * DEPRECATED: Use `Flow` module instead.
28+ *
2729 * A taint-tracking configuration for detecting use of a broken or weak
2830 * cryptographic hashing algorithm on sensitive data.
2931 */
30- class Configuration extends TaintTracking:: Configuration {
32+ deprecated class Configuration extends TaintTracking:: Configuration {
3133 Configuration ( ) { this = "NormalHashFunction" }
3234
3335 override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -44,6 +46,21 @@ module NormalHashFunction {
4446 sensitiveDataExtraStepForCalls ( node1 , node2 )
4547 }
4648 }
49+
50+ private module Config implements DataFlow:: ConfigSig {
51+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
52+
53+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
54+
55+ predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
56+
57+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
58+ sensitiveDataExtraStepForCalls ( node1 , node2 )
59+ }
60+ }
61+
62+ /** Global taint-tracking for detecting "use of a broken or weak cryptographic hashing algorithm on sensitive data" vulnerabilities. */
63+ module Flow = TaintTracking:: Global< Config > ;
4764}
4865
4966/**
@@ -57,13 +74,15 @@ module ComputationallyExpensiveHashFunction {
5774 import WeakSensitiveDataHashingCustomizations:: ComputationallyExpensiveHashFunction
5875
5976 /**
77+ * DEPRECATED: Use `Flow` module instead.
78+ *
6079 * A taint-tracking configuration for detecting use of a broken or weak
6180 * cryptographic hashing algorithm on passwords.
6281 *
6382 * Passwords has stricter requirements on the hashing algorithm used (must be
6483 * computationally expensive to prevent brute-force attacks).
6584 */
66- class Configuration extends TaintTracking:: Configuration {
85+ deprecated class Configuration extends TaintTracking:: Configuration {
6786 Configuration ( ) { this = "ComputationallyExpensiveHashFunction" }
6887
6988 override predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
@@ -80,4 +99,49 @@ module ComputationallyExpensiveHashFunction {
8099 sensitiveDataExtraStepForCalls ( node1 , node2 )
81100 }
82101 }
102+
103+ /**
104+ * Passwords has stricter requirements on the hashing algorithm used (must be
105+ * computationally expensive to prevent brute-force attacks).
106+ */
107+ private module Config implements DataFlow:: ConfigSig {
108+ predicate isSource ( DataFlow:: Node source ) { source instanceof Source }
109+
110+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
111+
112+ predicate isBarrier ( DataFlow:: Node node ) { node instanceof Sanitizer }
113+
114+ predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
115+ sensitiveDataExtraStepForCalls ( node1 , node2 )
116+ }
117+ }
118+
119+ /** Global taint-tracking for detecting "use of a broken or weak cryptographic hashing algorithm on passwords" vulnerabilities. */
120+ module Flow = TaintTracking:: Global< Config > ;
121+ }
122+
123+ /**
124+ * Global taint-tracking for detecting both variants of "use of a broken or weak
125+ * cryptographic hashing algorithm on sensitive data" vulnerabilities.
126+ *
127+ * See convenience predicates `normalHashFunctionFlowPath` and
128+ * `computationallyExpensiveHashFunctionFlowPath`.
129+ */
130+ module WeakSensitiveDataHashingFlow =
131+ DataFlow:: MergePathGraph< NormalHashFunction:: Flow:: PathNode ,
132+ ComputationallyExpensiveHashFunction:: Flow:: PathNode , NormalHashFunction:: Flow:: PathGraph ,
133+ ComputationallyExpensiveHashFunction:: Flow:: PathGraph > ;
134+
135+ /** Holds if data can flow from `source` to `sink` with `NormalHashFunction::Flow`. */
136+ predicate normalHashFunctionFlowPath (
137+ WeakSensitiveDataHashingFlow:: PathNode source , WeakSensitiveDataHashingFlow:: PathNode sink
138+ ) {
139+ NormalHashFunction:: Flow:: flowPath ( source .asPathNode1 ( ) , sink .asPathNode1 ( ) )
140+ }
141+
142+ /** Holds if data can flow from `source` to `sink` with `ComputationallyExpensiveHashFunction::Flow`. */
143+ predicate computationallyExpensiveHashFunctionFlowPath (
144+ WeakSensitiveDataHashingFlow:: PathNode source , WeakSensitiveDataHashingFlow:: PathNode sink
145+ ) {
146+ ComputationallyExpensiveHashFunction:: Flow:: flowPath ( source .asPathNode2 ( ) , sink .asPathNode2 ( ) )
83147}
0 commit comments