Skip to content

C++: Model Comdb2 SQL execution sinks - #22562

Open
kumarak wants to merge 1 commit into
github:mainfrom
trail-of-forks:comdb2-sql-injection-models
Open

kumarak wants to merge 1 commit into
github:mainfrom
trail-of-forks:comdb2-sql-injection-models

Conversation

@kumarak

@kumarak kumarak commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Calls that execute user-controlled SQL through the Comdb2 C API are currently missing SQL-injection sinks. Model the SQL-text argument of cdb2_run_statement and cdb2_run_statement_typed so cpp/sql-injection reports these flows. The typed variant specifies result-column types and still interprets its SQL argument as query text.

The models follow the public C API documentation and public Apache-2.0-licensed declarations. Regression coverage includes both unsafe execution calls, constant SQL, and tainted bound values used with constant parameterized SQL. Includes a library change note.

Validation with CodeQL CLI 2.25.6:

  • SQL-injection regression test (cpp/ql/test/query-tests/Security/CWE/CWE-089/SqlTainted).
  • External model validation (cpp/ql/test/library-tests/dataflow/external-models/validatemodels.ql).

@kumarak
kumarak requested a review from a team as a code owner September 14, 2026 21:26
Copilot AI balanced review requested due to automatic review settings September 14, 2026 21:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The models match the documented API signatures and are covered by focused regression cases.

Pull request overview

Adds Comdb2 C API SQL-execution sinks to C++ SQL-injection analysis.

Changes:

  • Models SQL arguments for both Comdb2 execution functions.
  • Adds regression coverage and a change note.
File summaries
File Description
cpp/ql/lib/ext/Comdb2.model.yml Defines Comdb2 SQL-injection sinks.
cpp/ql/test/query-tests/Security/CWE/CWE-089/SqlTainted/test_comdb2.c Tests unsafe SQL and safe parameter binding.
cpp/ql/test/query-tests/Security/CWE/CWE-089/SqlTainted/SqlTainted.expected Updates generated expected results.
cpp/ql/lib/change-notes/2026-09-14-comdb2-sql-injection.md Documents the analysis improvement.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants