All posts

Putting access controls around ChatGPT: database access for AI coding agents (on GCP)

When a development team lets ChatGPT draft SQL snippets directly against a production instance, they are effectively granting the model unchecked database access. A single rogue suggestion can expose customer PII, corrupt tables, or trigger costly queries. The risk is amplified on GCP where service accounts often carry broad privileges and the AI model runs with the same network reach as any human engineer. In that situation, the organization loses visibility into who actually caused a data‑modi

Free White Paper

GCP VPC Service Controls + AI Model Access Control: The Complete Guide

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

Free. No spam. Unsubscribe anytime.

When a development team lets ChatGPT draft SQL snippets directly against a production instance, they are effectively granting the model unchecked database access. A single rogue suggestion can expose customer PII, corrupt tables, or trigger costly queries. The risk is amplified on GCP where service accounts often carry broad privileges and the AI model runs with the same network reach as any human engineer. In that situation, the organization loses visibility into who actually caused a data‑modifying statement and whether the statement complied with internal policy.

What the team really needs is a control plane that sits between the AI coding agent and the database, granting just‑in‑time rights, requiring explicit approval for risky statements, masking sensitive columns in query results, and recording every interaction for later review. The control must be able to inspect the traffic at the protocol level so that it can block or rewrite commands before they hit the database engine. Without a dedicated gateway, those safeguards would have to be baked into the application code, scattered across CI pipelines, or left to ad‑hoc scripts – none of which provide a single source of truth for enforcement.

Why database access for AI coding agents needs a dedicated gateway

AI‑driven coding assistants do not understand the nuance of a company’s data‑access policy. They generate queries based on pattern matching, not on role‑based permissions. Consequently, an AI agent can unintentionally request a full table scan, request columns that are regulated, or issue DDL that changes schema without oversight. A gateway that can intercept the request, compare it against a policy, and either allow, mask, or route it for human approval restores the missing guardrails.

In addition, audit requirements for regulated industries often demand persistent logs of every database session, including the exact statements executed and the identity that initiated them. For AI agents, the identity is a service account or a token, but the audit log must still tie the activity back to a human owner or an automated job. Without a centralized point that records this information, compliance teams scramble to piece together logs from the database, the CI system, and the AI platform.

What a Layer‑7 gateway provides for database access

hoop.dev is a Layer 7 gateway that sits on the network edge between any client – including an AI coding agent – and the target database. It receives the client’s connection, authenticates the caller via OIDC/SAML, and then forwards the traffic to the database only after applying the configured guardrails. Because the gateway operates at the protocol layer, it can see each SQL statement, mask columns in the response, block commands that match a deny list, or trigger an approval workflow before the statement reaches the engine.

Continue reading? Get the full guide.

GCP VPC Service Controls + AI Model Access Control: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

All credentials needed to talk to the database are stored inside the gateway. The AI agent never sees the password or service‑account key; it only presents an identity token that hoop.dev validates. This separation ensures that even a compromised AI runtime cannot exfiltrate the underlying database credential.

How hoop.dev enforces database access for ChatGPT on GCP

The enforcement flow consists of three distinct layers:

  • Setup (identity): The organization configures an OIDC provider – for example, Google Workspace or an external IdP – and maps groups to permission profiles. When ChatGPT runs inside a container on GCP, it obtains an OIDC token scoped to a service account. The token tells hoop.dev who is making the request, but it does not grant any database rights by itself.
  • The data path (gateway): hoop.dev is the only point that can see the actual SQL traffic. Every request from the AI agent is routed through the gateway before it reaches Cloud SQL or any other managed PostgreSQL instance. Because the gateway is the data path, it can apply policy checks, inline masking, and just‑in‑time approval without relying on the database’s own access controls.
  • Enforcement outcomes: hoop.dev records the full session, including the original statement and the masked response. It can hide sensitive columns (for example, SSN or credit‑card numbers) before they ever leave the database. If a statement attempts to drop a table, hoop.dev can block it outright or send the request to a human approver. The recorded session can be replayed later for forensic analysis, and the audit log ties the activity to the original OIDC identity.

Because the gateway runs as a network‑resident agent inside the same VPC as the database, latency is minimal and the connection remains encrypted end‑to‑end. The policy engine lives inside hoop.dev, so any change to masking rules or approval thresholds takes effect instantly for all AI agents without redeploying the AI service.

Getting started with hoop.dev for ChatGPT on GCP

The quickest way to try this architecture is to deploy the hoop.dev compose stack in a GCP Compute Engine instance that shares the same subnet as the target Cloud SQL database. The quick‑start guide walks through configuring OIDC, registering the PostgreSQL connection, and defining a masking policy for columns that contain regulated data. Detailed steps are available in the getting‑started documentation. All source code and container images are open source on GitHub, so teams can self‑host the gateway behind their own firewalls: hoop.dev repository.

Once the gateway is running, point the ChatGPT‑driven code to the hoop.dev endpoint instead of the raw database host. The AI agent continues to use the same client libraries (psql, JDBC, etc.), but every request is now subject to the gateway’s policy checks, masking, and audit recording.

FAQ

  • Do I need to modify my existing database clients? No. hoop.dev speaks the native wire protocol, so existing client binaries work unchanged. You only change the host and port to point at the gateway.
  • Can I still use IAM authentication for Cloud SQL? Yes. hoop.dev can store the IAM‑derived credentials and use them when forwarding traffic, keeping the credential hidden from the AI runtime.
  • How does approval work for a risky statement? When a statement matches a configured risk rule, hoop.dev pauses the request and sends an approval notification to a configured channel (email, Slack, etc.). An authorized human can approve or reject the request, after which hoop.dev either forwards the statement or returns an error.

By placing a Layer 7 gateway between ChatGPT and your databases, you gain fine‑grained control, real‑time masking, just‑in‑time approvals, and persistent session logs – all without changing the AI code or exposing credentials. For a deeper dive into policy definition and masking syntax, explore the feature guide.

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