-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description of the issue
The Oracle Call Interface (OCI) is the main low-level C API for Oracle databases. CodeQL lacks coverage for it, particularly for SQL injection sinks.
While I haven't done a robust analysis of the API surface area, the official documentation shows the following functions as accepting SQL input:
- OCIStmtPrepare:
sword OCIStmtPrepare(OCIStmt* stmtp, OCIError* errhp, const OraText* stmt, ub4 stmt_len, ub4 language, ub4 mode); - OCIStmtPrepare2:
sword OCIStmtPrepare2(OCISvcCtx* svchp, OCIStmt** stmthp, OCIError* errhp, const OraText* stmttext, ub4 stmt_len, const OraText* key, ub4 keylen, ub4 language, ub4 mode);
oratypes.h of the OCI (Simple Client) SDK has the following typedefs:
- typedef unsigned char oratext;
- typedef unsigned int ub4;
It looks relatively simple to treat the stmt parameter of OCIStmtPrepare and the stmttext of OCIStmtPrepare2 as SQL sinks within CodeQL. The function names, starting with OCI, are unlikely to collide with other libraries.
I looked at adding this as a PR to expand model coverage, but it looks like the sql-injection sink type isn't supported for C++ CodeQL extension models yet.