mirror of
https://github.com/hohn/codeql-dataflow-sql-injection.git
synced 2025-12-16 18:23:05 +01:00
Use asIndirecArgument
This commit is contained in:
committed by
=Michael Hohn
parent
00bd07be2b
commit
92a678414d
@@ -15,7 +15,7 @@ module SqliFlowConfig implements DataFlow::ConfigSig {
|
|||||||
// count = read(STDIN_FILENO, buf, BUFSIZE);
|
// 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.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr()
|
read.getArgument(1) = source.(DataFlow::PostUpdateNode).getPreUpdateNode().asIndirectArgument()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ module SqliFlowConfig implements DataFlow::ConfigSig {
|
|||||||
// #endif
|
// #endif
|
||||||
exists(FunctionCall printf |
|
exists(FunctionCall printf |
|
||||||
printf.getTarget().getName().matches("%snprintf%") and
|
printf.getTarget().getName().matches("%snprintf%") and
|
||||||
printf.getArgument(0) = out.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr() and
|
printf.getArgument(0) = out.(DataFlow::PostUpdateNode).getPreUpdateNode().asIndirectArgument() and
|
||||||
// very specific: shifted index for macro.
|
// very specific: shifted index for macro.
|
||||||
printf.getArgument(6) = into.asExpr()
|
printf.getArgument(6) = into.asExpr()
|
||||||
)
|
)
|
||||||
|
|||||||
15
session.ql
15
session.ql
@@ -1,3 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* @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 cpp
|
||||||
|
|
||||||
// 1. invalid input -- source
|
// 1. invalid input -- source
|
||||||
@@ -59,9 +67,16 @@ import semmle.code.cpp.dataflow.new.TaintTracking
|
|||||||
|
|
||||||
module SqliFlowConfig implements DataFlow::ConfigSig {
|
module SqliFlowConfig implements DataFlow::ConfigSig {
|
||||||
predicate isSource(DataFlow::Node source) {
|
predicate isSource(DataFlow::Node source) {
|
||||||
|
exists(DataSource ds |
|
||||||
|
source.asExpr() = ds
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
predicate isSink(DataFlow::Node sink) {
|
predicate isSink(DataFlow::Node sink) {
|
||||||
|
exists(DataSink ds |
|
||||||
|
sink.asExpr() = ds
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user