Skip to content

Commit 635071f

Browse files
committed
Swift: Add tentative support for speculative taint flow.
1 parent 7497d95 commit 635071f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,29 @@ private module Cached {
9999
}
100100

101101
import Cached
102+
import SpeculativeTaintFlow
103+
104+
private module SpeculativeTaintFlow {
105+
private import codeql.swift.dataflow.internal.DataFlowDispatch as DataFlowDispatch
106+
private import codeql.swift.dataflow.internal.DataFlowPublic as DataFlowPublic
107+
private import codeql.swift.dataflow.internal.DataFlowPrivate as DataFlowPrivate
108+
109+
predicate speculativeTaintStep(DataFlow::Node src, DataFlow::Node sink) {
110+
exists(DataFlowDispatch::DataFlowCall call, DataFlowDispatch::ArgumentPosition argpos |
111+
// TODO: exclude neutrals and anything that has QL modeling.
112+
not exists(DataFlowDispatch::viableCallable(call)) and
113+
src.(DataFlowPrivate::ArgumentNode).argumentOf(call, argpos)
114+
|
115+
not argpos instanceof DataFlowDispatch::ThisArgumentPosition and
116+
sink.(DataFlowPublic::PostUpdateNode)
117+
.getPreUpdateNode()
118+
.(DataFlowPrivate::ArgumentNode)
119+
.argumentOf(call,
120+
any(DataFlowDispatch::ArgumentPosition qualpos |
121+
qualpos instanceof DataFlowDispatch::ThisArgumentPosition
122+
))
123+
or
124+
sink.(DataFlowPrivate::OutNode).getCall(_) = call
125+
)
126+
}
127+
}

0 commit comments

Comments
 (0)