Repository navigation
Description
Target Language
rust
Library Repository / Documentation URL
To be determined from the linked findings
Data Extension Name (Optional)
cwe-89.model.yml
Library Modules / Components
See linked findings for the frameworks involved.
Data Extension Description
AI Scan reported 3 high-severity CWE-89 (sql nosql ldap injection) finding(s) in Rust public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: missing-framework-model. Existing queries considered: rust/sql-injection.
Why CodeQL appears to have missed these (unverified until reproduced with a test database):
- The SQLx sink is modeled, but no Warp source model was found. A remote-source data extension for Warp path parameters should connect the flow.
- The installed query has no postgres::Client query sink model, and the fixed-file source also depends on local threat-model configuration.
- rust/sql-injection exists, but installed libraries model SQLx and not Diesel sql_query. The fixed-file source may also require a local threat model.
Linked findings (gap-key: rust/data-extension-create/sql-nosql-ldap-injection)
| Repo | CWE | Severity | AI scan alert | Summary |
|---|---|---|---|---|
| rust-vulnerable-apps | CWE-89 | high | https://github.com/codeql-forks-felickz/rust-vulnerable-apps/security/code-scanning/19 | The Warp path parameter is embedded in a SQL string and executed without parameter binding. A request value containing SQL syntax can alter the query, exposing or modifying database data. |
| rust-vulnerable-apps | CWE-89 | high | https://github.com/codeql-forks-felickz/rust-vulnerable-apps/security/code-scanning/22 | Untrusted file content is formatted directly into a PostgreSQL query and executed with no bound parameter. An attacker able to control the input can inject SQL expressions or additional query content. |
| rust-vulnerable-apps | CWE-89 | high | https://github.com/codeql-forks-felickz/rust-vulnerable-apps/security/code-scanning/25 | Untrusted file content is concatenated into raw SQL and passed to sql_query. Use a placeholder and bound parameter; the current construction allows attacker input to change query semantics. |
Findings come from AI Scan on public synthetic apps. Hypotheses above are unverified until reproduced with a test database. Verify first whether CodeQL already covers a case (for example via a different query or threat model) before adding code.
Code Examples
See the linked alerts above for the vulnerable pattern; reduce each to a minimal test case with a safe counterpart that should not alert.
Additional References (Optional)
https://cwe.mitre.org/data/definitions/89.html
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
felickz commentedon Oct 16, 2026
Update: the findings below were forwarded to the linked pull request #141 for the Copilot agent to re-validate.
sqli/sqli_bad_007_postgres/src/Sqli_bad_007.rs:12client.query, enabling SQL injection. CodeQL would need the model/query described as: SQL string built with format! from a Warp path parameter or file-read value and passed to postgres/sqlx query; needs the framework source and sqlx/postgres query sinks modeled.sqli/sqli_good_001_sqlx/src/main.rs:23vuln_func, interpolated into a query string, and executed without parameterization. CodeQL would need the model/query described as: SQL string built with format! from a Warp path parameter or file-read value and passed to postgres/sqlx query; needs the framework source and sqlx/postgres query sinks modeled.felickz commentedon Oct 31, 2026
Update: additional medium and low severity findings fit this gap (gap-key
rust/data-extension-create/sql-nosql-ldap-injection). They are listed with full context so the Copilot agent can re-validate each one against the proposed change and extend it where it does not cover them.Linked findings
.bind()does not undo that injection. An attacker can include SQL syntax plus one placeholder (for example, close the quote and add a tautological expression containing?) so the added bind count remains va...Handling
Add a data extension (model-as-data). An existing query should report these once the library is modeled; add the missing sources, sinks, summaries or barriers as extension rows.
Patterns
missing-source-or-sink-model(1 finding), for example rust-vulnerable-apps sqli/sqli_good_002_sqlx/src/main.rsFinding details
1. rust-vulnerable-apps sqli/sqli_good_002_sqlx/src/main.rs:21 (CWE-89, medium)
.bind()does not undo that injection. An attacker can include SQL syntax plus one placeholder (for example, close the quote and add a tautological expression containing?) so the added bind count remains valid while the altered query executes. Keep the SQL text constant (... WHERE key = ?) and bind the value only once..bind()does not undo that injection. CodeQL would need the model/query described as: SQL string built with format! from a Warp path parameter or file-read value and passed to postgres/sqlx query; needs the framework source and sqlx/postgres query sinks modeled.felickz commentedon Nov 3, 2026
Upstream triage
precision:very-highExact API/type-based fix, no heuristics. github/codeql candidate if the pattern is real-world.
Candidate for
github/codeql. Very high precision with a real-world basis and no material performance or false-positive concerns. Notags:experimentallabel.Linked pull request: #141
Why. Adds exact-path sink rows for Diesel raw SQL entry points (sql_query, SqlQuery::sql, dsl::sql, SimpleConnection::batch_execute), matching how stock sqlx, postgres, rusqlite and mysql are modeled; Diesel has no rows upstream. Each sink is exercised with bound-parameter negatives. The str::trim summary is a small stdlib fix best sent as a separate PR. Diesel is a public Rust ORM, so this is a general model addition.
Concerns, overlap and next steps
What an upstream change would look like. New rust/ql/lib/codeql/rust/frameworks/diesel.model.yml with the four sinkModel rows; tests in rust/ql/test/query-tests/security/CWE-089 (diesel.rs, options.yml, SqlInjection.expected, SqlSinks.expected); change note in rust/ql/lib/change-notes. The trim row goes in a separate PR.
Before opening an upstream pull request
Split note. Two independent parts: the Diesel sinks (very-high, general) and the str::trim summary (a global stdlib change that affects every Rust query). Submit them as two upstream PRs. The installer script edit is not for upstream.
This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.