File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
java/ql/lib/semmle/code/java/security Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,19 @@ private predicate maybeNull(Expr expr) {
363363 )
364364}
365365
366+ /** A taint-tracking configuration for reasoning about tainted nodes. */
367+ private module TaintedConfig implements DataFlow:: ConfigSig {
368+ predicate isSource ( DataFlow:: Node source ) { source instanceof ActiveThreatModelSource }
369+
370+ predicate isSink ( DataFlow:: Node sink ) { any ( ) }
371+ }
372+
373+ /** Tracks flow from any `ActiveThreatModelSource` to any node. */
374+ private module TaintedFlow = TaintTracking:: Global< TaintedConfig > ;
375+
376+ /** Holds if `expr is tainted by an `ActiveThreatModelSource`. */
377+ private predicate isTainted ( Expr expr ) { TaintedFlow:: flowToExpr ( expr ) }
378+
366379/** Holds if `g` is a guard that checks for `..` components. */
367380private predicate pathTraversalGuard ( Guard g , Expr e , boolean branch ) {
368381 branch = g .( PathTraversalGuard ) .getBranch ( ) and
@@ -382,6 +395,7 @@ private class FileConstructorSanitizer extends PathInjectionSanitizer {
382395 // `java.io.File` documentation states that such cases are
383396 // treated as if invoking the single-argument `File` constructor.
384397 not maybeNull ( constrCall .getArgument ( 0 ) ) and
398+ not isTainted ( constrCall .getArgument ( 0 ) ) and
385399 arg = constrCall .getArgument ( 1 ) and
386400 (
387401 arg = DataFlow:: BarrierGuard< pathTraversalGuard / 3 > :: getABarrierNode ( ) .asExpr ( ) or
You can’t perform that action at this time.
0 commit comments