Current practice leaves AI agents unchecked
Allowing an LLM to run unrestricted database access queries against production data can expose sensitive records in seconds. In many organizations the easiest way to give ChatGPT the ability to read or write a database is to embed a static credential in the prompt, store a shared password in a config file, or grant the model a service account with broad privileges. The model then connects directly to PostgreSQL using the same network path as a human operator. Because the gateway is bypassed, there is no real‑time visibility into which tables are touched, no way to block destructive statements, and no record of what data was returned to the LLM.
This approach also encourages a false sense of security. Teams assume that because the credential is limited to a single role, the risk is contained, yet the role often has read access to every schema and write access to audit tables. When the model generates a query based on a user request, the result can be cached, logged, or even exfiltrated without any oversight. The lack of inline data masking means that personally identifiable information can flow straight into the model’s context, violating privacy policies and regulatory expectations.
Why the data path needs a dedicated gateway
The core problem is not identity – most enterprises already use OIDC or SAML to authenticate users and service accounts. The missing piece is a point where every request is examined before it reaches the database. Without a dedicated data‑path component, policies such as just‑in‑time (JIT) approval, command‑level blocking, or response‑level redaction cannot be enforced consistently. The gateway must sit between the LLM and PostgreSQL, intercepting the wire‑protocol, applying policy, and then forwarding only the allowed traffic.
Placing enforcement at the network edge also isolates the control logic from the application runtime. Even if the LLM’s execution environment is compromised, the gateway remains outside the process that holds the credential, preventing the attacker from re‑using the secret directly. This separation is the only reliable way to guarantee that every query is subject to the same guardrails that protect human operators.
Implementing controlled database access for ChatGPT with hoop.dev
hoop.dev provides the required Layer 7 gateway. It proxies PostgreSQL connections, inspects each query, and applies a configurable set of controls. The system is open source, MIT licensed, and can be deployed with a single Docker Compose file or on Kubernetes. Once the gateway is running, ChatGPT (or any AI coding agent) connects to the proxy endpoint instead of the database directly. The proxy authenticates the request via OIDC, reads the caller’s group membership, and then enforces policies that are defined once at the gateway level.
