mirror of
https://github.com/hohn/codeql-dataflow-sql-injection.git
synced 2025-12-16 02:03:05 +01:00
sql injection: taintstep across macro under snprintf, with position adjustment
This commit is contained in:
committed by
=Michael Hohn
parent
45a5e89366
commit
4060f31100
@@ -39,6 +39,17 @@ class SqliFlowConfig extends TaintTracking::Configuration {
|
||||
// select sink, source, sink, "Possible SQL injection"
|
||||
|
||||
// Extra taint step
|
||||
// snprintf(query, bufsize, "INSERT INTO users VALUES (%d, '%s')", id, info);
|
||||
// snprintf(query, bufsize, "INSERT INTO users VALUES (%d, '%s')", id, info);
|
||||
// But snprintf is a macro on mac os. The actual function's name is
|
||||
// #undef snprintf
|
||||
// #define snprintf(str, len, ...) \
|
||||
// __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
|
||||
// #endif
|
||||
from FunctionCall printf, DataFlow::Node into, DataFlow::Node out
|
||||
where printf.getTarget().getName() = "snprintf"
|
||||
where
|
||||
printf.getTarget().getName().matches("%snprintf%") and
|
||||
printf.getArgument(0) = out.asExpr() and
|
||||
// very specific: shifted index for macro. We can generalize this to consider
|
||||
// all trailing arguments as sources.
|
||||
printf.getArgument(6) = into.asExpr()
|
||||
select printf, into, out
|
||||
|
||||
Reference in New Issue
Block a user