All posts

Non-human identity vs shared service accounts: which actually controls AI agent risk (on Postgres)

AI agents that can run unrestricted SQL against production databases are a single point of catastrophic failure for non-human identity management. Most teams today give those agents a shared service account, a static username and password baked into CI pipelines, Docker images, or environment files. Switching to a non-human identity, where each AI process receives an OIDC token instead of a static secret, changes the threat model dramatically. The credential lives forever, is copied across doze

Free White Paper

Non-Human Identity Management + AI Agent Security: The Complete Guide

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

Free. No spam. Unsubscribe anytime.

AI agents that can run unrestricted SQL against production databases are a single point of catastrophic failure for non-human identity management.

Most teams today give those agents a shared service account, a static username and password baked into CI pipelines, Docker images, or environment files. Switching to a non-human identity, where each AI process receives an OIDC token instead of a static secret, changes the threat model dramatically. The credential lives forever, is copied across dozens of jobs, and is often granted super‑user rights because the engineers need to move fast. When an agent misbehaves, the breach is invisible: there is no per‑request audit, no way to tell which query caused the damage, and no mechanism to hide columns that contain personal data.

Because the credential is static, any compromise of the CI runner or a mis‑configured secret store instantly grants an attacker full access to the Postgres instance. The risk is amplified when the same account is used by multiple services, each with different data‑access needs. The result is a tangled web of implicit trust that no security team can reliably reason about.

Why non-human identity alone is not enough

Replacing the shared service account with a non-human identity, for example an OIDC token issued to each AI agent, sounds like a clean fix. The token can be scoped to a specific role, it can be short‑lived, and it can be tied to a service‑account identity in the identity provider. However, the token still travels directly from the agent to the Postgres server.

That direct path means the database itself remains the only enforcement point. The database can check role membership, but it cannot enforce fine‑grained policies such as “mask credit‑card numbers in query results” or “require a human approver before a DELETE runs”. It also cannot capture a replayable session that includes every statement the agent sent, because the database logs are typically coarse and may be rotated or overwritten.

In short, non-human identity fixes credential hygiene but leaves the core enforcement surface untouched. The request still reaches the target without a guardrail that can block, mask, or record the activity. If the token is stolen, the attacker still has a direct line into the database.

How hoop.dev enforces control for AI agents on Postgres

hoop.dev inserts a Layer 7 gateway between the AI agent and the Postgres instance. The gateway becomes the only place where traffic is inspected, policies are applied, and evidence is collected. Because hoop.dev is the active participant in the data path, it can:

Continue reading? Get the full guide.

Non-Human Identity Management + AI Agent Security: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
  • Record every SQL statement and its result set, producing a complete session log that can be reviewed later.
  • Apply inline masking to columns that contain regulated data, ensuring that even a compromised token never sees raw values.
  • Block dangerous commands, such as DROP DATABASE or mass DELETE, before they reach the server, optionally routing them to a just‑in‑time approval workflow.
  • Enforce just‑in‑time access by requiring a fresh approval for every privileged operation, regardless of the token’s original scope.

All of these outcomes exist because hoop.dev sits in the data path; the database itself does not need to know about them. The gateway holds the credential that the Postgres server trusts, so the agent never receives the secret directly.

Decision matrix: non-human identity versus shared service accounts

Below is a quick comparison that helps answer the single question: which approach actually reduces AI‑agent risk?

ControlShared service accountNon-human identity aloneNon-human identity + hoop.dev
Credential rotationManual, infrequentAutomatic per-token expiryAutomatic per-token expiry, credential stored only in gateway
Fine-grained policy enforcementNoneLimited to DB role permissionsInline masking, command blocking, JIT approval
Audit visibilityDatabase logs only, coarseDatabase logs onlyFull session recording with replay capability
Risk of credential leakageHigh – credentials in many placesReduced – short-lived tokensMinimal – agent never receives secret, gateway mediates

The matrix shows that non-human identity improves credential hygiene, but only when paired with a data‑path enforcement layer does it provide the comprehensive protection needed for AI agents.

Getting started

To adopt this model, provision a hoop.dev gateway in the same network as your Postgres cluster and configure it to use your identity provider for OIDC authentication. The official getting started guide walks you through the Docker Compose quick‑start, and the learn section explains how to define masking rules, approval policies, and session retention.

FAQ

Do I still need database roles?

Yes. hoop.dev forwards the request with the original database credential, so the database’s own role model remains the baseline. hoop.dev adds an extra layer of enforcement on top of those roles.

Can existing AI pipelines be switched over without code changes?

Because hoop.dev speaks the native Postgres wire protocol, you can point your client library at the gateway endpoint instead of the database host. No changes to SQL statements or client code are required.

What happens to logs if the gateway is compromised?

Logs are stored outside the gateway process, so the audit data remains available even if the gateway itself is compromised.

Ready to see the code in action? View the source on GitHub and start building a safer AI‑driven data pipeline today.

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