Skip to content

Commit 2c637ab

Browse files
committed
unified: Mostly restore path-injection results
Switched to TaintTracking and adds some very ad-hoc steps to recover most of the results. Some more tests pass and others fail; these are now consistent with what we actually model.
1 parent ee7fc86 commit 2c637ab

4 files changed

Lines changed: 125 additions & 26 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/dataflow/DataFlowPluginSwift.qll‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,21 @@ private class SwiftDataFlowPlugin extends DataFlowPlugin {
2525
step.value() and
2626
node2.isResultValue(call)
2727
)
28+
or
29+
// Taint flow through unary "!" (TODO: model as a read of Optional.some, possibly with implicit taint read)
30+
exists(UnaryExpr expr |
31+
expr.getOperator().(PostfixOperator).getValue() = "!" and
32+
node1.isResultValue(expr.getOperand()) and
33+
step.taint() and
34+
node2.isResultValue(expr)
35+
)
36+
or
37+
// Taint flow through URL(string: x). TODO: Model with MaD and flow summaries
38+
exists(CallExpr call |
39+
call.getCallee().(Identifier).getValue() = ["URL", "NSURL"] and
40+
node1.isResultValue(call.getNamedArgument("string")) and
41+
step.taint() and
42+
node2.isResultValue(call)
43+
)
2844
}
2945
}

‎unified/ql/src/queries/security/CWE-022/PathInjection.ql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module PathInjectionConfig implements DataFlow::ConfigSig {
5454
}
5555
}
5656

57-
module PathInjectionFlow = DataFlow::Global<PathInjectionConfig>;
57+
module PathInjectionFlow = TaintTracking::Global<PathInjectionConfig>;
5858

5959
import PathInjectionFlow::PathGraph
6060

0 commit comments

Comments
 (0)