All posts

Nested agents: what they mean for your least privilege (on Snowflake)

Many teams assume that nesting Snowflake agents automatically enforces least privilege. In reality, nesting only scopes the identity that initiates the request; it does not insert a control point that can inspect, mask, or block queries. How teams connect to Snowflake today Most organizations provision a single Snowflake user or a handful of shared service accounts. Those accounts often carry broad roles – for example, ACCOUNTADMIN or a custom role that grants read and write across many schem

Free White Paper

Least Privilege Principle + On-Call Engineer Privileges: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

Many teams assume that nesting Snowflake agents automatically enforces least privilege. In reality, nesting only scopes the identity that initiates the request; it does not insert a control point that can inspect, mask, or block queries.

How teams connect to Snowflake today

Most organizations provision a single Snowflake user or a handful of shared service accounts. Those accounts often carry broad roles – for example, ACCOUNTADMIN or a custom role that grants read and write across many schemas. Engineers embed the credentials in CI pipelines, scripts, or local client configs. The result is a direct, standing connection that bypasses any runtime guard. Auditing is limited to Snowflake’s own query logs, which do not capture the context of the initiating process, nor do they provide real‑time approval workflows.

What nested agents change – and what they don’t

Introducing a nested agent model means that an outer service authenticates to Snowflake on behalf of an inner service or AI workflow. The outer layer can enforce a tighter identity, so the inner component only receives the permissions granted to the nested principal. This improves the least privilege posture by preventing the inner service from using a super‑user token.

However, the request still travels straight to Snowflake after the outer agent hands off the connection. No gateway sits in the data path to examine the SQL payload. Sensitive columns are not redacted, risky commands are not intercepted, and high‑value queries are not routed for human approval. In other words, nested agents solve the identity scoping problem but leave the enforcement gap wide open.

Why a data‑path gateway is required for true least privilege

To close the enforcement gap, the connection must pass through a layer that can apply policy at runtime. That layer is a Layer 7 gateway that proxies the Snowflake protocol, inspects each query, and enforces rules before the database sees the request. Such a gateway can:

  • Record every session for replay and audit, providing evidence that matches compliance requirements.
  • Mask sensitive fields in query results, ensuring that downstream services never see raw credit‑card numbers or personal identifiers.
  • Block commands that match a deny list, such as DROP DATABASE or GRANT ROLE issued by an automated job.
  • Require just‑in‑time approval for queries that exceed a risk threshold, for example, exporting more than a million rows.
  • Keep credentials inside the gateway so the outer and inner agents never see them.

This is precisely where hoop.dev fits. The product sits in the data path between identities and Snowflake, turning the abstract least privilege goal into an enforceable control surface.

How hoop.dev enforces least privilege for Snowflake

When a user authenticates via OIDC or SAML, hoop.dev validates the token, extracts group membership, and maps it to a Snowflake role that the gateway will use. The gateway holds the Snowflake credential; the user’s client never sees it. Every SQL statement is streamed through the gateway, where policy modules can apply the actions listed above. Because the gateway is the only point that can see the plaintext query, it can safely mask columns, log the exact statement, and trigger an approval workflow if needed.

Continue reading? Get the full guide.

Least Privilege Principle + On-Call Engineer Privileges: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

From a deployment perspective, the gateway runs as a Docker Compose service for quick trials or as a Kubernetes pod for production. An agent lives on the same network as Snowflake, ensuring low‑latency connectivity while keeping the enforcement boundary outside the Snowflake process itself.

Benefits for a least‑privilege strategy

By moving enforcement to the gateway, organizations gain:

  • Granular audit trails that tie each query to a specific user, time, and approval decision.
  • Dynamic masking that protects sensitive data even when downstream services have read access.
  • Risk‑based approvals that let engineers work quickly while still requiring oversight for high‑impact actions.
  • Zero credential exposure for both outer and nested agents, reducing the blast radius of a secret leak.

These outcomes exist only because the gateway sits in the data path; without it, nested agents alone cannot provide them.

Getting started

To try this approach, follow the getting‑started guide. The documentation walks through deploying the gateway, registering a Snowflake connection, and configuring OIDC authentication. All configuration details are kept out of this post to keep the focus on architecture.

FAQ

Does hoop.dev replace Snowflake’s native role management?

No. Snowflake continues to enforce its own role hierarchy. hoop.dev adds a layer that can further restrict what a user or nested agent can do before the request reaches Snowflake.

Can I still use existing Snowflake users and passwords?

Yes, but the gateway stores those credentials and presents them only to authorized sessions. This prevents the credentials from being hard‑coded in scripts or CI pipelines.

Is session recording safe for large query results?

Recording captures the query text and metadata. Result data can be masked or omitted according to policy, ensuring that sensitive output does not get written to logs.

Explore the source code on GitHub to see how the gateway implements these controls and to contribute to the project.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts