How to Configure OpenHands MariaDB Guardrails
You set up openhands mariadb guardrails by pairing strict database roles with agent container rules. This setup stops your AI agent from dropping tables or reading private rows. Most engineering teams start by giving the agent a shared database login. The agent uses this login to read schemas, test queries, and fix bugs. Shared logins often hold broad write rights across the whole database. A single bad prompt or model error can then wipe out real data. Setting up clear boundaries early keeps y
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 openhands mariadb guardrails by pairing strict database roles with agent container rules. This setup stops your AI agent from dropping tables or reading private rows.
Most engineering teams start by giving the agent a shared database login. The agent uses this login to read schemas, test queries, and fix bugs. Shared logins often hold broad write rights across the whole database. A single bad prompt or model error can then wipe out real data. Setting up clear boundaries early keeps your data safe while the agent works.
How native openhands mariadb guardrails work
A strong setup begins inside your database server. You create a dedicated database user just for the OpenHands agent. You then assign narrow rights to that user role. The role should only read or write to specific test tables. You can block commands that drop tables or alter schemas at the role level. MariaDB also lets you set resource limits on that specific account. You can cap the number of queries the agent runs per hour. You can also limit how many connections the agent opens at one time.
Next, you lock down the container where the OpenHands agent runs. The agent executes tasks inside an isolated workspace. You pass the restricted database login into this workspace as secret variables. Network rules on the host should only allow traffic to the test database port. This stops the agent from reaching other internal services on your network. You can also turn on native database audit logs to track agent actions. The database writes every login attempt and query into a local log file. Your security team can read these files later to check what the agent did.
What native database controls solve and what they miss
Native database roles and container network rules solve the basic access problem. They make sure the agent logs in with a known, limited account. They block the agent from touching tables outside its assigned schema. Resource limits also stop runaway loops from crashing the database server.
AI Guardrails + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Still, static database roles only check who logs in and which tables they touch. They cannot check the intent of an individual query in flight. If the agent needs write access to fix data, it can still delete rows. A valid update query without a filter clause can overwrite an entire table. Native roles also return raw table values for every allowed read query. If a table holds emails, phone numbers, or card numbers, the agent gets them. Those private fields then flow straight into the agent logs and model prompts. Storing static database passwords inside the agent workspace creates another risk. If the agent prints its system variables, those passwords appear in plain text. Teams must rotate passwords and check log files across many servers by hand.
How to review and test your agent database rules
Before you let the agent run tasks, you should test every rule by hand. Log in with the agent account and try to read blocked tables. Run a test query that tries to drop a table or change a user role. The database should reject both actions right away. You should also check that your query time limits kill slow searches. Good testing finds gaps in your database roles before the agent starts work.
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
Can native MariaDB roles block single row deletes while allowing updates?
Yes, MariaDB lets you grant update rights without granting delete rights on a table. Still, a bad update statement can still overwrite every row with blank values.
How do you stop an OpenHands agent from reading sensitive columns?
With native tools, you can grant read access only to safe columns or views. To rewrite emails or phone numbers in query results dynamically, you need data masking.
Where should you store MariaDB credentials for OpenHands?
Never hardcode database passwords inside prompt files or code repos. Pass secrets into the isolated workspace at startup, or remove static credentials from the workspace.
Related guides
In this post