How to Configure CrewAI MariaDB Sandbox

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a crewai mariadb sandbox by pairing a read-only database role with an isolated test instance. Next, you give the agent tool a limited database login string that only reaches safe tables. Teams often start by handing an agent a broad test user to speed up early work. When permissions are too wide, one bad agent prompt can drop tables or read private rows. How a crewai mariadb sandbox works in practice In a standard setup, an agent uses a custom tool to run SQL statements against you

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 crewai mariadb sandbox by pairing a read-only database role with an isolated test instance. Next, you give the agent tool a limited database login string that only reaches safe tables. Teams often start by handing an agent a broad test user to speed up early work. When permissions are too wide, one bad agent prompt can drop tables or read private rows.

How a crewai mariadb sandbox works in practice

In a standard setup, an agent uses a custom tool to run SQL statements against your database. The agent takes a user question, writes a query, and sends it through a standard database driver. To keep this safe, engineers build a separate database instance that holds fake or scrubbed records. They then create a dedicated database user that only has permission to read specific tables.

The agent framework reads the database host, user name, and password from local settings at startup. Every time a task runs, the agent opens a session using that single shared database account. The database engine checks the account role and blocks any command that tries to change schema structure. If the agent only needs three tables, the database admin grants read rights on those three tables alone. This stops the agent from scanning the whole database schema when it builds a query.

Network isolation and test data hygiene

A strong sandbox also relies on strict network rules between the agent host and the database server. Engineers place the test database in a private subnet that cannot reach production networks or internal services. Firewall rules allow traffic only from the specific container or server where the agent tasks run. This keeps a rogue query or a tricked agent from moving sideways into other company systems.

Data hygiene inside the test instance matters just as much as network walls and user roles. Teams often copy a slice of production data into the test instance so agents see real patterns. Before the agent runs, a script should scrub sensitive columns like emails, phone numbers, and card numbers. Without clean test data, an agent can still pull real customer details into its prompt history.

AI Sandbox Environments + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native database roles solve and what they miss

Native database roles and separate instances do a great job of stopping major structural damage. If an agent tries to delete a table, the read-only role rejects the statement right away. If a query crashes the test server, production apps stay up and real users notice nothing. Static grants draw a clear boundary around which tables and views the database account can touch.

Still, native database permissions only check who logs in and which tables the account can read. Once the agent logs in, the database cannot tell a safe query from a risky one. A read-only user can still run a massive join that locks up the server for hours. If the test database holds uncleaned rows, the agent can still read national IDs or emails. Static roles also share one login across many agent runs, so audit logs lack task detail. Teams need a way to inspect each statement in flight and rewrite sensitive fields in results.

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

Why should agents use a separate MariaDB instance instead of a production replica?

A production replica still holds real customer records and shares replication load with your main database cluster. An isolated test instance lets you scrub sensitive columns and cap compute use without hurting live traffic.

Can a read-only database role stop all dangerous agent queries?

A read-only role stops data changes and table drops, but it cannot block heavy read queries. An agent can still run a full table scan or pull sensitive rows from allowed tables.

How do teams track which agent task ran a specific SQL statement?

Native database logs only record the shared database user name that opened the session. To link queries to specific tasks, teams must attach agent context or check statements before they run.

The query runs. The emails stay hidden.