Skip to content

Commit eaf0530

Browse files
authored
Merge pull request github#6709 from aschackmull/java/local-taint-collections
Java: Add container flow to the local taint flow relation.
2 parents 82d463e + 28e5dce commit eaf0530

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

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

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,28 @@ private module Cached {
4242
*/
4343
cached
4444
predicate localTaintStep(DataFlow::Node src, DataFlow::Node sink) {
45-
DataFlow::localFlowStep(src, sink) or
46-
localAdditionalTaintStep(src, sink) or
45+
DataFlow::localFlowStep(src, sink)
46+
or
47+
localAdditionalTaintStep(src, sink)
48+
or
4749
// Simple flow through library code is included in the exposed local
4850
// step relation, even though flow is technically inter-procedural
4951
FlowSummaryImpl::Private::Steps::summaryThroughStep(src, sink, false)
52+
or
53+
// Treat container flow as taint for the local taint flow relation
54+
exists(DataFlow::Content c | containerContent(c) |
55+
readStep(src, c, sink) or
56+
storeStep(src, c, sink) or
57+
FlowSummaryImpl::Private::Steps::summaryGetterStep(src, c, sink) or
58+
FlowSummaryImpl::Private::Steps::summarySetterStep(src, c, sink)
59+
)
60+
}
61+
62+
private predicate containerContent(DataFlow::Content c) {
63+
c instanceof DataFlow::ArrayContent or
64+
c instanceof DataFlow::CollectionContent or
65+
c instanceof DataFlow::MapKeyContent or
66+
c instanceof DataFlow::MapValueContent
5067
}
5168

5269
/**
@@ -65,12 +82,8 @@ private module Cached {
6582
readStep(src, f, sink) and
6683
not sink.getTypeBound() instanceof PrimitiveType and
6784
not sink.getTypeBound() instanceof BoxedType and
68-
not sink.getTypeBound() instanceof NumberType
69-
|
70-
f instanceof DataFlow::ArrayContent or
71-
f instanceof DataFlow::CollectionContent or
72-
f instanceof DataFlow::MapKeyContent or
73-
f instanceof DataFlow::MapValueContent
85+
not sink.getTypeBound() instanceof NumberType and
86+
containerContent(f)
7487
)
7588
or
7689
FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink, false)

0 commit comments

Comments
 (0)