File tree 1 file changed +14
-0
lines changed
java/ql/lib/semmle/code/java/security
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) {
363
363
)
364
364
}
365
365
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
+
366
379
/** Holds if `g` is a guard that checks for `..` components. */
367
380
private predicate pathTraversalGuard ( Guard g , Expr e , boolean branch ) {
368
381
branch = g .( PathTraversalGuard ) .getBranch ( ) and
@@ -382,6 +395,7 @@ private class FileConstructorSanitizer extends PathInjectionSanitizer {
382
395
// `java.io.File` documentation states that such cases are
383
396
// treated as if invoking the single-argument `File` constructor.
384
397
not maybeNull ( constrCall .getArgument ( 0 ) ) and
398
+ not isTainted ( constrCall .getArgument ( 0 ) ) and
385
399
arg = constrCall .getArgument ( 1 ) and
386
400
(
387
401
arg = DataFlow:: BarrierGuard< pathTraversalGuard / 3 > :: getABarrierNode ( ) .asExpr ( ) or
You can’t perform that action at this time.
0 commit comments