Skip to content

Commit 82e2afc

Browse files
authored
Merge pull request #5 from jketema/cpp/mad-barriers
C++: Add MySQL MaD taint and barrier models
2 parents ad590f3 + 7ed1c0a commit 82e2afc

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added `taint` summary models and `sql-injection` barrier models for the mySQL `mysql_real_escape_string` and `mysql_real_escape_string_quote` escaping functions.

cpp/ql/lib/ext/MySql.model.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# partial model of the MySQL api
2+
extensions:
3+
- addsTo:
4+
pack: codeql/cpp-all
5+
extensible: summaryModel
6+
data: # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance
7+
- ["", "", False, "mysql_real_escape_string", "", "", "Argument[*2]", "Argument[*1]", "taint", "manual"]
8+
- ["", "", False, "mysql_real_escape_string_quote", "", "", "Argument[*2]", "Argument[*1]", "taint", "manual"]
9+
- addsTo:
10+
pack: codeql/cpp-all
11+
extensible: barrierModel
12+
data: # namespace, type, subtypes, name, signature, ext, output, kind, provenance
13+
- ["", "", False, "mysql_real_escape_string", "", "", "Argument[*1]", "sql-injection", "manual"]
14+
- ["", "", False, "mysql_real_escape_string_quote", "", "", "Argument[*1]", "sql-injection", "manual"]

cpp/ql/lib/semmle/code/cpp/models/implementations/MySql.qll

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,3 @@ private class MySqlExecutionFunction extends SqlExecutionFunction {
1616

1717
override predicate hasSqlArgument(FunctionInput input) { input.isParameterDeref(1) }
1818
}
19-
20-
/**
21-
* The `mysql_real_escape_string` family of functions from the MySQL C API.
22-
*/
23-
private class MySqlBarrierFunction extends SqlBarrierFunction {
24-
MySqlBarrierFunction() {
25-
this.hasName(["mysql_real_escape_string", "mysql_real_escape_string_quote"])
26-
}
27-
28-
override predicate barrierSqlArgument(FunctionInput input, FunctionOutput output) {
29-
input.isParameterDeref(2) and
30-
output.isParameterDeref(1)
31-
}
32-
}

0 commit comments

Comments
 (0)