Skip to content

Commit 85adc3b

Browse files
committed
Java: Add String.join as default taint step.
1 parent ee3af0a commit 85adc3b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,15 +381,22 @@ private predicate argToMethodStep(Expr tracked, MethodAccess sink) {
381381
tracked = sink.(MethodAccess).getArgument(i)
382382
)
383383
or
384-
exists(Method m, MethodAccess ma |
385-
ma.getMethod() = m and
386-
m.getDeclaringType() instanceof TypeString and
387-
m.hasName("format") and
384+
exists(MethodAccess ma |
385+
taintPreservingArgumentToMethod(ma.getMethod()) and
388386
tracked = ma.getAnArgument() and
389387
sink = ma
390388
)
391389
}
392390

391+
/**
392+
* Holds if `method` is a library method that return tainted data if any
393+
* of its arguments are tainted.
394+
*/
395+
private predicate taintPreservingArgumentToMethod(Method method) {
396+
method.getDeclaringType() instanceof TypeString and
397+
(method.hasName("format") or method.hasName("join"))
398+
}
399+
393400
/**
394401
* Holds if `method` is a library method that return tainted data if its
395402
* `arg`th argument is tainted.

0 commit comments

Comments
 (0)