How to Configure OpenHands CockroachDB Data Masking

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up openhands cockroachdb data masking with custom database views and restricted user roles. This setup rewrites sensitive fields like emails and phone numbers before the agent reads them. Teams often give coding agents broad database accounts to move fast during setup. Broad roles let the agent read raw customer data and run risky queries. How openhands cockroachdb data masking works in practice OpenHands runs as an autonomous coding agent that executes commands and database queries.

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 openhands cockroachdb data masking with custom database views and restricted user roles. This setup rewrites sensitive fields like emails and phone numbers before the agent reads them. Teams often give coding agents broad database accounts to move fast during setup. Broad roles let the agent read raw customer data and run risky queries.

How openhands cockroachdb data masking works in practice

OpenHands runs as an autonomous coding agent that executes commands and database queries. CockroachDB stores distributed relational data and manages permissions through standard SQL roles. CockroachDB does not have a single toggle for dynamic data masking on tables. Instead, database teams build SQL views that transform sensitive columns using string functions. These functions replace card numbers and national IDs with placeholder text in query results.

Next, the team creates a dedicated database role just for the OpenHands agent. The admin revokes read rights on the base tables for this specific role. Then, the admin grants the agent role read permissions on the masked views only. You put these role credentials into the OpenHands workspace settings. When the agent queries the view, the database rewrites matched fields in the results. This flow keeps raw phone numbers and emails out of the agent context window.

Why database views require constant schema upkeep

Building views for masking works well when your database schema stays small and static. Still, product teams change tables and add new columns every week. Each time an engineer adds a sensitive column, someone must update the masked views. If a team forgets one column, the agent gets raw data in query results. View maintenance quickly becomes a manual chore for database admins.

Also, coding agents often need to inspect table schemas to write migration scripts. If the agent only sees custom views, it might write broken queries for production tables. Teams then grant the agent access to the underlying tables to fix this issue. That single change undoes all the view-based masking work right away.

Data Masking (Static) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native roles solve and what they leave open

Native database roles and views control which objects an account can access at login. They do a great job of blocking access to whole tables or schemas. They also help teams separate human user accounts from automated agent accounts.

Still, static roles only decide who logs in to the database cluster. They do not inspect what individual SQL statements or commands do in flight. If an agent uses a shared role, the database cannot tell which task ran a query. Also, static credentials sit in workspace files where scripts can read and print them. When you rely only on views, one bad grant exposes raw card numbers and emails.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Does CockroachDB offer built-in dynamic data masking?

No, CockroachDB relies on custom SQL views and role grants to mask column values. Teams must write and maintain these views by hand or mask data in flight.

What types of data should we mask for OpenHands agents?

Teams should mask emails, phone numbers, card numbers, and national IDs in query results. Rewriting these fields stops sensitive details from entering the external model prompt history.

Why are read-only roles not enough for coding agents?

Read-only roles stop writes, but they still return raw customer records in query results. Without masking, the agent sends those raw emails and card numbers to the model provider.

The query runs. The emails stay hidden.