@@ -49,7 +49,6 @@ module Werkzeug {
49
49
50
50
private class MultiDictAdditionalTaintStep extends TaintTracking:: AdditionalTaintStep {
51
51
override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
52
- // See https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Headers.getlist
53
52
nodeFrom = instance ( ) and
54
53
nodeTo .( DataFlow:: MethodCallNode ) .calls ( nodeFrom , "getlist" )
55
54
}
@@ -122,6 +121,54 @@ module Werkzeug {
122
121
}
123
122
}
124
123
124
+ /**
125
+ * Provides models for the `werkzeug.datastructures.Headers` class
126
+ *
127
+ * See https://werkzeug.palletsprojects.com/en/1.0.x/datastructures/#werkzeug.datastructures.Headers.
128
+ */
129
+ module Headers {
130
+ /**
131
+ * A source of instances of `werkzeug.datastructures.Headers`, extend this class to model new instances.
132
+ *
133
+ * This can include instantiations of the class, return values from function
134
+ * calls, or a special parameter that will be set when functions are called by an external
135
+ * library.
136
+ *
137
+ * Use the predicate `Headers::instance()` to get references to instances of `werkzeug.datastructures.Headers`.
138
+ */
139
+ abstract class InstanceSource extends DataFlow:: LocalSourceNode { }
140
+
141
+ /** Gets a reference to an instance of `werkzeug.datastructures.Headers`. */
142
+ private DataFlow:: TypeTrackingNode instance ( DataFlow:: TypeTracker t ) {
143
+ t .start ( ) and
144
+ result instanceof InstanceSource
145
+ or
146
+ exists ( DataFlow:: TypeTracker t2 | result = instance ( t2 ) .track ( t2 , t ) )
147
+ }
148
+
149
+ /** Gets a reference to an instance of `werkzeug.datastructures.Headers`. */
150
+ DataFlow:: Node instance ( ) { instance ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result ) }
151
+
152
+ /**
153
+ * Taint propagation for `werkzeug.datastructures.Headers`.
154
+ */
155
+ class HeadersAdditionalTaintStep extends TaintTracking:: AdditionalTaintStep {
156
+ override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
157
+ // Methods
158
+ //
159
+ // TODO: When we have tools that make it easy, model these properly to handle
160
+ // `meth = obj.meth; meth()`. Until then, we'll use this more syntactic approach
161
+ // (since it allows us to at least capture the most common cases).
162
+ nodeFrom = instance ( ) and
163
+ exists ( DataFlow:: AttrRead attr | attr .getObject ( ) = nodeFrom |
164
+ // methods (non-async)
165
+ attr .getAttributeName ( ) in [ "getlist" , "get_all" , "popitem" , "to_wsgi_list" ] and
166
+ nodeTo .( DataFlow:: CallCfgNode ) .getFunction ( ) = attr
167
+ )
168
+ }
169
+ }
170
+ }
171
+
125
172
import WerkzeugOld
126
173
}
127
174
0 commit comments