How to Configure OpenHands Bigquery Least Privilege
You set up openhands bigquery least privilege by making a dedicated cloud service account. Next, you bind that account to strict dataset and job roles. Many teams skip this step when they test an AI agent. They pass their own admin keys to the agent container instead. Broad roles let an autonomous agent drop tables or read secret rows by mistake. One bad prompt can wipe out production data or rack up huge cloud bills. How openhands bigquery least privilege works in cloud roles OpenHands runs
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 bigquery least privilege by making a dedicated cloud service account. Next, you bind that account to strict dataset and job roles. Many teams skip this step when they test an AI agent. They pass their own admin keys to the agent container instead. Broad roles let an autonomous agent drop tables or read secret rows by mistake. One bad prompt can wipe out production data or rack up huge cloud bills.
How openhands bigquery least privilege works in cloud roles
OpenHands runs as an autonomous coding agent inside its own workspace. It writes code, runs shell commands, and queries data to finish tasks. When it talks to BigQuery, it needs a cloud identity. You should never give the agent a project-wide owner or editor role. Instead, you create a fresh service account just for the agent.
BigQuery separates the right to run a query from the right to read data. First, the agent needs permission to submit a query job at the project level. Second, the agent needs permission to view specific tables at the dataset level. If the agent only reads data for analysis, give it a reader role on one dataset. Do not grant dataset permissions at the top project level.
Sometimes the agent needs to write new tables to test data pipelines. You can make a separate scratch dataset for those write tasks. Grant the agent a data editor role on that scratch space alone. Keep production datasets locked down with read-only rules or no access at all. You can also turn on table-level or column-level security for sensitive columns.
Where static cloud roles fall short for AI agents
Native cloud roles decide who can log in and which tables they can touch. That setup blocks the agent from touching outside datasets in your cloud project. Yet static roles do not inspect the actual SQL statements the agent runs in flight. Once the agent has read rights on a table, it can pull every row.
Autonomous agents loop through tasks fast and run many queries in seconds. A static role cannot stop a bad join that scans terabytes of history. While you can set daily byte limits, static roles still struggle with row-level secrets. If a permitted table holds customer emails or card numbers, the agent reads them in plain text. Those raw values then flow straight into the agent logs and model prompts.
Least Privilege Principle + BigQuery IAM: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Why runtime query checks matter for autonomous workflows
Teams also face a hard problem with static service account keys. To use native roles, you often mount a key file inside the agent runtime. Since OpenHands can run bash commands, it can read its own local files. A confused agent might print that key in a log or push it to git.
True safety for AI agents requires checks on every single query at runtime. Teams need a way to inspect SQL commands before they hit the data warehouse. They also need dynamic data masking that rewrites emails and phone numbers in query results. Pausing risky drop or alter commands for human approval adds another strong safety net.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Why does an OpenHands agent need both job and data roles in BigQuery?
BigQuery splits compute rights from storage rights in its permission model. The job role lets the agent run a query, while the data role lets it read tables.
Can I restrict an OpenHands agent to a single table instead of a whole dataset?
Yes, BigQuery lets you attach reader roles directly to one specific table or view. This stops the agent from seeing other tables that live in the same dataset.
What is the main risk of putting service account keys in the agent container?
OpenHands has full shell access inside its workspace to write and test code. The agent can read the mounted key file and leak it in logs or git commits.
Related guides
In this post