How to Configure OpenHands MySQL Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

To set up an openhands mysql audit log, turn on database event tracking for the agent role. Then send those database events to your central log tool for review. Engineering teams often give coding agents a shared database user with broad permissions. When that role has too much access, one bad query can drop tables or read private data. Native logs record the damage after it happens, not before the query runs. How an openhands mysql audit log works OpenHands runs as an autonomous coding agent

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.

To set up an openhands mysql audit log, turn on database event tracking for the agent role. Then send those database events to your central log tool for review. Engineering teams often give coding agents a shared database user with broad permissions. When that role has too much access, one bad query can drop tables or read private data. Native logs record the damage after it happens, not before the query runs.

How an openhands mysql audit log works

OpenHands runs as an autonomous coding agent inside a local container or cloud workspace. Developers give the agent tasks like fixing bugs, writing tests, or updating database schemas. To finish these tasks, the agent reads database credentials from workspace variables. It then opens a direct session to your MySQL server to run queries.

On the database side, MySQL uses a server plugin to track activity. Database admins turn on this plugin and set rules for which users to watch. When the agent logs in, the plugin writes each login event and SQL statement to a file. Teams can filter these rules by user account, event type, or table name.

To make these records useful, admins create a dedicated database user just for the coding agent. Every query from that user gets tagged in the log file with a timestamp and status code. A log collector then reads the local file and ships the entries to a central search tool. Security teams review those records to see what the agent changed during a task.

What native logging solves and where it falls short

Native database logging gives teams a clear history of past agent actions. If an agent breaks a staging table, admins can check the log to find the exact statement. It also helps teams prove who touched a database during an audit review. Dedicated agent roles make it easy to separate bot traffic from human queries.

Still, native database roles and logs only decide who can log in. They do not inspect or control what individual statements do while in flight. Once the agent has write permissions on a table, it can update one row or delete all rows by default. The database log simply writes down that the table is now gone.

Shared agent accounts also make it hard to tie a query back to a specific developer. Ten engineers might trigger the same agent workspace using one database password. In the MySQL log, all ten sessions look like the exact same database user. You lose the link between the human who wrote the prompt and the SQL query that ran.

Audit Log Integrity + MySQL Access Governance: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Finally, native logs do not stop sensitive data from entering the agent context window. If an agent selects a customer table, raw emails and phone numbers flow back to the model. Also, the audit file itself might store raw card numbers or national IDs inside query text. Teams need a way to check queries before execution and mask sensitive fields in results.

Best practices for agent database roles

Start by creating a separate database role for each agent workspace instead of sharing one login. Grant read access only to the specific tables needed for the current coding task. Avoid giving agents schema change permissions or drop rights on production or shared staging databases.

Next, set strict row limits and query timeouts on the database account used by the agent. A bad prompt can cause an agent to run heavy joins that lock up the server. Make sure your log shipping pipeline masks emails and card numbers before storing query text. Review agent query logs every week to remove unused table permissions.

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

Does the MySQL audit plugin slow down agent queries?

Yes, logging every read and write event adds disk load to the database server. Teams can lower this load by logging only specific agent accounts or write statements.

Native MySQL logs only record the database username, not the human behind the agent prompt. To track the human user, each developer needs a unique identity tied to their database session.

Can the MySQL audit log block an agent from reading customer emails?

No, an audit log only records queries and cannot block or mask data in flight. To hide emails or phone numbers, you need data masking that rewrites matched fields in results.

The query runs. The emails stay hidden.