How to Configure Goose MariaDB Least Privilege
You set up goose mariadb least privilege by creating a restricted database user. Then you limit that user to specific tables and read-only SQL actions. Many engineering teams connect AI agents to databases using shared admin credentials. This shortcut speeds up early testing, but it creates a huge security risk. An AI agent with broad rights can drop tables or alter production rows. It can also pull sensitive customer records into its local context window. Scoping the database account down to ex
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You set up goose mariadb least privilege by creating a restricted database user. Then you limit that user to specific tables and read-only SQL actions. Many engineering teams connect AI agents to databases using shared admin credentials. This shortcut speeds up early testing, but it creates a huge security risk. An AI agent with broad rights can drop tables or alter production rows. It can also pull sensitive customer records into its local context window. Scoping the database account down to exact needs prevents most accidental damage.
How goose mariadb least privilege works in practice
Goose runs as a local developer agent that executes tasks on your machine. It connects to external tools and databases to read context and run queries. When Goose connects to MariaDB, it uses standard database credentials to log in. MariaDB checks the account name and host before it allows any query.
To enforce least privilege, admins build a dedicated database role for the agent. You grant this role select rights only on the schemas the agent needs. You never grant drop, alter, or delete rights to an automated coding agent. If the agent needs to write data, you restrict writes to staging tables.
You can also use MariaDB views to hide sensitive columns from the agent. A view lets the agent query safe columns while omitting password hashes. Admins also set resource limits on the MariaDB account to stop runaway queries. This prevents a bad prompt from locking up database memory or CPU.
What native database roles solve and what they miss
Native MariaDB roles do a great job of blocking unauthorized schema changes. They stop the agent from reading tables outside its assigned project boundary. They also give database admins a clear way to group permissions by job.
Still, static database roles only check who logs in at the start. They do not inspect what individual queries do in flight during a session. Once the agent has select rights on a table, it reads every row. If that table holds emails, phone numbers, or card numbers, the agent gets them. Static roles cannot rewrite matched fields in results before they reach the model.
Least Privilege Principle + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native roles also leave local secrets exposed on the developer machine. Goose still needs a password or key stored in a local file. If that secret leaks, an attacker gains the same database access right away. Finally, standard database logs only show the shared agent account name. Teams struggle to tie a specific AI query back to the human user.
Managing agent sessions and sensitive data
Running AI agents safely in production requires controls that act on each query. Teams need a way to link every agent action to an individual developer. When an agent wants to run a risky command, a human should approve it. This stops bad writes before they ever touch the MariaDB storage engine.
Data masking is another key piece of safe agent database access. When an agent queries a user table, masking rewrites matched fields in results. Sensitive values like national IDs turn into safe placeholders while queries still work. The agent finishes its task without pulling raw personal data into its prompt.
Check MySQL queries and results on the wire
MySQL grants control who logs in. They do not check single queries or mask sensitive columns once a session starts. With hoop.dev, you run an open-source proxy, a sidecar for your MySQL. It runs next to MySQL, RDS, or Aurora and reads the MySQL wire protocol.
Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails. When a rule refuses a query, MySQL returns a native error packet with your message. On the response path, hoop.dev data masking rewrites string values in returned rows that match your rules. Every query and decision is logged per resource. See the MIT-licensed project on GitHub.
Frequently asked questions
Why should Goose use a separate MariaDB account?
A separate account isolates the AI agent from human developer permissions. It lets you restrict the agent to safe read queries and track its actions.
Can MariaDB roles block an agent from reading specific columns?
Yes, MariaDB supports column-level select grants and custom SQL views. Still, managing column grants across hundreds of tables takes a lot of manual work.
What happens if an AI agent runs a slow query in MariaDB?
A bad query can use up CPU and lock tables for other users. You should set query timeouts and account resource limits in MariaDB to prevent this.
Related guides
In this post