Skip to content

Python: add SQL injection models for the duckdb package - #22352

Open
jtabsbm wants to merge 1 commit into
github:mainfrom
jtabsbm:add-duckdb-python-models
Open

Python: add SQL injection models for the duckdb package#22352
jtabsbm wants to merge 1 commit into
github:mainfrom
jtabsbm:add-duckdb-python-models

Conversation

@jtabsbm

@jtabsbm jtabsbm commented Aug 15, 2026

Copy link
Copy Markdown

What does this PR do?

Adds CodeQL data-flow models for the duckdb Python package (~10M downloads/month). duckdb implements the Python DB-API 2.0 (PEP 249), but had no models in this repo, so string-built SQL passed to duckdb execution APIs was not flagged by the SqlInjection query suite.

Specifically:

  • DuckdbPEP249 models duckdb as a PEP 249 module, giving duckdb.connect(), connection.cursor(), cursor.execute() and cursor.executemany() the standard SQL-execution sink models via the existing PEP 249 machinery (plus the fetch* threat-model sources).
  • ModuleLevelExecuteCall additionally models the module-level convenience wrappers duckdb.sql(), duckdb.execute() and duckdb.executemany() as SqlExecution calls, with getSql() bound to positional argument 0 or the query keyword.
  • Registers the framework in Frameworks.qll and adds duckdb, Database to the supported frameworks docs.

The modeling pattern follows the merged hdbcli models from #19444.

Testing

  • QL syntax follows existing reviewed models (PEP249 extension + module-level ApiGraph call, same as hdbcli)

Checklist:

  • .qll changes are in semmle/python/frameworks/
  • Change note added
  • Supported frameworks docs updated

duckdb (~10M downloads/month) implements PEP 249 but had no CodeQL models,
so string-built SQL passed to duckdb.execute()/sql()/executemany() was not
flagged by the SqlInjection query suite. This adds:

- DuckdbPEP249: models duckdb as a PEP 249 module (connect/cursor/
  execute/executemany sinks via the existing PEP249 machinery)
- ModuleLevelExecuteCall: models the module-level duckdb.sql(),
  duckdb.execute() and duckdb.executemany() convenience wrappers as
  SqlExecution calls (getSql from arg 0 or the 'query' keyword)
- Frameworks.qll registration and supported-frameworks docs entry

Pattern follows the merged hdbcli models (PR github#19444).

Signed-off-by: jtabsbm <317336566@users.noreply.github.com>
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.

1 participant