Skip to content

Add support for Oracle Call Interface (OCI) to C/C++ coverage #19764

Open
@ebickle

Description

@ebickle

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions