Skip to content

Commit d3b1729

Browse files
authored
Merge pull request github#2793 from aschackmull/java/format-taint-step
Java: Add String.format as default taint step.
2 parents c685b34 + cabe627 commit d3b1729

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,25 @@ private predicate argToMethodStep(Expr tracked, MethodAccess sink) {
380380
taintPreservingArgumentToMethod(m, i) and
381381
tracked = sink.(MethodAccess).getArgument(i)
382382
)
383+
or
384+
exists(MethodAccess ma |
385+
taintPreservingArgumentToMethod(ma.getMethod()) and
386+
tracked = ma.getAnArgument() and
387+
sink = ma
388+
)
389+
}
390+
391+
/**
392+
* Holds if `method` is a library method that returns 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"))
383398
}
384399

385400
/**
386-
* Holds if `method` is a library method that return tainted data if its
401+
* Holds if `method` is a library method that returns tainted data if its
387402
* `arg`th argument is tainted.
388403
*/
389404
private predicate taintPreservingArgumentToMethod(Method method, int arg) {

0 commit comments

Comments
 (0)