How to Configure OpenHands MariaDB Credentials
You set up openhands mariadb credentials by passing a scoped database user into the agent workspace. This setup lets the coding agent run queries without holding full admin rights. Many teams start by giving the agent a shared root login to move fast. That broad role lets a single bad query drop tables or read private rows. How openhands mariadb credentials work in agent setups OpenHands runs tasks inside an isolated workspace where it writes code and runs shell commands. When the agent needs
Ephemeral Credentials + End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up openhands mariadb credentials by passing a scoped database user into the agent workspace. This setup lets the coding agent run queries without holding full admin rights. Many teams start by giving the agent a shared root login to move fast. That broad role lets a single bad query drop tables or read private rows.
How openhands mariadb credentials work in agent setups
OpenHands runs tasks inside an isolated workspace where it writes code and runs shell commands. When the agent needs to check a schema or test a query, it reads local variables. Teams pass the database host, port, user name, and secret key into that workspace.
On the database side, MariaDB checks who logs in and what tables they can touch. A good setup creates a dedicated database user just for the coding agent. You grant that user read rights on test tables and block access to core system schemas. You also restrict the host address so the account only accepts traffic from the agent network.
Next, you load the secret key into the agent container at startup time. The agent reads these values from its local workspace and opens a client session. MariaDB checks the secret key against its internal grant tables before allowing any query to run. If the host and key match, the database opens a session with those preset table rights.
Where native database roles fall short for coding agents
Native MariaDB roles do a great job of deciding who can log into the server. They also block an agent from touching schemas outside its assigned grant list. For basic read tasks on fake test data, this built-in role model works well.
The gap appears once the agent starts running live queries inside an allowed table. MariaDB grants work at the table or column level, not on the meaning of each command. If an agent needs write rights to fix a bug, it can also delete every row. The database cannot tell a safe one-row update apart from a broken full-table wipe.
Static secrets inside the agent workspace also create a clear risk for engineering teams. Because the agent can run shell commands, a confused model might print its own secret keys. Those keys then sit in plain text inside agent logs or issue trackers.
Ephemeral Credentials + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Read queries carry risk as well when tables hold real user rows. If an agent queries a customer table to debug an issue, it pulls back raw fields. Emails, phone numbers, card numbers, and national IDs flow straight into the model prompt context. Native database grants cannot rewrite matched fields in results on the fly during a query.
Steps to tighten agent database sessions
Start by splitting agent duties into separate read and write database accounts. Give your default agent setup the read-only account for daily code checks and schema lookups. Only load the write account when a specific task requires data changes or schema migrations.
You should also set resource limits on the MariaDB account used by the agent. MariaDB lets admins cap the number of queries and sessions an account can run per hour. These caps stop a runaway agent loop from taking down the database server.
Finally, rotate the secret keys given to your coding agents on a regular schedule. Short key lifetimes limit the damage if a secret ever leaks into a build log. When you combine tight table grants with query caps, you lower the risk of automated runs.
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
Should an OpenHands agent use the same MariaDB login as the main app?
No, the agent should always have its own separate MariaDB user account. A separate account lets you limit table rights and track agent queries in your logs.
How do I stop an OpenHands agent from reading sensitive user columns?
You can restrict column rights in MariaDB or use database views that leave out private fields. For live queries on full tables, data masking rewrites matched fields in results like emails and phone numbers.
What happens if an agent enters an infinite loop while querying MariaDB?
An unchecked loop can max out CPU and lock up tables for other users. Setting per-hour query limits and statement timeouts on the MariaDB user stops runaway loops fast.
Related guides
In this post