Skip to content

threat_sql_injection column name overclaims: ~0% precision, FastAPI Query() drives it #3018

Closed

Description

@squid-protocol

Summary

#3017 (for #2985) shipped sec_amplified_sql_injection to file_data as the column
threat_sql_injection, labelled "Confirmed SQL Injection Path (Public API -> Raw DB
Sink)"
. Measuring the signal after the fact shows that name asserts a conclusion the data
does not support, and the column landed in exactly the schema #2982's CVE correlation reads.

My naming, my error — filing to correct it before anything queries it.

Evidence

Across the blessed golden_master_zero_dep_audit.json corpus (2817 files), 29 files are
flagged as a "Confirmed SQL Injection Path". The top hit is
python/fastapi/tests/test_annotated.py with 13 "confirmed SQL injections" in a file
containing no database code at all
(grep -ciE "sqlalchemy|psycopg|sqlite|cursor|SELECT|INSERT"
returns 0).

The mechanism is db_hooks matching FastAPI's query-parameter helper:

L12: async def default(foo: Annotated[str, Query()] = "foo"):

Query( fires db_hooks, the async def route fires api, they share a function, and
correlate_against_ledger "confirms" a SQL injection path.

On gitgalaxy's own scan all 7 hits are false too -- hardcoded PRAGMA journal_mode = WAL,
a correctly parameterized DELETE ... WHERE repo_name = ?, and one match on the word
"raw" inside an English prose comment.

Inspected precision: ~0%.

Why the name is the problem

The underlying correlation is a legitimate shape measurement -- "a public API declaration
sits within N lines of a raw DB sink, in the same function". That is worth persisting. What
it is not is a confirmed injection path: the engine is AST-less, so it cannot prove any
untrusted value reaches the query. That is precisely the reasoning #1020 used to delete
injection_surface, and CLAUDE.md's "Comparative-correctness claims require verification"
rule says a claim like "Confirmed" needs a read of real source behind it. It has none.

Proposed change

  • Column threat_sql_injection -> threat_api_near_db_sink
  • Label "Confirmed SQL Injection Path (Public API -> Raw DB Sink)" ->
    "Public API Declared Near Raw DB Sink"

Renaming now costs nothing (the column is one merge old and nothing queries it yet); renaming
after #2982 starts correlating against it is a breaking change to published data.

The equation key sec_amplified_sql_injection is left alone in this issue -- it is the
pre-existing internal name, and see the sibling issue on the db_hooks sensor itself.

Activity

  1. added
    appsec
    schema
    on Sep 14, 2026
  2. added a commit that references this issue on Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appsecschema

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions