Repository navigation
Releases
sqlguardllm 0.5.0a8
SQLGuardLLM 0.5.0a8 adds the MCP Registry ownership marker to the published PyPI package. Python, npm, NuGet and the MCP manifest advance together.
sqlguardllm 0.5.0a7
Fixes the macOS engine packages on npm (they could not run after npm install); see Fixed.
Fixed
- npm: the macOS engine packages could not run. npm does not keep symlinks in packages, and the macOS engine (Python.framework) has four, so after
npm installits digest no longer matched the built-in one and the client refused to start it (engine_digest_mismatch). The packages now carry real copies instead of symlinks, and CI unpacks every packed platform package and checks the digest of the installed engine, which a file list cannot show. Affects 0.5.0-alpha.5 and 0.5.0-alpha.6 on macOS (Linux and Windows were not affected).
sqlguardllm 0.5.0a6
The NuGet package now carries the engine for five runtimes and the integrations package is published with it; Node and .NET local mode are tested on Linux, macOS and Windows.
Fixed
- Node.js: a program that ends with a top-level
await guard.close()on a local-mode guard exited with an unsettled await (code 13), because the engine process is unref'd and nothing kept the event loop alive whileclose()waited for it to exit.close()now keeps the loop alive until the engine exits (at most 2 s). - .NET:
dotnet packfailed with NU5123 once the engines were staged, and a RID-specific publish (dotnet publish -r <rid>, self-contained, single-file, container images) failed with NETSDK1152 or lost the engine folder, because the SDK flattens native assets. The package now shipsbuild/SqlGuardLlm.targets, which keeps thesqlguardllm-engine/folder intact next to the app (#76). - The NuGet release job pushed
SqlGuardLlmwithout the engines (nothing staged them) and did not push the integration packages (#76, #79).
Added
- .NET release and CI (#76, #77, #79):
clients/dotnet/build/stage-engines.py(it was documented but missing) stages the attested engine archives with anengine.sha256manifest and fails when the package passes 150 MB;clients/dotnet/Directory.Build.propsholds one version for the four packages, with SourceLink, deterministic builds and.snupkgsymbols for all of them, andrelease.ymlchecks it against the engine release, verifies the engine archives, packs and pushesSqlGuardLlm,SqlGuardLlm.Extensions,SqlGuardLlm.EntityFrameworkCoreandSqlGuardLlm.SemanticKernel, after a consumer project restored the packed package and started its engine.dotnet-client.ymlnow runs the unit tests and the whole conformance corpus in local mode on Linux, macOS and Windows (a missing engine fails instead of skipping), and apackagejob builds the engine of each platform, packs, and runsclients/dotnet/smokewithdotnet run,dotnet publish -r <rid>(framework-dependent, self-contained single-file, trimmed and Native AOT with trimming and AOT warnings as errors), a tampered-engine check and, on Linux, a container image. - Node.js recipes (#74): the
Recipesworkflow has anode-recipesjob that runsexamples/nodewith the real engine in local mode on SQLite and on a PostgreSQL 16 service container.examples/node/run.mjsand the tests acceptSQLGUARD_ENGINE_CMD. - Node.js and .NET guides, quickstart pointers, package chooser and READMEs (English and Spanish) now describe the embedded engine (
SqlGuard.local,SqlGuard.CreateLocalAsync) as the default path and the server as the remote mode. - .NET integrations (#78).
SqlGuardLlm.Extensions(services.AddSqlGuard(...)with options bound from configuration, ADO.NET and Dapper helpers, a Microsoft.Extensions.AIGuardedSqlFunction),SqlGuardLlm.EntityFrameworkCore(aDbCommandInterceptorthat enforces raw SQL) andSqlGuardLlm.SemanticKernel(a function invocation filter), plus runnable examples inexamples/dotnet/. - Node.js recipes (#74) in
examples/node/: a guardedsql_db_querytool for LangChain.js, a guardedtool()for the Vercel AI SDK and runners forpg,mysql2and Prisma$queryRawUnsafe, all throughenforce(), with SQLite and (withDATABASE_URL) PostgreSQL tests. Seedocs/RECIPES.md.
sqlguardllm 0.5.0a5
First release whose npm package carries the embedded engine: npm install sqlguardllm can run it with no Python and no server (SqlGuard.local). The .NET package ships the engine as runtime assets with a local mode.
Added
- npm: the release now publishes the five
sqlguardllm-engine-<platform>packages and thensqlguardllmwith the embedded engine in itsoptionalDependencies, all withnpm publish --provenance(#75). The engines are the attested archives of the same run.clients/node/npm/publish.mjs --dry-runrunsnpm packon all six; the newnpm pack (dry run)workflow runs it on pull requests and uploads the file lists. The one-time owner steps (Trusted Publisher on each new package) are in CONTRIBUTING.md.
sqlguardllm 0.5.0a4
Security release: upgrade if you use dialect="duckdb" with hidden or masked columns. It also brings the embedded-engine groundwork (engine protocol, standalone binaries, npm and NuGet engine packages), the opt-in audit log and the LLM red team.
Security
- On DuckDB, hidden and masked columns could be read with
COLUMNS('regex')orCOLUMNS(lambda). DuckDB picks the columns by pattern at run time, and the guard did not treat it as a star, soSELECT COLUMNS('.*') FROM customersreturned a hidden column.COLUMNS()is now refused whenever the query can see a table with hidden or masked columns (also inside an aggregate). Affects every release withdialect="duckdb". Found by the LLM red team (#63).
Added
- LLM red team (#63):
research/redteam/run.pyasks Claude (claude-opus-5-5, adaptive thinking, structured outputs, server-side fallback) for attacks against the guard, with a fixed defensive-purpose prompt (prompt.md, sha256 recorded). Every query is kept inresearch/redteam/<date>/attacks.jsonlwith model, prompt and policy hashes, version, git sha, verdict and per-engine outcome, judged by the fuzzing canary oracle on SQLite, DuckDB, PostgreSQL, MySQL and SQL Server; duplicates are fingerprinted and counted, bypasses become pending cases fortests/corpus/redteam.yaml. A run is capped (at most 50 attacks, a hard token budget, a per-run USD ceiling checked against a free token count first); a refusal is recorded, not a failure.--rescore <dir>re-judges a stored dataset without the API. Weekly and manual workflow.github/workflows/redteam.ymlonmainonly. - .NET: the engine as runtime assets of the NuGet package (#76).
SqlGuardEngine.StartAsync(policy)runs the packagedruntimes/{rid}/native/sqlguardllm-engine/for linux-x64, linux-arm64, osx-x64, osx-arm64 and win-x64 over the stdio protocol, after recomputing the SHA-256 of every file againstengine.sha256(a mismatch, a missing file or a wrong engine version or protocol refuses to run). An unsupported runtime (other OS or CPU, musl) fails withengine_unsupported, which names remote mode (SqlGuardClient).clients/dotnet/build/stage-engines.pystages the output offetch-engine.pyand fails when the.nupkgpasses 150 MB. - Standalone engine binaries for linux-x64, linux-arm64, macos-arm64, macos-x64 and windows-x64 (#69): PyInstaller one-dir builds of
engine --stdio(sqlguardllm, sqlglot and the standard library only) built byscripts/build-engine.pyon a native runner each and accepted only afterhelloand the full conformance corpus pass over stdio (.github/workflows/engine-binaries.yml, also on every pull request touching the engine). Size, cold start and memory inbenchmarks/engine-binaries.json. - Release pipeline for the binaries (#70): on every
v*tag the five archives andSHA256SUMSare attached to the GitHub Release from the same commit as the PyPI release, with build provenance attestations (gh attestation verify); the registries publish only after all binaries passed.scripts/fetch-engine.py <version>downloads and verifies them (checksums, attestations, lockstep version) and fails on any mismatch. Asset names, verification and the client version rule (refuse an engine with another major or protocol version) are indocs/PROTOCOL.md. sqlguardllm engine --stdio: the engine as a child process over newline-delimited JSON (protocol version 1:hello,load_policy,check,explain,shutdown), with the samecheckandexplainbodies as the HTTP server, described byschema/protocol/protocol.schema.jsonanddocs/PROTOCOL.md. The conformance corpus runs over it (#68).- Opt-in audit log of every decision, off by default (#65).
Guard(policy, audit=AuditLog(...))or any callable taking anAuditEvent; sinks for a JSON Lines file, stderr,loggingand OpenTelemetry (sqlguardllm[otel]). Events carry the timestamp, id, version, policy fingerprint, role, outcome, violation codes, tables, normalised-SQL fingerprint, duration and the names of the context keys, never their values.include_sqlisredacted(default, literals replaced by?),noneorraw. A failing sink never allows a rejected query; withstrict=Trueit rejects the query with the new codeaudit_failure. CLIcheck,serveandmcpget--audit-log PATH|-and--audit-sql. Seedocs/AUDIT.md.
sqlguardllm 0.5.0a3
Security release: upgrade if you use dialect="mysql" with hidden or masked columns.
Security
- On MySQL, hidden and masked columns could be read by writing the column name in another case. MySQL ignores the case of column names, quoted or not, but sqlglot's MySQL dialect is case-sensitive (because MySQL table names can be), so with
customers.emailhiddenSELECT EMAIL FROM customerswas allowed, and a maskedPHONEwas neither masked nor refused outside the select list. Hidden and masked columns are now matched case-insensitively in every dialect, which can only reject or mask more. Affects 0.1.0a1 to 0.5.0a2 withdialect="mysql": upgrade. Found by the new fuzzer (#62).
Added
sqlguardllm testchecks declared policy cases and reports results as text or JUnit XML (#66).examples/roles-tests.yamltests every role of the demo policy set, next toexamples/policy-tests.yamlfor the demo policy. CI runs both and lints the demo policies with--strict(#66, #67).sqlguardllm lintwarns about policies that are valid but probably unsafe, with stable codes:no-table-allowlist,tenant-without-row-filter,sensitive-column-exposed,max-rows-disabled,max-rows-high(above 10000 or--max-rows-threshold),aggregate-k-low(k below 5) anddenied-function-allowed. Each warning has an explanation, a fix and a link to its field in the policy reference, in English or Spanish (--language), as text or JSON (--format). Policy sets are linted role by role. The column checks read the policy'sschemaand are reported as skipped without it.--strictexits 1 on warnings (#67).- Policy key
lint_suppress: {code: reason}silences a reviewed lint warning, and the report shows the reason. It is in the policy and policy-set JSON Schemas, unknown codes and blank reasons are rejected, roles inherit and extend it, and checking SQL ignores it (#67). - Property-based fuzzing of the guard, judged by executing every allowed query on canary data (
tests/fuzz/,hypothesis): no value of another role's rows or of a hidden or masked column in the output, the same rows when only secrets change, never more thanmax_rows, no exception fromcheck(), and idempotence. 300 examples on SQLite and DuckDB in every pull request; 20,000 every night on PostgreSQL 16, MySQL 8, SQL Server 2022, DuckDB and SQLite. Failures are minimised intotests/corpus/fuzz_regressions.yaml; statistics inresearch/results/fuzz.json; the oracle and its limits indocs/THREAT_MODEL.md. It also found that DuckDB 2.0.1 drops theLIMITof someLEFT JOINqueries, so theremax_rowsdepends on the engine (#62).
Fixed
check()raised instead of rejecting on some malformed input:RecursionErrorfor deeply nested SQL (thousands of parentheses), andTypeErrorfrom sqlglot's argument checks, which are on wheneverunittestorpytestis imported (a T-SQL query whose nested comments leaveLENwith two arguments). Any such error while parsing is nowparse_error. Found by the fuzzer (#62).
sqlguardllm 0.5.0a2
First release on all three registries at once: PyPI, npm and, for the first time, NuGet.
Added
- Every release now publishes to PyPI, npm and NuGet together with the same version, all with Trusted Publishing.
Fixed
- T-SQL ordered set operations preserve their ordering and use a valid row limit on SQL Server (#92).
- Node.js client: the package declared the MIT license by mistake; it is Apache-2.0 like the rest of the project, and the license file now ships in the package.
- Node.js client:
sqlguardllm/package.jsonis exported, so tools can read the installed version.
sqlguardllm 0.5.0a1
Everything that was planned for other languages and tooling: an HTTP server, official Node.js and .NET clients checked against the same 148-case corpus, a documentation site and a browser playground, plus Policy.from_database, a cost guard for the MCP server and the rest of the warehouse denylists.
Added
- In-browser playground "Try to break it" in
playground/(static site, Pyodide, demo SQLite, gallery presets, two roles, editable policy, shareable URL-fragment links, English/Spanish) with a Playwright test and CI workflow. Not deployed yet (#18). - Documentation site (mkdocs-material, https://jmmana.github.io/sqlguardllm/): quickstart in English and Spanish, rules, a policy reference generated from
schema/policy.schema.json, an API reference from docstrings, threat model, attack gallery and integrations; built with--strictand link-checked on every pull request, deployed to GitHub Pages from main (#14). - Optional cost guard for
sqlguardllm mcp(--max-cost,--max-plan-rows;max_cost/max_plan_rowsincreate_server): runsEXPLAIN(JSON, neverANALYZE) on PostgreSQL and MySQL before a query and refuses plans over the threshold, failing closed if the estimate can't be read; ignored with a warning on other engines.explain_queryreports the estimate (#33). - Cross-language conformance: every attack-corpus case runs through the HTTP server, the Node.js client and the .NET client and must equal the in-process
Guard.checkanswer (conformance/cases.json, aConformanceworkflow,docs/CONFORMANCE.md). The .NET client now sends aContent-Lengthbody, which the server requires (#37). sqlguardllm serve: an HTTP server (GET /v1/health,POST /v1/check,POST /v1/explain) so any language can use the engine as a sidecar, standard library only, optional bearer token, plus aDockerfile; install withsqlguardllm[serve]. Seedocs/SERVER.md(#34).- Official .NET client
SqlGuardLlm(clients/dotnet/, NuGet):CheckAsync,EnforceAsync,ExplainAsyncandHealthAsyncagainstsqlguardllm serve, multi-targeting net8.0 and net10.0, with no dependencies and fail-closed errors. Not published yet (#36). - Official Node.js/TypeScript client in
clients/node(sqlguardllmon npm, not yet published):SqlGuardwithcheck,enforce,explain,healthandwrapfor thesqlguardllm serveHTTP API; zero runtime dependencies, ESM + CJS, fails closed on network errors, timeouts and malformed responses (#35). Policy.from_database(url, include=…, exclude=…, schemas=…, **options): fillstablesandschemaby reading a live database with the SQLAlchemy inspector (new optional extrasqlguardllm[db]). Only names are read, never rows; errors never include the URL (#28).- Denied functions for Snowflake, BigQuery, ClickHouse and Trino, each list linked to the vendor documentation, with a corpus case for every entry (#16). Contributed by @shiwng in #42.
- Integration recipes in
docs/RECIPES.mdwith runnable code inexamples/: a generic DB-API wrapper, SQLAlchemy, LangChain (create_agenttool and langchain-community's toolkit), LlamaIndex, Vanna 2.0 and a pointer to the MCP server. Each is tested with fake model output on SQLite; a Recipes workflow runs them against the framework versions they target. No framework is a dependency (#17). - Performance budget:
benchmarks/bench_check.pytimesGuard.check()on 21 representative queries (median and p95), and a Benchmark workflow fails when a typical query's median is over budget (2 ms on a laptop, 4 ms on GitHub's slower shared runner, where five joins take 3.2–3.4 ms) or a pull request makes a query more than 25 % slower than its base branch (#19).
sqlguardllm 0.4.0a1
An MCP server: any MCP client (Claude Desktop, Cursor, VS Code, agents) gets a database tool that can't do harm. Install it with pip install "sqlguardllm[mcp]".
Added
- MCP server:
sqlguardllm mcp --policy FILE [--role NAME] [--db URL] [--context JSON|@file] [--language es] [--timeout SECONDS](optional extrasqlguardllm[mcp]) gives any MCP client the toolslist_tables,describe_table,explain_queryandquery. Queries go throughGuard.enforce()and run in a read-only transaction with a timeout, always rolled back, returning at mostmax_rowsrows; violations come back as tool errors the model can act on. The context and the database URL never appear in tool output or logs. Setup for Claude Desktop, Cursor and VS Code, and a demo database, indocs/MCP.mdandexamples/mcp/(#31, #32).
sqlguardllm 0.3.0a1
Personal data protection, richer policies and a second security fix. New options are off by default: existing policies behave the same, except that percentage and WITH TIES limits are now capped.
Security
max_rowscould be bypassed with a percentage orWITH TIESlimit.SELECT TOP 50 PERCENT …(SQL Server),FETCH FIRST 50 PERCENT ROWS ONLY(Oracle) andFETCH FIRST n ROWS WITH TIESpassed unchanged, because sqlglot 30 keeps those flags inlimit_options. Such limits are now replaced with a plain limit ofmax_rows. Affects 0.1.0a1 to 0.2.0a2: upgrade. Found while buildingGuard.explain().
Added
masked_columns: a column can be selected but comes back masked (null,redact,hashas SHA-256 hex per dialect,partial), even inside functions orCASE; using it anywhere outside the select list ishidden_column. With the newschemaoption,*over such a table is expanded with the masks (#29).aggregate_only: {table: k}: the table can only be read through aggregates andGROUP BY(new codeaggregate_required), and the guard addsHAVING COUNT(*) >= kso no group smaller than k rows comes back (#30).PolicySet: abasepolicy androlesin one file (PolicySet.from_file), withextendsbetween roles,for_role()and a cachedguard()per role and language. A key set in a role replaces the inherited value; keys underaddextend lists and mappings. Cycles and unknown roles arePolicyError. Example inexamples/roles.yaml; JSON Schema inschema/policy-set.schema.json, printed bysqlguardllm schema --policy-set(#26).Guard.explain(sql, context): anExplanationwith the tables and columns a query reads, the masks, group sizes, row filters and limit it gets, its violations, and a sentence in English or Spanish for UIs and audit logs. Shares one pass withcheck()(#27).