sql injection: sink as class predicate

This commit is contained in:
Michael Hohn
2020-07-20 14:20:32 -07:00
committed by =Michael Hohn
parent 1f385ddfe3
commit 7aa51e67c8

View File

@@ -13,6 +13,7 @@ class SqliFlowConfig extends TaintTracking::Configuration {
SqliFlowConfig() { this = "SqliFlow" } SqliFlowConfig() { this = "SqliFlow" }
override predicate isSource(DataFlow::Node source) { override predicate isSource(DataFlow::Node source) {
// count = read(STDIN_FILENO, buf, BUFSIZE);
exists(FunctionCall read | exists(FunctionCall read |
read.getTarget().getName() = "read" and read.getTarget().getName() = "read" and
read.getArgument(1) = source.asExpr() read.getArgument(1) = source.asExpr()
@@ -23,13 +24,18 @@ class SqliFlowConfig extends TaintTracking::Configuration {
override predicate isAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) { none() } override predicate isAdditionalTaintStep(DataFlow::Node n1, DataFlow::Node n2) { none() }
override predicate isSink(DataFlow::Node sink) { any() } override predicate isSink(DataFlow::Node sink) {
// rc = sqlite3_exec(db, query, NULL, 0, &zErrMsg);
exists(FunctionCall exec |
exec.getTarget().getName() = "sqlite3_exec" and
exec.getArgument(1) = sink.asExpr()
)
}
} }
// from SqliFlowConfig conf, DataFlow::PathNode source, DataFlow::PathNode sink // from SqliFlowConfig conf, DataFlow::PathNode source, DataFlow::PathNode sink
// where conf.hasFlowPath(source, sink) // where conf.hasFlowPath(source, sink)
// select sink, source, sink, "Possible SQL injection" // select sink, source, sink, "Possible SQL injection"
// Sink identification // Sink identification
// rc = sqlite3_exec(db, query, NULL, 0, &zErrMsg); // rc = sqlite3_exec(db, query, NULL, 0, &zErrMsg);
from FunctionCall exec, DataFlow::Node sink from FunctionCall exec, DataFlow::Node sink