SQL Agent Guardrails: 8 Attacks Tested (DuckDB, Python)
A read only database stopped three of eight attacks on my SQL agent. The other five needed other layers.
Video #37 ยท AI agents and MCP
Steps in the video
Files
- agent.py (35 lines)
- attack.py (62 lines)
- guard.py (41 lines)
- layers.py (53 lines)
- shop.py (13 lines)
Tested with
Python 3.12.15 | duckdb==2.0.0
What this does not show
The model is a stand-in that returns fixed SQL, so no real model is tested. Eight attacks, not every attack. DuckDB's settings are defence in depth, not a sandbox, and the timer is best effort. One DuckDB version, on Windows. The shop, the data and the secret file are made up.
Sources
Learning IT by Example.