mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
C++: Support SQL Injection sinks for Oracle Call Interface (OCI)
This commit is contained in:
@@ -9,6 +9,8 @@ edges
|
||||
| test.c:48:20:48:33 | *globalUsername | test.c:51:18:51:23 | *query1 | provenance | TaintFunction |
|
||||
| test.c:75:8:75:16 | gets output argument | test.c:76:17:76:25 | *userInput | provenance | |
|
||||
| test.c:75:8:75:16 | gets output argument | test.c:77:20:77:28 | *userInput | provenance | |
|
||||
| test.c:101:8:101:16 | gets output argument | test.c:106:24:106:29 | *query1 | provenance | TaintFunction Sink:MaD:325 |
|
||||
| test.c:101:8:101:16 | gets output argument | test.c:107:28:107:33 | *query1 | provenance | TaintFunction Sink:MaD:326 |
|
||||
| test.cpp:39:27:39:30 | **argv | test.cpp:43:27:43:33 | *access to array | provenance | |
|
||||
nodes
|
||||
| test.c:14:27:14:30 | **argv | semmle.label | **argv |
|
||||
@@ -23,6 +25,9 @@ nodes
|
||||
| test.c:75:8:75:16 | gets output argument | semmle.label | gets output argument |
|
||||
| test.c:76:17:76:25 | *userInput | semmle.label | *userInput |
|
||||
| test.c:77:20:77:28 | *userInput | semmle.label | *userInput |
|
||||
| test.c:101:8:101:16 | gets output argument | semmle.label | gets output argument |
|
||||
| test.c:106:24:106:29 | *query1 | semmle.label | *query1 |
|
||||
| test.c:107:28:107:33 | *query1 | semmle.label | *query1 |
|
||||
| test.cpp:39:27:39:30 | **argv | semmle.label | **argv |
|
||||
| test.cpp:43:27:43:33 | *access to array | semmle.label | *access to array |
|
||||
subpaths
|
||||
|
||||
@@ -75,4 +75,41 @@ void ODBCTests(){
|
||||
gets(userInput);
|
||||
SQLPrepare(0, userInput, 100); // BAD
|
||||
SQLExecDirect(0, userInput, 100); // BAD
|
||||
}
|
||||
|
||||
// Oracle Call Interface (OCI) Routines
|
||||
int OCIStmtPrepare(
|
||||
void *arg0,
|
||||
void *arg1,
|
||||
const unsigned char *sql,
|
||||
unsigned int arg3,
|
||||
unsigned int arg4,
|
||||
unsigned int arg5);
|
||||
int OCIStmtPrepare2(
|
||||
void *arg0,
|
||||
void **arg1,
|
||||
void *arg2,
|
||||
const unsigned char *sql,
|
||||
unsigned int arg4,
|
||||
const unsigned char *arg5,
|
||||
unsigned int arg6,
|
||||
unsigned int arg7,
|
||||
unsigned int arg8);
|
||||
|
||||
void OCITests(){
|
||||
char userInput[100];
|
||||
gets(userInput);
|
||||
|
||||
// a string from the user is injected directly into an SQL query.
|
||||
char query1[1000] = {0};
|
||||
snprintf(query1, 1000, "SELECT UID FROM USERS where name = \"%s\"", userInput);
|
||||
OCIStmtPrepare(0, 0, query1, 0, 0, 0); // BAD
|
||||
OCIStmtPrepare2(0, 0, 0, query1, 0, 0, 0, 0, 0); // BAD
|
||||
|
||||
// an integer from the user is injected into an SQL query.
|
||||
int userNumber = atoi(userInput);
|
||||
char query2[1000] = {0};
|
||||
snprintf(query2, 1000, "SELECT UID FROM USERS where number = \"%i\"", userNumber);
|
||||
OCIStmtPrepare(0, 0, query2, 0, 0, 0); // GOOD
|
||||
OCIStmtPrepare2(0, 0, 0, query2, 0, 0, 0, 0, 0); // GOOD
|
||||
}
|
||||
Reference in New Issue
Block a user