Skip to content

Commit 18890c4

Browse files
committed
C++: Use isAdditionalBarrier in the SqlTainted query.
1 parent 69efe7a commit 18890c4

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class Configuration extends TaintTrackingConfiguration {
2727
override predicate isSink(Element tainted) {
2828
exists(SQLLikeFunction runSql | runSql.outermostWrapperFunctionCall(tainted, _))
2929
}
30+
31+
override predicate isAdditionalBarrier(Expr e) { e.getUnspecifiedType() instanceof IntegralType }
3032
}
3133

3234
from

cpp/ql/test/query-tests/Security/CWE/CWE-089/SqlTainted/SqlTainted.expected

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,11 @@ edges
33
| test.c:15:20:15:23 | argv | test.c:21:18:21:23 | (const char *)... |
44
| test.c:15:20:15:23 | argv | test.c:21:18:21:23 | query1 |
55
| test.c:15:20:15:23 | argv | test.c:21:18:21:23 | query1 |
6-
| test.c:16:25:16:28 | argv | test.c:33:18:33:23 | (const char *)... |
7-
| test.c:16:25:16:28 | argv | test.c:33:18:33:23 | (const char *)... |
8-
| test.c:16:25:16:28 | argv | test.c:33:18:33:23 | query3 |
9-
| test.c:16:25:16:28 | argv | test.c:33:18:33:23 | query3 |
106
nodes
117
| test.c:15:20:15:23 | argv | semmle.label | argv |
128
| test.c:15:20:15:23 | argv | semmle.label | argv |
13-
| test.c:16:25:16:28 | argv | semmle.label | argv |
14-
| test.c:16:25:16:28 | argv | semmle.label | argv |
159
| test.c:21:18:21:23 | (const char *)... | semmle.label | (const char *)... |
1610
| test.c:21:18:21:23 | (const char *)... | semmle.label | (const char *)... |
1711
| test.c:21:18:21:23 | query1 | semmle.label | query1 |
18-
| test.c:33:18:33:23 | (const char *)... | semmle.label | (const char *)... |
19-
| test.c:33:18:33:23 | (const char *)... | semmle.label | (const char *)... |
20-
| test.c:33:18:33:23 | query3 | semmle.label | query3 |
2112
#select
2213
| test.c:21:18:21:23 | query1 | test.c:15:20:15:23 | argv | test.c:21:18:21:23 | query1 | This argument to a SQL query function is derived from $@ and then passed to mysql_query(sqlArg) | test.c:15:20:15:23 | argv | user input (argv) |
23-
| test.c:33:18:33:23 | query3 | test.c:16:25:16:28 | argv | test.c:33:18:33:23 | query3 | This argument to a SQL query function is derived from $@ and then passed to mysql_query(sqlArg) | test.c:16:25:16:28 | argv | user input (argv) |

cpp/ql/test/query-tests/Security/CWE/CWE-089/SqlTainted/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ int main(int argc, char** argv) {
3030
// an integer from the user is injected into an SQL query.
3131
char query3[1000] = {0};
3232
snprintf(query3, 1000, "SELECT UID FROM USERS where number = \"%i\"", userNumber);
33-
mysql_query(0, query3); // BAD [FALSE POSITIVE]
33+
mysql_query(0, query3); // BAD
3434
}

0 commit comments

Comments
 (0)