A team let an AI agent attack our guardrail for AI agent writes
Brahma red-teamed open-source Databricks write guard bricksentry up to version 0.1.31, exposing preview leaks, tag injection, and diff bugs across 1B rows.
In short
Databricks data engineers and AI agent platform teams · 264 s full diff on 1 billion rows; 0.1.31 latest fix · Open-source package on PyPI for Databricks and MCP · Install from PyPI and review VALIDATION.md failures
By Dillip Chowdary • Dec 03, 2026 • Source: bricksentry.org

At a glance
- Who it is for
- Databricks data engineers and AI agent platform teams
- The number
- 264 s full diff on 1 billion rows; 0.1.31 latest fix
- Available
- Open-source package on PyPI for Databricks and MCP
- What to do
- Install from PyPI and review VALIDATION.md failures
- Report date
- November 30, 2026
- Test scale
- 200,000-row HR table; up to 1B synthetic rows
In this post
In bricksentry.org's report published on November 30, 2026, developer Brahma detailed a two-week red-team test of the open-source Databricks write guardrail bricksentry through version 0.1.31 against a 200,000-employee HR table.
Data engineers and platform teams running AI agents on Databricks can use these findings to audit table write controls before production rollout. They can install bricksentry from PyPI, review every logged failure in the repository's VALIDATION.md file, and apply policy rules to agent SQL writes.
01How bricksentry checks agent writes
An agent invokes bricksentry over MCP or from Python by passing a SQL statement and a target table name. Instead of letting the statement touch production data, the tool runs the query against an isolated copy and returns only row counts and a deterministic verdict. The agent never sees actual table rows, and no language model decides whether a change passes.
- Parse allowlist Check every table read by the SQL statement against the agent_tables allowlist.
- Clone target Create a shallow Delta clone of the target table by copying metadata rather than data.
- Execute write Run the proposed write statement on the clone so production stays untouched.
- Diff versions Compare the clone against production by key at fixed table versions for added, removed, changed, or duplicate rows and shifted totals.
- Check lineage Look up downstream tables, dashboards, and jobs through Unity Catalog lineage.
- Apply policy Evaluate deterministic policy file rules to assign a verdict of pass, warn, needs_human, or block.
- Return verdict Send counts and the verdict back to the agent and drop the clone.
Because Delta shallow clones copy only metadata, the isolation step stays lightweight during normal checks. Every rule outcome is repeatable for identical inputs because the policy file replaces model judgment. That deterministic design is what Brahma set out to stress-test on a live workspace.
02Databricks Free Edition test setup
Brahma conducted all testing over two weeks in November on a Databricks Free Edition serverless workspace backed by a single 2X-Small SQL warehouse. The target workload was an HR pipeline whose primary table holds 200,000 employee records. Rather than testing unreleased local code, every round installed the published bricksentry package directly from PyPI.
Databricks' Genie Code assistant executed test steps across the workspace and acted as the automated attacker during red-team rounds. Strict workspace rules kept production tables read-only while routing all writes to clones or a scratch schema dropped after each run. Before and after every round, DESCRIBE HISTORY checks verified that no other table state had changed.
03SQL preview and allowlist bypasses
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
The first major flaw turned preview_write into an unintended read API because it returned sample diff rows. An agent lacking table permissions could issue a mock update on sensitive fields like social security numbers and read back the original values without writing anything. Version 0.1.27 restricted agents to counts only, hid totals on single-row tables, and masked values in engine errors while keeping examples for human reviewers.
Round 9 exposed a second leak when the agent_tables allowlist checked only the target write table. Unlisted tables referenced in subqueries, MERGE sources, INSERT SELECT statements, or comparison targets still leaked row counts to the agent. Version 0.1.28 added full sqlglot parsing so every referenced table must appear on the allowlist and unparseable SQL is refused.
Round 10 threw 13 Spark grammar, identifier, and comment-splitting attacks like FR//OM at the parser, and all 13 were refused. However, version 0.1.29's follow-up round showed that serverless query plans still hid forbidden tables inside listed views and SQL functions. Brahma fixed that gap by recursively inspecting view definitions and function bodies from Unity Catalog.
04Metadata injection and diff bugs
Adding Spark's EXPLAIN EXTENDED plan check as a hard gate initially broke legitimate agent MERGE operations because serverless plan formats vary. Brahma relaxed the gate so it blocks only when a readable plan exposes an unlisted table, leaving the parser as the primary control. In Round 9, a prompt injection planted in a Unity Catalog tag also reached the agent verbatim, prompting bricksentry to mask free-text tags as [text hidden: 97 chars] while keeping short tags like pii and requiring a token for non-localhost HTTP MCP servers.
While fixing another bug, Brahma found that a hand-written scanner treated -- inside quoted strings as a comment, hiding trailing statements like ; DROP TABLE other until version 0.1.31. Correctness bugs in versions 0.1.24 through 0.1.27 also skewed counts in both directions. A skipped checksum missed 1,895 changed rows during a schema change, duplicate NULL key pairing turned 2 changes into 36,563 across 50,000 rows, and unpinned diffs reported 49 of 50 mid-run edits before version pinning was added.
05Scale benchmarks and builder takeaways
Synthetic benchmarks on the Free Edition 2X-Small warehouse tested full keyed diffs of a 20% update across up to 1 billion rows. Processing time grew slower than row count, and 10% sampling offered no savings at 10 million rows but ran 2.8 times faster at 1 billion rows with repeatable samples.
| Table size | Time | Result |
|---|---|---|
| 100 million rows | 49 s | 20,000,000 rows, 20.00% |
| 500 million rows | 136 s | 20.00%, undo correct |
| 1 billion rows | 264 s | 20.00%, undo matched time travel |
Note: The scale tests used narrow synthetic tables measuring 1.8 GB at 500 million rows and 3.5 GB at 1 billion rows, so wider production tables will take longer.
Brahma's closing guidance urges guardrail builders to treat every output, timing signal, error, and metadata tag as an untrusted read path or prompt input. Parsers should fail closed on unreadable SQL, while engine plans work best as a secondary check rather than a brittle hard gate. Finally, teams should test under-reporting cases deliberately, favor over-reporting over silent misses, and publish every failure openly.
Frequently asked questions
How does bricksentry prevent an AI agent from reading restricted Databricks tables?
It parses every SQL statement with sqlglot, requires all referenced tables, views, and SQL functions to be on the agent_tables allowlist, and returns only row counts and a deterministic verdict. Since version 0.1.27, agents no longer receive example diff rows, one-row totals, or unmasked error values.
What happened when Genie Code tried to bypass the SQL parser in Round 10?
All 13 attacks using Spark-specific grammar, identifier tricks, and split keywords like FR//OM were refused, with unreadable queries failing closed. Follow-up testing still uncovered hidden table reads inside views and SQL functions, which led to recursive Unity Catalog checks in version 0.1.29.
How fast does bricksentry diff large Delta tables?
On a Databricks Free Edition 2X-Small SQL warehouse, a full keyed diff of a 20% update took 49 seconds at 100 million rows, 136 seconds at 500 million rows, and 264 seconds at 1 billion rows. Sampling 10% of rows ran 2.8 times faster at 1 billion rows.
How did bricksentry fix prompt injection and MCP authentication risks?
After Round 9 injected instructions through a Unity Catalog tag, bricksentry replaced free-text tag values with [text hidden: 97 chars] while preserving short tags such as pii. It also blocked non-localhost HTTP MCP servers from starting without an authentication token.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement