Skip to content

Commit e3534d1

Browse files
committed
Java: cover wrapped constructor taint flow
1 parent af0dff8 commit e3534d1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,15 @@ predicate summaryStep(Node node1, Node node2, string kind) {
697697
interpretOutput(output, 0, ref, TNode(node2))
698698
)
699699
}
700+
701+
/**
702+
* Holds if `node1` to `node2` is specified as a flow step with the given kind, input and output
703+
* in a CSV flow model.
704+
*/
705+
predicate summaryStep(Node node1, Node node2, string kind, string input, string output) {
706+
exists(Top ref |
707+
summaryElementRef(ref, input, output, kind) and
708+
interpretInput(input, 0, ref, TNode(node1)) and
709+
interpretOutput(output, 0, ref, TNode(node2))
710+
)
711+
}

java/ql/src/semmle/code/java/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ private predicate inputStreamWrapper(Constructor c, int argi) {
166166
/** An object construction that preserves the data flow status of any of its arguments. */
167167
private predicate constructorStep(Expr tracked, ConstructorCall sink) {
168168
exists(int argi | sink.getArgument(argi) = tracked |
169+
summaryStep(any(DataFlow::Node n | n.asExpr() = tracked),
170+
any(DataFlow::Node n | n.asExpr() = sink), "taint", "Argument(" + argi + ")", "ReturnValue")
171+
or
169172
// wrappers constructed by extension
170173
exists(Constructor c, Parameter p, SuperConstructorInvocationStmt sup |
171174
c = sink.getConstructor() and

0 commit comments

Comments
 (0)