All posts

Agent impersonation: what it means for your access reviews (on Postgres)

When a contract engineer leaves a project, the team often forgets to rotate the shared PostgreSQL password. Weeks later, a CI job still runs under that same account, pulling data for a new feature. The job’s logs show a handful of queries, but the audit team cannot tell whether the original contractor, a current developer, or an automated script issued them. Without clear attribution, the upcoming access reviews lack the evidence needed to answer “who did what”, turning the review into a guessin

Free White Paper

Access Reviews & Recertification + Open Policy Agent (OPA): The Complete Guide

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

Free. No spam. Unsubscribe anytime.

When a contract engineer leaves a project, the team often forgets to rotate the shared PostgreSQL password. Weeks later, a CI job still runs under that same account, pulling data for a new feature. The job’s logs show a handful of queries, but the audit team cannot tell whether the original contractor, a current developer, or an automated script issued them. Without clear attribution, the upcoming access reviews lack the evidence needed to answer “who did what”, turning the review into a guessing game.

That uncertainty is the hallmark of agent impersonation. In a PostgreSQL environment, impersonation occurs when a process or user presents credentials that do not uniquely identify the true actor. The database sees a valid role, but the surrounding ecosystem cannot map the request back to a specific human or service identity.

Access reviews depend on that mapping. An effective review asks, “Who ran this SELECT? Did they have a legitimate reason?” When impersonation is possible, the answer collapses to “Someone with the shared password,” which defeats the purpose of the review.

How teams connect today

Most engineering groups provision a handful of high‑privilege PostgreSQL accounts and distribute the passwords via internal wikis or password‑manager notes. Service accounts for CI pipelines are often granted broad read‑write privileges and never rotated. The database itself does not enforce per‑user authentication beyond the supplied role; it trusts the client to be honest.

This model leaves two gaps. First, the identity that initiates a connection is opaque to the database. Second, there is no enforcement point that can intervene if a request looks suspicious. The result is a landscape where access reviews rely on manual log inspection, and any shared credential instantly erodes confidence.

What the precondition fixes – and what it leaves open

Moving to identity‑aware authentication, using OIDC or SAML to issue short‑lived tokens, addresses the first gap. Each token carries a unique subject, and the database can reject connections that lack a valid token. However, the token‑based request still travels directly to PostgreSQL. The gateway that sits between the client and the database remains invisible, so there is still no place to record the exact query, mask sensitive result fields, or require a human approval for risky commands. In other words, the request reaches the target, but the organization still lacks audit trails, inline masking, and just‑in‑time approval.

hoop.dev as the data‑path solution

hoop.dev sits in the Layer 7 data path and becomes the only point where enforcement can happen. Because hoop.dev proxies every PostgreSQL session, it can:

  • Record each query and the identity that issued it, creating a reliable evidence source for access reviews.
  • Mask columns that contain personally identifiable information before they leave the database, reducing the risk of accidental exposure.
  • Block commands that match a deny list, such as DROP DATABASE, before they reach PostgreSQL.
  • Route high‑risk statements to an approval workflow, ensuring a human signs off before execution.

All of these outcomes exist only because hoop.dev occupies the gateway position. Without hoop.dev, the token verification step would still occur, but the database would never see the additional guardrails.

Continue reading? Get the full guide.

Access Reviews & Recertification + Open Policy Agent (OPA): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

What to watch for in access reviews

When evaluating PostgreSQL access, look for these red flags that suggest impersonation:

  1. Long‑lived passwords shared across multiple services or users.
  2. Service accounts with privileges that exceed the principle of least privilege.
  3. Audit logs that contain generic role names without a tied‑to‑identity field.
  4. Sudden spikes in query volume from a single account that has not been used recently.

If any of these appear, the organization should treat the findings as high‑risk until a gateway that records per‑session identity is in place.

How hoop.dev enables trustworthy access reviews

hoop.dev ties every PostgreSQL request to the exact OIDC subject that presented the token. The session record includes the full SQL statement, timestamps, and the originating IP address. Reviewers can filter by user, date, or query type, and instantly see who performed each action. Because the gateway masks sensitive columns, the audit logs never expose raw PII, yet they retain enough context to verify compliance.

In addition, hoop.dev’s just‑in‑time access model ensures that standing privileges are minimized. Engineers request a temporary role, receive a short‑lived token, and the gateway enforces the scope for the duration of the session. Once the session ends, the token expires and no lingering access remains.

Setup considerations

The foundation is an identity provider that issues OIDC or SAML tokens, Okta, Azure AD, Google Workspace, or any compatible IdP. hoop.dev acts as the relying party, validates the token, and extracts group membership to drive authorization decisions. Deploy the gateway close to the PostgreSQL cluster, either via Docker Compose for a quick start or via Kubernetes for production workloads. The agent runs inside the same network segment, holds the database credentials, and never exposes them to end users.

For detailed deployment steps, see the getting‑started guide and the broader feature overview on the learn page.

FAQ

How can I detect if an existing PostgreSQL account is being shared?

Review the audit logs for repeated use of the same role from multiple source IPs or at unusual hours. If you see the same role issuing queries from both a developer workstation and a CI runner, that indicates credential sharing.

Does hoop.dev replace the need for rotating database passwords?

hoop.dev stores the database credentials in the agent, so end users never see them. However, rotating the underlying password remains a best practice for defense in depth. hoop.dev’s gateway will automatically pick up the new credential after you update the agent configuration.

Can hoop.dev mask data without breaking application logic?

Yes. hoop.dev applies masking at the protocol layer, replacing sensitive column values with placeholder tokens before they reach the client. Applications continue to receive the expected number of rows and columns, preserving query semantics while protecting the data.

By moving the enforcement point to the data path, organizations gain the visibility and control needed for reliable access reviews. hoop.dev makes impersonation a detectable and preventable condition rather than an invisible risk.

Ready to try it? The source code and contribution guidelines are available on GitHub.

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