How to Configure BigQuery Least Privilege

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up bigquery least privilege by assigning roles at the dataset or table level. You also split permission to run jobs from permission to read stored data. Many data teams start with broad project roles to move fast during early builds. Those wide roles stay in place and give every user and app too much reach. One bad script or leaked key can then read or wipe every table. How bigquery least privilege works in cloud roles Google Cloud manages data permissions through a tree of folders, p

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 bigquery least privilege by assigning roles at the dataset or table level. You also split permission to run jobs from permission to read stored data. Many data teams start with broad project roles to move fast during early builds. Those wide roles stay in place and give every user and app too much reach. One bad script or leaked key can then read or wipe every table.

How bigquery least privilege works in cloud roles

Google Cloud manages data permissions through a tree of folders, projects, datasets, and tables. Child items inherit every role granted higher up in the tree. If you grant a read role at the project level, that user reads all datasets. To stop this inheritance, you remove data permissions from the project level.

You then split compute permissions from storage permissions for every person and service account. A user needs a project role that only lets them submit and run query jobs. That job role does not let them read any table on its own. Next, you grant read or write roles on the exact dataset or table they need.

You can also limit what people see inside a single shared table. Policy tags let you lock down sensitive columns like emails, phone numbers, or card numbers. Row access rules filter table rows based on the group of the person logged in. Authorized views let teams run preset queries without giving them direct access to base tables.

Separating human users from service accounts

Apps, data pipelines, and notebooks need their own tight permission rules. Many teams share one strong service account across several pipelines to save setup time. If one pipeline breaks or leaks its key, all connected datasets face risk. You should create one unique service account for each app or pipeline workload.

Human users should log in with their own work emails and groups. You assign dataset roles to team groups instead of single user emails. When someone changes teams, you remove them from the group in your identity tool. Avoid downloading static service account keys to local laptops whenever you can. Short-lived credentials linked to user logins cut down the risk of stolen files.

Least Privilege Principle + BigQuery IAM: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What cloud roles solve and what they leave open

Native roles and dataset rules do a great job of blocking unauthorized users at login. They make sure a finance analyst cannot open tables owned by the engineering team. They also keep pipelines locked to the specific tables they update each hour. This setup forms a strong base for your cloud security model.

Still, static roles only check who logs in before a query starts to run. Once a user has table access, the cloud role allows every valid statement on it. A developer with legitimate read access can still pull millions of customer rows at once. An engineer with write access for a quick fix can drop or overwrite rows by mistake.

Managing hundreds of policy tags and authorized views also takes constant work from data teams. Schema changes can break views or leave new sensitive columns without a tag. Teams need a way to inspect individual queries in flight and rewrite sensitive results dynamically. Masking tools can rewrite matched fields like national IDs or emails in query results on the fly.

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 sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses 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 should I avoid basic owner, editor, and viewer roles?

Basic roles apply across the whole project and include thousands of broad permissions. They give users reach into every dataset, bucket, and service in that project. Predefined or custom roles let you grant only the exact actions a job needs.

How do I let someone run queries without reading all project data?

Grant the user a job runner role at the project level so they can use compute. Then grant a data viewer role only on the specific dataset or table they need. This pair lets them run SQL while keeping all other project datasets hidden.

How do I handle temporary access for debugging production data?

Do not add permanent write roles to user accounts for one-time fixes. Use conditional role bindings that expire after a set time window, or require peer approval per query. This stops temporary permissions from turning into permanent standing access over time.

The query runs. The emails stay hidden.