Skip to content

Commit 4e8a4a5

Browse files
committed
C/C++: Add tentative support for speculative taint flow.
1 parent fae7175 commit 4e8a4a5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,5 @@ private predicate exprToPartialDefinitionStep(Expr exprIn, Expr exprOut) {
281281
}
282282

283283
private predicate iteratorDereference(Call c) { c.getTarget() instanceof IteratorReferenceFunction }
284+
285+
predicate speculativeTaintStep(DataFlow::Node src, DataFlow::Node sink) { none() }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,26 @@ predicate modeledTaintStep(DataFlow::Node nodeIn, DataFlow::Node nodeOut, string
212212
nodeOut = callOutput(call, modelOut)
213213
)
214214
}
215+
216+
import SpeculativeTaintFlow
217+
218+
private module SpeculativeTaintFlow {
219+
private import semmle.code.cpp.ir.dataflow.internal.DataFlowDispatch as DataFlowDispatch
220+
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate as DataFlowPrivate
221+
222+
predicate speculativeTaintStep(DataFlow::Node src, DataFlow::Node sink) {
223+
exists(DataFlowCall call, ArgumentPosition argpos |
224+
// TODO: exclude neutrals and anything that has QL modeling.
225+
not exists(DataFlowDispatch::viableCallable(call)) and
226+
src.(DataFlowPrivate::ArgumentNode).argumentOf(call, argpos)
227+
|
228+
not argpos.(DirectPosition).getIndex() = -1 and
229+
sink.(PostUpdateNode)
230+
.getPreUpdateNode()
231+
.(DataFlowPrivate::ArgumentNode)
232+
.argumentOf(call, any(DirectPosition qualpos | qualpos.getIndex() = -1))
233+
or
234+
sink.(DataFlowPrivate::OutNode).getCall() = call
235+
)
236+
}
237+
}

0 commit comments

Comments
 (0)