mirror of
https://github.com/hohn/codeql-c-sqli.git
synced 2025-12-16 10:33:03 +01:00
minor changes
This commit is contained in:
committed by
=Michael Hohn
parent
61804125e3
commit
cfdf2168f5
12
README.org
12
README.org
@@ -202,13 +202,23 @@
|
|||||||
--ram=14000 \
|
--ram=14000 \
|
||||||
-j12 \
|
-j12 \
|
||||||
--rerun \
|
--rerun \
|
||||||
--search-path ~/local/vmsync/ql \
|
|
||||||
--format=sarif-latest \
|
--format=sarif-latest \
|
||||||
--output cpp-sqli.sarif \
|
--output cpp-sqli.sarif \
|
||||||
-- \
|
-- \
|
||||||
$DB \
|
$DB \
|
||||||
$SRCDIR/SqlInjection.ql
|
$SRCDIR/SqlInjection.ql
|
||||||
|
|
||||||
|
codeql database analyze \
|
||||||
|
-v \
|
||||||
|
--ram=14000 \
|
||||||
|
-j12 \
|
||||||
|
--rerun \
|
||||||
|
--format=sarif-latest \
|
||||||
|
--output cpp-sqli.sarif \
|
||||||
|
-- \
|
||||||
|
$DB \
|
||||||
|
$SRCDIR/trivial.ql
|
||||||
|
|
||||||
# Examine the file in an editor
|
# Examine the file in an editor
|
||||||
edit cpp-sqli.sarif
|
edit cpp-sqli.sarif
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|||||||
@@ -20,21 +20,21 @@ module SqliFlowConfig implements DataFlow::ConfigSig {
|
|||||||
|
|
||||||
predicate isBarrier(DataFlow::Node sanitizer) { none() }
|
predicate isBarrier(DataFlow::Node sanitizer) { none() }
|
||||||
|
|
||||||
predicate isAdditionalFlowStep(DataFlow::Node into, DataFlow::Node out) {
|
// predicate isAdditionalFlowStep(DataFlow::Node into, DataFlow::Node out) {
|
||||||
// Extra taint step
|
// // 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
|
// // But snprintf is a macro on mac os. The actual function's name is
|
||||||
// #undef snprintf
|
// // #undef snprintf
|
||||||
// #define snprintf(str, len, ...) \
|
// // #define snprintf(str, len, ...) \
|
||||||
// __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
|
// // __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)
|
||||||
// #endif
|
// // #endif
|
||||||
exists(FunctionCall printf |
|
// exists(FunctionCall printf |
|
||||||
printf.getTarget().getName().matches("%snprintf%") and
|
// printf.getTarget().getName().matches("%snprintf%") and
|
||||||
printf.getArgument(0) = out.asDefiningArgument() and
|
// printf.getArgument(0) = out.asDefiningArgument() and
|
||||||
// very specific: shifted index for macro.
|
// // very specific: shifted index for macro.
|
||||||
printf.getArgument(6) = into.asIndirectArgument()
|
// printf.getArgument(6) = into.asIndirectArgument()
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
predicate isSink(DataFlow::Node sink) {
|
predicate isSink(DataFlow::Node sink) {
|
||||||
// rc = sqlite3_exec(db, query, NULL, 0, &zErrMsg);
|
// rc = sqlite3_exec(db, query, NULL, 0, &zErrMsg);
|
||||||
exists(FunctionCall exec |
|
exists(FunctionCall exec |
|
||||||
|
|||||||
10
notes.org
Normal file
10
notes.org
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
* sequence
|
||||||
|
- [X] build program
|
||||||
|
- [X] build under codeql control -> codeql db
|
||||||
|
/Users/hohn/2025-05-21/codeqlworkshop/codeql-c-sqli/cpp-sqli-35d4c80
|
||||||
|
- [X] write / use query (db + query -> codeql -> sarif)
|
||||||
|
- [X] view sarif
|
||||||
|
|
||||||
|
- [ ] follow up:
|
||||||
|
+ [ ] classes of vulnerabilities
|
||||||
|
|
||||||
Reference in New Issue
Block a user