Repository navigation
Description
Parent epic: #214
Priority: P1
Problem
research/redteam/ and the benchmark (#174, #182) test our guard. Nobody can easily measure whether their own text-to-SQL app or database MCP server can be made to run unsafe SQL. A tool that answers that question is useful on its own, and every report with holes in it is an argument to add a guard.
Proposal
sqlguardllm redteam setup --db "$DISPOSABLE_URL" # creates canary tables and rows in a disposable database
sqlguardllm redteam mcp -- <your MCP server command> # calls the server's SQL tool with every benchmark attack
sqlguardllm redteam report --format md # summary, per-attack results, a badge- MCP mode (first): acts as an MCP client, finds the SQL tool (or takes
--tool), sends the 69 benchmark attacks and the 34 legitimate queries, and judges the results with the canary oracle fromtests/fuzz. A canary in the output is a bypass. - HTTP mode (follow-up): the same against a text-to-SQL endpoint that takes SQL.
- Agent mode (follow-up): prompts that try to make the user's own agent write the attacks.
- Report: attacks that got through, legitimate queries that were refused, and a Markdown badge (for example
SQL red team: 69/69 blocked).
Security impact
- Defensive use only, against systems the user owns. The docs and
--helpsay so. - Runs only against a database prepared by
redteam setup: it refuses to start unless the canary marker table is present. This keeps generated attacks off real data. - Read-only sessions and timeouts on our side. The report never includes rows other than canaries.
- Results that show a weakness in a third-party project are reported privately to that project, never published by us (see the epic's ground rules in EPIC — Upstream adoption: sqlguardllm inside agent frameworks and database MCP servers #164).
Acceptance criteria
-
setup,mcpandreportwork against dbhub with and withoutsqlguardllm proxyin front. The report shows the difference. - Refuses to run without the canary marker (test).
- Offline reports in Markdown and JSON, with a versioned JSON schema. The benchmark guide documents rendering and comparing saved reports.
- Docs (EN / ES): "Red-team your own database agent", with the responsible-use rules at the top (guide).
Files
src/sqlguardllm/redteam/(new) · reusetests/fuzzoracle and the benchmark corpus ·cli.py·docs/REDTEAM.md(new)
Size
L
Offline reporting delivered
PR #254 adds python -m sqlguardllm.bench --report-from results.json to render existing aggregate benchmark JSON as Markdown on a local machine. All ten PR workflows passed before merge. This delivers the offline reporting slice. The original setup and execution criteria remain open.
PR #267 adds offline comparison of two saved benchmark reports. All ten PR workflows passed before merge. The bilingual guide documents input compatibility and private handling of findings.
PR #273 passed all eight reported workflows and merged. The Node example integration test has more time on busy runners, with complete response coverage and zero errors still required.
PR #278 merged after all ten PR workflows passed. The offline renderer refuses inconsistent counts and rates and invalid timing before rendering or comparing saved results. Earlier unversioned reports are still accepted when consistent. The test suite covers invalid files without starting validators.
PR #282 merged after ten successful PR workflows. New JSON reports record a fingerprint of the corpus definition and its ordered cases. The offline comparison refuses mismatching fingerprints and flags legacy reports for manual corpus verification.
PR #302 merged after ten successful PR workflows. Offline comparisons now show aggregate changes in outcomes, answered cases and errors for validators shared by reports with matching corpus fingerprints. They only read saved results.
PR #303 merged after all PR workflows passed, including Engines on PostgreSQL 16. It adds sqlguardllm redteam setup | mcp | report for PostgreSQL and SQLite. Each case first runs directly on the disposable database in a rolled-back transaction, so a missing privilege or procedure is not counted as a block; results are per dialect (PostgreSQL has 17 effective attacks in the corpus, not 69), so the badge reuses the benchmark's bypass n/m · FP n/m. The command after -- is never written to the report. Remaining: the dbhub run on PostgreSQL with and without sqlguardllm proxy, and the HTTP and agent modes.
PR #304 merged after its CI passed, including the proxy-upstreams job. A real dbhub on PostgreSQL, 14 effective attacks and 18 legitimate queries: dbhub alone accepts 13/14 (4 attacks changed the database, 5 leaked a canary); behind sqlguardllm proxy, 0/14 accepted and 0/18 refused, with no trace. report --compare-with shows the two runs side by side. This tests a setup (default dbhub settings, a database user that can write), not dbhub itself.
All acceptance criteria are met. The HTTP and agent modes the issue lists as follow-ups are not built.
Activity
Version the saved benchmark JSON report format (#274)
Validate saved benchmark metrics before rendering (#278)
Check corpus fingerprints when comparing saved benchmark reports (#282)
Show count changes in verified offline benchmark comparisons (#302)
Test the red team on a real PostgreSQL in the engines job (#219)
sqlguardllm redteam: attack your own database MCP server (#219, first…
Test redteam against dbhub on PostgreSQL, with and without the proxy (#…
Exclude active red-team modules from default CI (#308)