Skip to content

Commit 7497d95

Browse files
committed
Python: Add tentative support for speculative taint flow.
1 parent 8eb0cb4 commit 7497d95

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/TaintTrackingPrivate.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,27 @@ predicate asyncWithStep(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
219219
contextManager.strictlyDominates(var)
220220
)
221221
}
222+
223+
import SpeculativeTaintFlow
224+
225+
private module SpeculativeTaintFlow {
226+
private import semmle.python.dataflow.new.internal.DataFlowDispatch as DataFlowDispatch
227+
private import semmle.python.dataflow.new.internal.DataFlowPublic as DataFlowPublic
228+
229+
predicate speculativeTaintStep(DataFlow::Node src, DataFlow::Node sink) {
230+
exists(DataFlowDispatch::DataFlowCall call, DataFlowDispatch::ArgumentPosition argpos |
231+
// TODO: exclude neutrals and anything that has QL modeling.
232+
not exists(DataFlowDispatch::viableCallable(call)) and
233+
call instanceof DataFlowDispatch::PotentialLibraryCall and
234+
src.(DataFlowPublic::ArgumentNode).argumentOf(call, argpos)
235+
|
236+
not argpos.isSelf() and
237+
sink.(DataFlowPublic::PostUpdateNode)
238+
.getPreUpdateNode()
239+
.(DataFlowPublic::ArgumentNode)
240+
.argumentOf(call, any(DataFlowDispatch::ArgumentPosition qualpos | qualpos.isSelf()))
241+
or
242+
sink.(DataFlowDispatch::OutNode).getCall(_) = call
243+
)
244+
}
245+
}

0 commit comments

Comments
 (0)