Many assume that letting an AI coding assistant like Claude query a database is safe because the model never sees raw rows, but that belief ignores data masking requirements. In reality the assistant can retrieve and expose sensitive fields unless the response is masked.
Teams often give Claude a service account that has broad read access to a production PostgreSQL instance. They store the credential in a configuration file or container secret that developers share. When Claude generates a SELECT statement, the query travels directly to the database, returns full rows, and the raw data lands in the model’s output. No audit trail records which columns were returned, and no inline transformation hides personally identifiable information. If a developer later discovers that credit‑card numbers or health identifiers were included in a response, the exposure is already baked into the model.
Why data masking matters for Claude agents
The immediate fix is to add a masking layer, but the problem runs deeper. Even with a masking policy, the request still reaches the database unfiltered. The database sees the original query, executes it, and returns the complete result set. Without a control point that can inspect and transform the response before it leaves the data path, the mask never takes effect. Moreover, the request still uses a static credential that grants far more privilege than any single user should have. The missing piece is a place where the policy can be enforced and the action recorded.
Setup: defining a non‑human identity for Claude
The security team provisions a dedicated service identity for the Claude agent. An OIDC provider (for example, Azure AD or Google Workspace) issues a short‑lived token that carries only the group membership required to run the specific queries the agent needs. The token is scoped to the "Claude‑Postgres" role. This step decides who the request is and whether it may start, but on its own it does not enforce any data‑handling rule.
Data path: inserting a gateway between Claude and Postgres
hoop.dev sits in the data path as a Layer 7 gateway that proxies PostgreSQL traffic. When Claude connects, the request routes through the gateway instead of going straight to the database. The gateway holds the database credential, so the agent never sees it. Because hoop.dev is the only place that inspects traffic, it can apply policies in real time.
hoop.dev masks sensitive fields in query results, records every session for replay, and can require a human approval step for risky statements. The masking policy lives in the gateway configuration and applies to every response that matches the rule set. Because hoop.dev is the active subject, the masking happens reliably regardless of how the underlying database or credential is configured.
