All posts

HIPAA for AI agents: controlling access for audit-ready operations (on Postgres)

Uncontrolled AI agents querying patient data can instantly create a HIPAA violation. HIPAA expects any system that touches protected health information (PHI) to enforce the minimum‑necessary rule, maintain reliable audit trails, and provide mechanisms to prevent accidental disclosure. When an AI model is granted direct credentials to a PostgreSQL instance, the model can issue arbitrary SELECT statements, export entire tables, or even modify data without any human oversight. The regulation also

Free White Paper

AI Audit Trails + Audit-Ready Documentation: The Complete Guide

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

Free. No spam. Unsubscribe anytime.

Uncontrolled AI agents querying patient data can instantly create a HIPAA violation.

HIPAA expects any system that touches protected health information (PHI) to enforce the minimum‑necessary rule, maintain reliable audit trails, and provide mechanisms to prevent accidental disclosure. When an AI model is granted direct credentials to a PostgreSQL instance, the model can issue arbitrary SELECT statements, export entire tables, or even modify data without any human oversight. The regulation also requires that any access be tied to a distinct identity, that logs capture who accessed what and when, and that sensitive fields be masked or redacted in responses that leave the system. Without these safeguards, a breach can be reported as a “failure to safeguard PHI,” exposing the covered entity to steep fines and reputational damage.

Many organizations treat AI agents as just another service account. They create a static database user, grant it broad SELECT privileges, and let the model connect directly from a compute node. The setup satisfies the setup requirement – the identity is known to the database, and the service account is provisioned with least‑privilege permissions. However, the request still travels straight to PostgreSQL, bypassing any runtime enforcement. No session is recorded, no query‑level approval is required, and no inline masking occurs. In short, the data path provides no guardrails, leaving the organization unable to prove compliance during an audit.

What hipaa expects for AI‑driven data access

HIPAA’s Security Rule defines three core safeguards: administrative, physical, and technical. For AI agents, the technical safeguards are the most relevant. They include:

  • Access control: each request must be tied to an authenticated identity and limited to the minimum data needed.
  • Audit controls: every access event must be logged with sufficient detail to support audit requirements.
  • Integrity controls: the system must detect and block unauthorized commands before they affect the database.
  • Transmission security: data in motion must be encrypted and, where possible, filtered to hide PHI.

When AI agents operate without a dedicated gateway, none of these technical safeguards are guaranteed. The database can log connections, but it cannot reliably mask column values or enforce just‑in‑time approvals for high‑risk queries. Additionally, without a separate logging component, audit records may reside on the same host that runs the agent, which can limit their reliability for compliance purposes.

Why AI agents need a dedicated gateway

Placing a gateway in the data path solves the missing enforcement layer. The gateway becomes the only point where traffic to PostgreSQL can be inspected, altered, or blocked. This satisfies the requirement that “the only place enforcement can happen” is the data path, not the identity provider or the database itself.

In practice, the gateway performs three essential functions for HIPAA compliance:

  1. It authenticates the AI agent using OIDC or SAML, ensuring the request originates from a known, non‑human identity.
  2. It applies policy checks before the query reaches PostgreSQL, including just‑in‑time approvals for sensitive tables.
  3. It records the full session, masks PHI in responses, and stores the log in a location that is separate from the compute node.

These capabilities turn a raw service account into a compliant access point without requiring developers to rewrite application code.

Continue reading? Get the full guide.

AI Audit Trails + Audit-Ready Documentation: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

How hoop.dev delivers hipaa‑ready controls

hoop.dev sits in the data path between the AI agent and the PostgreSQL server. It verifies the agent’s token, reads group membership, and then enforces policy on every request.

hoop.dev records each session, capturing the full query, the response, the identity that issued it, and the timestamp. The logs are written to a storage backend that the agent cannot reach, providing the reliable audit trail required by HIPAA.

hoop.dev masks sensitive columns in real time, ensuring that PHI never leaves the gateway in clear text. The masking rules are defined centrally and applied consistently across all sessions, satisfying the minimum‑necessary rule.

When a query touches a high‑risk table, hoop.dev routes the request to an approval workflow. A human reviewer must grant temporary access before the query is allowed to proceed. This just‑in‑time approval mechanism prevents unauthorized bulk exports of PHI.

Because hoop.dev is the only component that can block or alter traffic, it fulfills the “only place enforcement can happen” principle. All enforcement outcomes, audit logging, inline masking, JIT approval, and command blocking, exist solely because hoop.dev sits in the data path.

To get started, follow the getting‑started guide and review the learn section for detailed explanations of masking policies and approval workflows.

FAQ

Does hoop.dev replace the database’s native logging?

No. hoop.dev complements native logs by adding a secure, centralized audit trail that includes query results and masking actions, which the database alone cannot provide.

Can I use hoop.dev with existing PostgreSQL users?

Yes. hoop.dev authenticates the AI agent separately and then proxies the connection using its own service credentials, so existing database users remain unchanged.

Is hoop.dev itself HIPAA certified?

hoop.dev does not claim certification. It generates the evidence that auditors look for when evaluating HIPAA compliance for AI‑driven data access.

Explore the source code and contribute at https://github.com/hoophq/hoop.

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