How to Configure OpenHands MariaDB Least Privilege
To set up openhands mariadb least privilege, create a dedicated database user with scoped permissions. Then bind that account to your agent container and block root access. Many teams give autonomous coding agents a shared admin key to move fast. Broad permissions let a single bad prompt drop tables or leak private rows. How openhands mariadb least privilege works in practice OpenHands runs tasks inside an isolated workspace container to write code and fix bugs. When the agent needs database
Least Privilege Principle + End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
To set up openhands mariadb least privilege, create a dedicated database user with scoped permissions. Then bind that account to your agent container and block root access. Many teams give autonomous coding agents a shared admin key to move fast. Broad permissions let a single bad prompt drop tables or leak private rows.
How openhands mariadb least privilege works in practice
OpenHands runs tasks inside an isolated workspace container to write code and fix bugs. When the agent needs database state, it uses standard client tools inside that workspace. MariaDB checks user rules at login based on the username and source host. You build least privilege by matching those database rules to the exact agent task.
Start by creating a separate MariaDB account just for the OpenHands agent runtime. Never let the agent share credentials with your main backend app or human engineers. Next, restrict the host definition so the account only logs in from the workspace network. This step stops an exposed key from working outside your internal network.
After you lock down the host, grant only the exact privileges the agent needs. For bug checks or schema reviews, give the account read permissions on specific tables. If the agent must test migrations, grant write rules only on a scratch schema. MariaDB also lets you grant read access to single columns instead of full tables. This keeps the agent away from secret columns while it inspects general app data.
What native database roles solve and what they miss
Native MariaDB roles do a great job of blocking unauthorized schema changes and deletes. If OpenHands tries to drop a production table, the database engine rejects the command. You can also set native resource limits on the agent account in MariaDB. Setting query count limits and connection caps stops a looping agent from causing outages.
Still, static database roles only decide who logs in and which tables they touch. They cannot inspect what individual queries do in flight or why they run. If an agent has read access to a customer table, it can pull every row. That query output goes straight into the model prompt context and external logs. Native roles do not rewrite emails, phone numbers, card numbers, or national IDs in results.
Least Privilege Principle + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Static credentials also create key management chores for your platform team. You must store the database password in the agent workspace so the tool can log in. Because the agent can run shell commands, it can read its own local variables. If the agent needs temporary write permissions for a fix, someone must edit database grants. Teams often leave those extra permissions open by mistake after the task ends.
Managing agent database tasks across teams
When multiple engineers run OpenHands at the same time, tracking database actions gets hard. Everyone might use the same agent service account to run local tests or checks. When a slow query hits MariaDB, the database log only shows that shared account name. You cannot tell which engineer or which task triggered the bad query.
To keep things clean, pair your database grants with strict workspace cleanup rules. Tear down the agent container after each task and rotate the MariaDB password often. Keep production data out of development schemas whenever the agent only needs test rows. Review your MariaDB grant tables each week to spot leftover permissions and remove them.
Add wire guardrails and masking beside MySQL
Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.
With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.
Frequently asked questions
Should OpenHands use the same MariaDB user as my web app?
No, you should always create a separate MariaDB user for the agent. Your web app needs broad write access, while the agent usually needs narrow read rules.
How do I stop OpenHands from running slow MariaDB queries?
You can set per-account resource limits and statement timeouts inside MariaDB. These native limits kill slow queries before they lock up your database server.
Can MariaDB roles hide sensitive columns from OpenHands?
MariaDB lets you grant select permissions on specific columns instead of the whole table. If a query asks for a restricted column, MariaDB blocks the entire query from running.
Related guides
In this post