mirror of
https://github.com/hohn/codeql-lab.git
synced 2025-12-17 02:13:04 +01:00
Rename directories to include language. Also update files
This commit is contained in:
committed by
=Michael Hohn
parent
fe1baf7dc1
commit
102c18cce5
46
codeql-dataflow-sql-injection-c/SqlInjection.ql
Normal file
46
codeql-dataflow-sql-injection-c/SqlInjection.ql
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @name SQLI Vulnerability
|
||||
* @description Using untrusted strings in a sql query allows sql injection attacks.
|
||||
* @ kind path-problem
|
||||
* @id cpp/sqlivulnerable
|
||||
* @problem.severity warning
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import semmle.code.cpp.dataflow.new.TaintTracking
|
||||
|
||||
module SqliFlowConfig implements DataFlow::ConfigSig {
|
||||
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
// count = read(STDIN_FILENO, buf, BUFSIZE);
|
||||
exists(FunctionCall read |
|
||||
read.getTarget().getName() = "read" and
|
||||
(
|
||||
read.getArgument(1) = source.asDefiningArgument()
|
||||
or
|
||||
read.getArgument(1) = source.asExpr()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
predicate isBarrier(DataFlow::Node sanitizer) { none() }
|
||||
|
||||
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.asIndirectArgument()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module MyFlow = TaintTracking::Global<SqliFlowConfig>;
|
||||
// import MyFlow::PathGraph
|
||||
|
||||
from DataFlow::Node thing
|
||||
where SqliFlowConfig::isSource(thing)
|
||||
select thing, thing.getAQlClass()
|
||||
// from MyFlow::PathNode source, MyFlow::PathNode sink
|
||||
// where MyFlow::flowPath(source, sink)
|
||||
// select sink, source, sink, "Possible SQL injection"
|
||||
|
||||
Reference in New Issue
Block a user