Why audit trail matters for Postgres
When an agent can masquerade as any user, your audit trail becomes meaningless. In a regulated environment the ability to prove who executed each SQL statement is often the difference between passing an audit and facing penalties. A trustworthy audit trail also helps engineers pinpoint the root cause of a data leak, roll back accidental changes, and detect insider threats before they cause irreversible damage.
The hidden risk of agent impersonation
Most organizations run Postgres behind a single service account that lives on a bastion host or inside a CI runner. The agent that talks to the database authenticates once, stores the credential locally, and then reuses it for every request. Because the agent presents the same credential regardless of which engineer triggered the operation, the database logs record only the service account name. If the agent is compromised, an attacker can issue queries that appear to come from a legitimate user, erasing the true source of the activity. The result is an audit trail that shows a flood of benign operations while the malicious actions remain invisible.
Why a gateway is required
Many teams have already invested in SSO or OIDC to prove a user’s identity before they reach the internal network. That authentication step is essential, but it stops at the network edge. Once the request leaves the identity provider, it is handed directly to the Postgres agent, which still holds the static credential. No additional checks are performed, no per‑user logging is added, and no data is masked. In other words, the precondition of having a verified identity does not guarantee a reliable audit trail because the enforcement point never sees the request.
How hoop.dev creates a reliable audit trail
hoop.dev is a Layer 7 gateway that sits between the verified identity and the Postgres instance. The gateway proxies every client connection, inspects each wire‑protocol message, and records the full statement together with the original user’s identity token. Because hoop.dev never hands the database credential to the caller, the agent cannot impersonate a different user. The gateway enforces just‑in‑time access, so a user receives a short‑lived token that is validated on every query. If a command violates a policy, hoop.dev blocks it before it reaches the database.
Every SQL statement that passes through the gateway is recorded in an immutable session log that can be replayed on demand. The log includes the user’s name, groups, timestamp, and the exact query text. Sensitive columns such as credit‑card numbers or personal identifiers can be masked in real time, ensuring that even privileged reviewers never see raw data they are not authorized to view. Because the audit trail is generated at the gateway, it remains complete even if the underlying agent is compromised.
