How to Configure Codex MariaDB Audit Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a codex mariadb audit log by turning on the native audit plugin. Then you map your AI coding agent to a dedicated database user. Teams often give AI agents shared admin accounts to move fast. Broad roles let the agent read or change any table in the database. If the agent makes a mistake, shared roles hide who ran the bad query. How the codex mariadb audit log workflow runs AI coding agents like OpenAI Codex run tasks on behalf of your engineers. The agent reads code, writes script

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 a codex mariadb audit log by turning on the native audit plugin. Then you map your AI coding agent to a dedicated database user. Teams often give AI agents shared admin accounts to move fast. Broad roles let the agent read or change any table in the database. If the agent makes a mistake, shared roles hide who ran the bad query.

How the codex mariadb audit log workflow runs

AI coding agents like OpenAI Codex run tasks on behalf of your engineers. The agent reads code, writes scripts, and connects to external data stores. To track this work in MariaDB, you first create a specific database role. You give this role only the permissions the agent needs for its task. For example, you might grant read permissions on a few test tables. Next, you load the built-in audit plugin on your MariaDB server. This plugin watches all traffic inside the database engine.

You can filter the audit plugin to watch your new agent user. When the agent logs in, the server records the connection event. Every time the agent sends a query, the plugin writes a log entry. This entry shows the timestamp, the database user, and the SQL text. Admins then ship these log files to a central log store for review. This basic setup gives your team a trail of what the agent did.

What native logging solves and where it falls short

Native database logging helps you pass basic audits and check past events. If a table breaks, you can read the log to find the bad query. Assigning a dedicated user to the agent stops it from using root keys. You can also drop that user account if the agent acts up.

Still, native database roles and logs leave big operational gaps open. First, a database role only checks who logs in at the start. Once the agent is in, it can run any query allowed by that role. Native audit logs only tell you about a bad query after it runs. They do not block a destructive statement while it is in flight.

Second, MariaDB sees the shared agent user, not the human behind the prompt. Five engineers might use the same AI agent setup on their laptops. The database log shows the same agent username for all five people. You cannot tell which engineer asked the agent to run a specific query.

Audit Log Integrity + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Third, native audit logs do not fix sensitive data exposure. When the agent queries a customer table, the database sends back raw rows. Those rows might hold emails, phone numbers, card numbers, or national IDs. The agent pulls those raw values right into its context window. Data masking is needed to rewrite matched fields in results before they leave.

Why query controls matter for AI agents

AI agents generate and run SQL much faster than human engineers do. A human might pause before running a broad update or a big read. An agent will run the query right away if its role allows it. Relying on static roles means you must trust every query the agent writes. Teams need a way to inspect and approve individual statements in real time. They also need to tie every agent action back to a real human identity. Without statement-level checks, you only find mistakes when you read the logs later.

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, inline in the MySQL wire protocol. On every query an AI agent or human runs against production MySQL, RDS, or Aurora, hoop.dev decides to pass, mask, block, or hold it for review.

Multi-statement batches and prepared queries are split and checked one by one by hoop.dev guardrails, which refuse banned queries with a native MySQL error or hold risky ones for approval. On the response path, hoop.dev data masking rewrites string values in returned rows in memory, and every decision is logged. See the MIT-licensed project on GitHub.

Frequently asked questions

Does the MariaDB audit plugin block bad queries from an AI agent?

No, the native audit plugin only records events after they happen. It writes connection and query details to a file for later review. To stop bad queries in flight, you need statement-level controls before the database.

Why should our AI coding agent have its own database user?

A dedicated user lets you filter the MariaDB log for agent traffic. It also lets you limit the agent to read-only permissions on safe tables. If you share an admin account, you mix human and agent queries together.

Can native MariaDB logs hide sensitive data from the AI agent?

No, audit logs only record the queries that run on the server. They do not alter the query results sent back to the client. You need dynamic data masking to rewrite emails or card numbers in results.

The query runs. The emails stay hidden.