Skip to content

Commit 93a28cb

Browse files
committed
C#: Add default (reverse update) taint step from implicit operator calls to their arguments.
1 parent 8807217 commit 93a28cb

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/TaintTrackingPrivate.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ private class LocalTaintExprStepConfiguration extends ControlFlowReachabilityCon
109109
}
110110
}
111111

112+
private ControlFlow::Nodes::ExprNode getALastEvalNode(ControlFlow::Nodes::ExprNode cfn) {
113+
exists(Expr e | any(LocalTaintExprStepConfiguration x).hasExprPath(_, result, e, cfn) |
114+
e.(OperatorCall).getTarget() instanceof ImplicitConversionOperator // Should only be implicit operator calls.
115+
)
116+
}
117+
118+
private ControlFlow::Nodes::ExprNode getPostUpdateReverseStep(ControlFlow::Nodes::ExprNode e) {
119+
result = getALastEvalNode(e)
120+
}
121+
112122
private predicate localTaintStepCommon(DataFlow::Node nodeFrom, DataFlow::Node nodeTo) {
113123
hasNodePath(any(LocalTaintExprStepConfiguration x), nodeFrom, nodeTo)
114124
}
@@ -177,6 +187,16 @@ private module Cached {
177187
readStep(nodeFrom, any(DataFlow::ContentSet c | c.isElement()), nodeTo)
178188
or
179189
nodeTo = nodeFrom.(DataFlow::NonLocalJumpNode).getAJumpSuccessor(false)
190+
or
191+
// Allow reverse update flow for implicit conversion operator calls.
192+
// This is needed to support flow out of method call arguments, where an implicit conversion is applied
193+
// to a call argument.
194+
nodeTo.(PostUpdateNode).getPreUpdateNode().(DataFlow::ExprNode).getControlFlowNode() =
195+
getPostUpdateReverseStep(nodeFrom
196+
.(PostUpdateNode)
197+
.getPreUpdateNode()
198+
.(DataFlow::ExprNode)
199+
.getControlFlowNode())
180200
) and
181201
model = ""
182202
or

0 commit comments

Comments
 (0)