Skip to content

Attack tests on the query guard and on kept columns

Tested 2026-11-21, on the code in free/ (Portward on your computer and the hosted engine). We wrote SQL and tool calls as an attacker would, to break two promises:

  • Read-only. Nothing the AI sends can write, change a setting, call a function with side effects or read outside the tables it is allowed.
  • Kept columns. A column you keep from the AI never reaches it: not by name, not through an alias, an expression, a cast, a subquery, a join, a view, an error message or the database’s own statistics.

This page says what was tried, what broke and was fixed, what is still open, and what Portward does not protect against. A third pass on 2026-11-24 (ticket 106) attacked business tools, file stores and Team scope; it is under Third pass. Every number here is a test in the repository that you can run.

A second pass the same day closed the hole the first run left open (a result’s size in bytes had no limit), two more error messages that could quote a row’s value, and the same faults in the gateway’s separate copy of the guard. It is marked “second pass” below. It ran without database servers: what it still owes against real ones is under What is open.

The guard parses the AI’s SQL with a SQL parser (sqlglot) and refuses anything that is not one SELECT over allowed tables, calling only functions on a list. It then writes the SQL again from the parsed form. What runs on the database is that rewritten SQL, never the text the AI sent. In it, each table is replaced by a subquery that selects only the columns the AI may see, so a kept column does not exist in what the query reads. Postgres and MySQL queries also run in a read-only transaction with a time limit. SQL Server has no read-only transaction, so there Portward refuses a login that can write.

The first run: 912 tests passed, and one more was marked as an expected failure, the open hole. The second pass replaced that one with 5 tests that pass (1 without a server, 4 against real Postgres and MySQL, not yet run there) and added 21 more for the byte budget and the error messages (see The byte budget). The table counts the first run’s attacks: one SQL statement against one engine. Some tests run several.

ClassPostgresMySQLSQL ServerSQLite
Read-only: SQL the guard must refuse174108156
Read-only: the same SQL sent to the server as a login that can write, then the data compared174108
Read-only: the same SQL sent as a login that may move a sequence, then the data and sequence compared156
Read-only: writes sent past the guard, straight to the read-only session66
Comments, quotes, hints and limits: accepted, and what runs is checked91112
Strings that end at another place on the server49
Kept columns: queries that name a kept column or table31313131
Kept columns: queries that read everything9999
Kept columns: ways particular to one engine302220
Kept columns: same answer whatever the kept values are51
Kept columns: same answer in “Claude gets results”, with and without the results panel102
New and renamed columns9
Stand-ins (anonymised columns)191922
Totals-only columns30
Error messages that could quote a value1358
Time limit and row limit2261
Tools: what any tool reply holds4 tests

The read-only SQL covers: writes and schema changes; stacked statements; a write inside WITH; SELECT INTO; COPY, LOAD DATA, INTO OUTFILE; EXPLAIN ANALYZE; SET, RESET and role changes; transaction control; DO, CALL, EXEC, prepared statements; locks; functions that read files, sleep, lock, change settings or run SQL from a string; functions stored in the database; system catalogs and other schemas; table functions, generate_series and recursive WITH; MySQL versioned comments and optimizer hints; SQL Server batches without a semicolon and lock hints; and Unicode look-alikes for semicolons, spaces and keywords. The published bypasses of two other database servers for AI apps (bytebase/dbhub#504, crystaldba/postgres-mcp#178) are among the cases.

Postgres 16, MySQL 8.4 and SQL Server 2022 ran in Docker on the test computer. The tests against them first ran on 2026-11-21, on the first run’s fixed code: 218 passed on Postgres and MySQL and 78 on SQL Server. They skip when no server is running.

Live re-run, 2026-11-21, after the second pass (on main at 56b4409 with the in-image proof’s branch, one database at a time, each container with a memory limit): test_guard_attacks_live.py 122 passed on Postgres 16 and 100 passed on MySQL 8.4.13; test_guard_attacks_sqlserver.py 78 passed on SQL Server 2022. On MySQL the first run was 99 passed and 1 failed: test_a_result_too_large_to_hold_is_refused_not_read selected two columns of one name, which MySQL refuses in the query the guard wraps (“Duplicate column name ‘name’”), so it never reached the budget. That was the test’s query, not the guard; with the columns named apart it passes on both, and MySQL’s hang-up past the budget is now seen against a real server. The same day the built engine image refused a 50 MB result on real Postgres, MySQL and SQL Server and went on answering (docs/design/sources-proof.md). The engines not in the table (Redshift, Snowflake, BigQuery, Databricks, Oracle, files, business apps) were not attacked with the full set; the second pass read each one’s handling of result size and of error messages, and tested what it changed.

Four attacks succeeded in the first run. Each is fixed, and its test stays in the suite. The second pass fixed three more things (5 to 7) and ported the first run’s fixes to the gateway (8).

1. A WITH name that only looked like the table read after it. Fixed in 92ad9aa. The guard matched a table reference to a WITH name without regard to capitals or quotes. Postgres and MySQL do have regard to them. After WITH "PG_STATS" AS (...), a plain pg_stats was the database’s own table to Postgres and a WITH name to the guard, so it was read as it is. On Postgres this reached pg_stats, which holds the most common values of every column the login can read, kept columns among them, and pg_settings. On a connection that runs on profiles it reached any table no profile grants, on Postgres and on MySQL. A WITH name must now be written exactly as it was defined.

2. A string that ended at another place on the server (Postgres). Fixed in 8c3182b. With standard_conforming_strings set to off on the server, the database or the login, Postgres reads \' inside a string as a quote. The guard does not. Text the guard had checked as one string ended early on the server and the rest ran as SQL: any table could be read, and statements ran outside the read-only transaction. The setting has been on by default since Postgres 9.1, so this needed an unusual server. Portward now sets it to on for every query. MySQL’s string modes (NO_BACKSLASH_ESCAPES, ANSI_QUOTES) were tried the same way and did not move a string’s end.

3. A user-defined operator ran its function (Postgres). Fixed in 92ad9aa. The guard refuses functions stored in the database, but a OPERATOR(schema.op) b ran the function behind an operator stored there. With an operator whose function read a kept column, the value came back. OPERATOR(...) is now refused.

4. An error message quoted a row’s value (Postgres). Fixed in 8c3182b. In “I send rows myself” the AI is not sent rows, and Portward keeps the database’s message from the AI when it could quote one. Messages about a mistake in the SQL are passed on. SELECT name::regclass FROM people fails with relation "<the name>" does not exist, which carries the same code as a mistake in the SQL. Such a message is now passed on only when Postgres points at a place in the SQL, which it does for mistakes in the SQL and not for errors raised while reading rows. This never reached a kept column, which a query cannot read at all.

Two more changes came from cases that did not succeed:

  • NEXT VALUE FOR moves a sequence on, which is a write. SQL Server refused it only because of the row limit Portward adds. The guard now refuses it (92ad9aa).
  • An unclosed quote made the parser fail in a way the guard did not catch. It is now a refusal (92ad9aa).

5. A result’s size in bytes had no limit (second pass). Rows were limited (10,000 a result, 200 on Free on the web) and time was limited (30 seconds), but a query can build very large values, for example repeat(name, 100000000). Postgres allows 1 GB a value, and Portward read the whole result into memory. This could stop the engine that runs the query (the hosted engine has 512 MB); it disclosed nothing. On SQL Server one such query returned about 1.8 GB in the first run. Every source now reads its result a row at a time against a byte budget and refuses with “that result is too large to hold; ask for fewer rows or columns, or shorter values”. See The byte budget.

6. Redshift passed on an error that can quote a row’s value (second pass). Redshift had the rule Postgres had before fix 4: any message with a class 42 code was passed on as a mistake in the SQL. Redshift reads rows through a cursor, and runs the query at the first FETCH, so its words are now passed on only when the DECLARE fails (the query is parsed and planned there, and no row is read), and only when every name the message quotes is in the SQL that was sent. Tested with a stand-in for the driver, not against a real Redshift.

7. Files and business apps passed on an error that quotes a row’s value (second pass). They are queried with DuckDB, whose “Not implemented Error” was passed on as a mistake in the SQL. It is also raised while rows are read: sold_at AT TIME ZONE note fails with Unknown TimeZone '<the note>'. That class is now kept from the AI. Found by trying about 60 expressions on DuckDB and 18 on SQLite; no other passed-on message quoted a value. This never reached a kept column.

8. The gateway’s copy of the guard (second pass). The gateway (the Enterprise product, src/portward/guard.py) has its own guard. It accepted OPERATOR(...) and NEXT VALUE FOR, raised an error of its own on an unclosed quote instead of refusing, and its Postgres source passed on every database message and did not set standard_conforming_strings. All four are fixed as in the engine. Its WITH names were already matched exactly (fix 1 was not needed there).

Third pass: business tools, file stores and Team (ticket 106)

Section titled “Third pass: business tools, file stores and Team (ticket 106)”

Tested 2026-11-24 on main at 1698dd5, without servers or vendor accounts. The first two passes attacked database tables. This one attacked what came since: business-app records and file stores (both queried with DuckDB), the scope one teammate gets on a Team engine, and text planted in the data that steers the AI. 151 tests, in free/tests/test_guard_attacks_sources_team.py (149) and free/tests/test_guard_attacks_team.py (2). Business tools are the stand-in HubSpot-shaped and QuickBooks-shaped readers of test_scope_business_tools_files.py, run through the real app base; files are the made-up S3 through the real file-store adapter; Team runs end to end against the real account service and engine host.

ClassTests
A field kept back on levels, read through DuckDB’s own syntax (COLUMNS(*), * EXCLUDE, a table as a value, to_json, UNPIVOT, PIVOT, SUMMARIZE, DESCRIBE, query(), query_table(), duckdb_columns(), lambdas, QUALIFY, POSITIONAL and ASOF joins, sampling, filters and sorts on the field)51
The same 51 against a field kept from one teammate only, with a control that it comes back to the others52
A totals-only amount: no single deal’s amount12
A record rule on one member stepped round through a self-join, a union, a subquery, query() or another case1 (9 queries)
An object kept from a member: its lines (parts) stay kept, by every name and function11
A record rule on an object: its lines are kept whole, never left unlimited10
An object named in another case in the scope1
An instruction planted in a CRM field and in a field’s name1
A file store: a kept column renamed in the file, a file renamed in the bucket2
A file store: two files, or two sheets, that would make one table name; two columns of one name5, and 1 control
A forged or look-alike folder or workbook1
A scoped member’s run of a verified answer1
Team: another member’s result id through every tool that takes one, for a member and for the admin1 (13 calls each)
Team: a member steered by an instruction in a cell calls every tool that could widen or narrow anyone1

9. A file store numbered a second table or column of the same name. Fixed in file_stores.py. In a bucket (S3, Cloud Storage, Azure), two named files that make one table name (hr/salaries.csv and public/salaries.csv), two sheets of a workbook (Pay and pay ), or a sheet and a file, became salaries and salaries_2, numbered by the order of the Files list or of the workbook’s sheets. A header with one name twice (Email and email) became two columns numbered by their order. A rule names a table and a column, so when the order changed (an admin put another file first, someone added a sheet before the kept one, or swapped two columns), the rule stayed on the name and moved to other data, and the kept data came back under a name no rule covered. Google Drive, OneDrive and SharePoint already refused this (#178 review H1); a bucket now refuses it the same way, naming both, and also refuses a column that has data and no name. Tests: test_attack_two_files_that_would_make_one_table_name_are_refused_not_numbered, test_attack_two_sheets_of_a_bucket_workbook_that_would_make_one_name_are_refused, test_attack_two_columns_of_one_name_are_refused_not_numbered.

10. The panel’s “Set this level” opened another member’s result (Team). Fixed in hosted/level_tools.py. set_level read the result from the panel’s store before any check of whose it was. Another member got “no column …” for a column the result lacked and the admin check for one it had, so the columns of a teammate’s result could be told; an admin could narrow a level from a member’s result. Every other tool that takes a result id answered “no pull with that id”. set_level now does too.

11. Another member’s result id was told apart from a made-up one (Team). Fixed in pulls.py. more_rows and the panel’s tools said “no pull with that id” for a teammate’s id and “isn’t held in this session” for an id that was never made, so an id could be confirmed as real. On a workspace engine every result is saved before it is held, so an id with no saved result is now answered as a teammate’s is. No values were ever sent.

12. One member’s narrower result held a verified answer back from everyone (Team). Fixed in verified.py. A verified answer is held back from the AI once a run’s result differs from the verified one, which means the data changed. A member with a row rule or a kept table gets a different result by design, and their run (from list_sources’s re-check or run_verified_answer) was kept for the whole connection, so the answer was held back from every member and the admin until someone without a scope ran it. It disclosed nothing. A narrowed member’s run is no longer kept; they are still told whether their own result matches. Test: test_attack_a_scoped_members_run_doesnt_hold_a_verified_answer_back_from_everyone.

  • No DuckDB form reached a kept field, a field kept from one teammate, or a single totals-only amount. Most are refused by the guard (DuckDB’s star forms and table functions are not on its list); the rest run on the subquery of allowed columns and return nothing kept.
  • An object kept from a member keeps its lines from them under every spelling and function, and a record rule on the object keeps its lines whole rather than unlimited, on levels and on block rules.
  • A kept column renamed in the file, a file renamed in the bucket, and a field that appears in a business tool after setup are new to Portward and held until someone reviews them; a header in another case is the same column and stays kept.
  • A folder or workbook is matched only by its exact key from the page that was drawn: a look-alike, a .. path, another case or a table name passed as a workbook is refused whole.
  • Text planted in a record, a cell or a field’s name comes back as a value. A member’s AI app that obeys it is refused by every tool it names (give_back_teammate, narrow_teammate, draft_wider_levels, narrow_levels, use_levels, set_level); nothing is drafted, no teammate is narrowed, no level or rule changes.
  • No real vendor. Every business-tool and file-store attack ran against stand-ins of the vendors’ replies. The guard and DuckDB are the real ones; a real vendor’s field names and types were not tried.
  • The data’s own authors. Whoever can edit a file or a CRM record can put a kept value in a column the AI may read. Portward keeps columns by name, not by what is in them.
  • Text planted in data steers the AI. Portward can’t stop an AI app from following it; it makes sure nothing the AI can call widens what anyone gets, and that a member can’t change anyone’s scope.

Fourth pass: team admin asked for in chat (tickets 79 and 80)

Section titled “Fourth pass: team admin asked for in chat (tickets 79 and 80)”

Written 2026-11-25 on branch rm/team-admin-view, built behind the Team switch (off on the live service), for the three tools a workspace’s engine gains (team_admin, invite_teammate, remove_teammate) and the three account service routes they call (/v1/workspace-engine/team, /invite-draft, /remove). End to end against the real account service and engine host, as the third pass’s Team tests. Run 2026-11-25 at the batch gate (rm/batch-2026-11-25b, the three Team branches with main merged in): every test below passed on its first run, and so did the cross-source guard tests that came with ticket 103 (test_cross_source_guard.py). Nothing in the guard was changed. Seven functional tests failed on that run; each was the test, not the guard: the view’s test read the shared panel script (which carries the usage question for every panel), split the drafts section at a repeated heading, and expected a reply without the runs_this every reply carries; the link tests linked a column the workspace keeps from everyone, which correctly can’t be linked (D-186). The tests were corrected and pass.

ClassTests
A member calls each admin tool, and an admin demoted a moment ago calls the three new ones in the same session2 (test_team_admin_view.py)
A member steered by an instruction in a cell also calls team_admin, invite_teammate and remove_teammateadded to the third pass’s steered-member test
An admin steered by an instruction in a cell invites an outsider, removes another admin and themselves, and opens the view1 (test_guard_attacks_team.py)
Another workspace’s engine names that workspace’s admin on each route, and removes them naming its own admin1 (test_control_workspace_attacks.py)
A member’s own program adds a role, an admin flag or another asker to the body, or sends ids of the wrong shape1 (test_control_workspace_attacks.py)
Drafting the same address again and again to go round the invitation limits or have someone emailed1 (test_control_workspace_attacks.py)
A made-up engine token, and every route with the Team switch off, answered alike2 (test_control_workspace_engine_admin.py)

What each is meant to show: the role is asked of the account service before every call and read from its store again on its routes, so nothing a caller adds makes them an admin; another workspace’s people are answered as strangers; an invitation by asking is only a draft, sent by an admin’s tap on the Team page and counted against the page’s own limits; removing by asking takes members only, never an admin or the asker (D-184); the view carries names and counts only, never the planted text or a value.

Still open: a steered admin’s AI app can remove an ordinary member at once. That is narrowing (ADR-0026 rule 2), written to the audit log as “asked in chat”, and undone by inviting them again.

A result may hold 32 MB, measured as the values take up in the engine’s memory. The hosted engine has 512 MB; 138 MB is in use with nothing held (measured in docs/design/app-records-memory.md), and a result is in memory three or four times while a question is answered (the driver’s copy, the rows, the reply), so 32 MB costs at most about 130 MB and leaves room for a second question at the same time. This was reasoned from those numbers, not measured on an engine, and not together with business-app records held at their own cap (up to 464 MB in that document), where there is less room. 10,000 rows of about 50 short columns fit. One row (Postgres) or one value (SQL Server, SQLite) may be 8 MB, a quarter of that, where the database itself can be made to refuse a larger one before sending it. The numbers are MAX_RESULT_BYTES and MAX_ROW_BYTES in free/src/portward_free/sources/base.py. A result over the budget is refused whole, never cut.

“Before it arrives” below means the engine never holds the oversized row or value. “As it arrives” means the driver has received a row before Portward can count it, so one row can pass the budget before the refusal.

SourceHowAn oversized row or value is refused
PostgresThe database measures each row and fails the query on one over 8 MB. Rows are read as a stream; past 32 MB the query is cancelled.Before it arrives
MySQLThe bytes the server sends are counted before each piece (16 MB at most) is read; past 32 MB Portward hangs up. Rows are also counted as they are read.Before it arrives
SQLiteSQLite’s own length limit is set to 8 MB, so it refuses to build or read a longer value. Rows are counted as it steps to each.Before it arrives
SQL ServerThe server sends at most 8 MB of any one long value (SET TEXTSIZE); a value that long is refused, since it may have been cut. Rows are counted one at a time.A value: before. A row of many long values: as it arrives
OracleAlready had: 32 MB on the connection’s wire, 64 MB of rows.Before it arrives
Snowflake, BigQueryAlready had: each reply is capped (2 MB a page; 16 MB a Snowflake partition unpacked), 32 MB a result.Before it arrives
RedshiftAlready had: rows through a cursor, one row first, 32 MB a result. Redshift limits a value to 16 MB.As it arrives (16 MB at most)
DatabricksAlready had: 4 MB asked for per fetch, 32 MB a result, and REPEAT and its kind limited to 10,000.As it arrives
Files and business apps (DuckDB)DuckDB’s memory limit bounds what a query can build (128 to 256 MB on the hosted engine, 1 GB on your computer). Rows are counted one at a time as they are handed over.As it arrives, inside DuckDB’s limit

What this changes for an ordinary question: a result over 32 MB is refused where it used to be read, and on Postgres, SQLite and SQL Server a stored value over 8 MB (2 million characters on SQL Server) can no longer be read through Portward at all. On SQLite, printf asked for a text over the limit gives NULL instead of an error; that is SQLite’s own behaviour.

Tests, all without a database server, with small budgets set in the test and no large value ever built: 18 in free/tests/test_result_bytes.py (the budget, SQLite, a CSV file, a business app’s records, Postgres with a stand-in for the connection, MySQL with the real driver reading a server’s bytes from a buffer), 2 in test_sqlserver.py, 1 in test_guard_attacks.py, and Redshift’s own from before. The Postgres source was also run by hand against a local Postgres 16 with SQL that reads no table: the measuring query, a refused row, a cancelled stream and the next query on the same connection all behaved as the tests say.

  • Runs against real servers for the second pass: done on 2026-11-21 for Postgres, MySQL and SQL Server (the re-run above: 122, 100 and 78 passed). Still owed: Redshift’s new error rule rests on Redshift running a cursor’s query at the first FETCH, which its documentation says and no test here has checked.
  • SQL Server: one row of many long values. Each value is at most 8 MB, but a row can hold many, and the driver receives a whole row before Portward counts it. SQL Server has no way to measure a row that Portward could add to any query.
  • The gateway has no byte budget. Its sources read a whole result into memory, as the engine’s did. It runs in the customer’s own cloud, on a machine the customer sizes.
  • The gateway’s other sources pass on the database’s words. Only its Postgres source got the rule of fix 4. Its MySQL, SQL Server, Oracle, Redshift, Snowflake, BigQuery, Databricks and file sources still pass a failed query’s message on. Not assessed here: how much such a message can quote that the AI could not read anyway. A hidden column is read as tokens there, so its real values are not in reach of a failed cast; rows kept back by an access rule and total-only columns were not checked.
  • The engines outside the first run’s table were still not attacked with the full set. Files and business tools (DuckDB) were attacked for kept fields, parts and totals in the third pass; Redshift, Snowflake, BigQuery, Databricks and Oracle were not.
  • Every read-only attack was refused by the guard on all three engines. The data, the tables and the sequences were the same afterwards, with the attacks sent as a login that can write (Postgres, MySQL) or move a sequence (SQL Server).
  • Writes sent straight to the Postgres and MySQL sessions, as if the guard had let them by, were refused by the read-only transaction.
  • Text hidden in comments did not run. The guard writes comments again with */ broken up, and a MySQL versioned comment (/*!50000 ... */) comes out as an ordinary comment. Quotes inside names are doubled in the engine’s own way. SQL Server lock hints are taken off.
  • No query that named a kept column or table ran, and none brought a kept value back, on any engine. Queries that read everything (*, whole-row values, row_to_json, joins, unions) returned every column but the kept one.
  • Views and functions stored in the database that read a kept column could not be reached while the connection had a kept column. Statistics, index definitions and information_schema could not be read.
  • What the AI was given was the same, byte for byte apart from the result’s id, on two databases that differed only in their kept values. This held for failing queries, and in “Claude gets results”, where the SQL is run a second time for your own panel with the kept columns in.
  • A column added after you last looked at a connection, and a new table, stayed kept. A kept column that was renamed kept its whole table from the AI.
  • An anonymised column came back only as stand-ins, through every expression tried. A real value in a filter matched nothing. The key could not be read back from the session.
  • A totals-only column gave no single value, and a total over fewer than 5 rows was left out, also when a join repeated one row.
  • The time limit stopped a long query and the row limit cut a large result on all three engines.
  • No tool reply held a kept value, a file path or a login. Rows read before a column was kept were not sent again after it was kept.
  • Differencing two totals. SUM(salary) for everyone and for everyone but one person gives that person’s salary. A test in the suite shows it. Use a stand-in or keep the column if a value must never be inferred.
  • Counting stand-ins. The same value always gets the same stand-in, so the AI can see how often each occurs and which rows share one. Someone who knows the most common value can guess its stand-in.
  • The same value somewhere else. If another column, table or view the AI may read holds the kept value, the AI can read it there. While a connection has no kept column or blocked table at all, views are readable.
  • Names. With block rules the AI is told the names of kept columns and blocked tables, never their values. On profiles they are hidden, but the AI can still test whether an object of a given name exists (a cast to regclass on Postgres, OBJECT_ID on SQL Server). It can read the database’s version, the login’s name and the database’s name.
  • What your database itself defines. An operator or cast you defined that takes the place of a built-in one for some type runs when a query uses it. A function of yours with the same name as a common SQL function the guard allows could be called. Neither was tested beyond the OPERATOR(...) case above.
  • Heavy queries inside the limits. A query may use the database for up to 30 seconds. Portward does not limit how many run one after another beyond the weekly question limit on Free. The byte budget protects the engine, not your database: a query that builds large values still builds them there before Portward refuses the result.
  • Timing. Portward’s replies carry no timings. In “Claude gets results” the second run for your panel reads kept columns, so how long a reply takes can depend on kept values. An AI app that shows its model how long a tool call took would let the model measure it.
  • A second statement at the protocol level on Postgres and SQL Server. The guard refuses a second statement, and MySQL’s protocol refuses one too. On Postgres and SQL Server the protocol does not. Before fix 2, a statement that got past the guard on Postgres could end the read-only transaction and start one that writes. A login that can only read is the control that does not depend on the guard. Portward warns when a Postgres or MySQL login can write, and refuses one on SQL Server.
  • The AI app. Tools only the results panel may call are marked so, and the AI app is what stops its model from calling them. Portward cannot tell the two callers apart.
Terminal window
cd free
docker run -d --name portward_pg_test -e POSTGRES_PASSWORD=pw -p 127.0.0.1:15432:5432 postgres:16-alpine
docker run -d --name portward_mysql_test -e MYSQL_ROOT_PASSWORD=pw -p 127.0.0.1:13306:3306 mysql:8
docker run -d --name portward_mssql_test -e ACCEPT_EULA=Y -e 'MSSQL_SA_PASSWORD=Portward!Test1' \
-p 127.0.0.1:14333:1433 mcr.microsoft.com/mssql/server:2022-latest
uv run --frozen --all-extras pytest -q tests/test_guard_attacks.py tests/test_guard_attacks_live.py \
tests/test_guard_attacks_sqlserver.py

test_guard_attacks.py needs no database server. The other two skip when their server is not running. The attack SQL is in tests/guard_attack_cases.py. The tests make their own database, pwfree_attacks, and change nothing else.

The byte budget and the error messages of the second pass, without any server:

Terminal window
cd free
uv run --frozen --all-extras pytest -q tests/test_result_bytes.py tests/test_guard_attacks.py \
tests/test_sqlserver.py tests/test_redshift.py

The third pass (business tools, file stores, Team), without any server:

Terminal window
cd free
uv run --frozen --all-extras pytest -q tests/test_guard_attacks_sources_team.py tests/test_guard_attacks_team.py

The gateway’s guard and its Postgres source, from the repository’s root:

Terminal window
PYTHONPATH=src python -m pytest -q tests/test_guard.py tests/test_guard_aggregates.py tests/test_postgres_source.py

Run one test command at a time. The byte-budget tests set small budgets (a few thousand bytes) and never build a large value, so they are safe on a small machine; to see a real refusal against a real server, start the containers above and run tests/test_guard_attacks_live.py -k "too_large or past_the_budget".