Imagine every AI‑driven workflow that touches protected health information generating a reliable audit trail, with each read or write either masked or approved before it reaches the database. In that world auditors can verify who accessed PHI, what was seen, and whether any data was exposed, all without slowing down legitimate model inference.
HIPAA expects covered entities to enforce the minimum‑necessary principle, to maintain detailed audit logs, and to protect PHI at rest and in transit. For AI agents that query patient records, this means three concrete controls: identity‑based access that limits each request to the exact data elements needed, real‑time masking of any PHI that should not be returned, and a permanent, replayable record of every interaction.
Today many organizations store a static credential in a secret manager, let the agent connect directly to the database, and grant the credential broad read permissions. The result is a single point of failure. If the credential is compromised, an attacker can exfiltrate the entire dataset. Even when the credential is safe, the organization lacks per‑request visibility, cannot prove that an agent only accessed the minimum data, and cannot demonstrate approval for risky queries.
The first step toward compliance replaces static, standing credentials with identities that an identity provider issues on demand. AI workloads receive short‑lived OIDC or SAML tokens tied to a service account, and those tokens carry group membership that maps to a narrowly scoped role in the gateway configuration. However, without a control point that sits between the identity verification and the target database, the request still flows unchecked. No audit log is generated, no PHI is masked, and no human can intervene on a suspicious query.
hipaa compliance through a data‑path gateway
hoop.dev provides the missing control surface. It is a Layer 7 gateway that sits in the data path for every supported target, databases, Kubernetes clusters, SSH hosts, and internal HTTP services. The gateway authenticates the AI agent’s OIDC token, then proxies the connection to the backend. Because the proxy is the only place the traffic passes, hoop.dev can enforce all HIPAA‑required controls.
Setup: identity and least‑privilege grants
AI workloads receive short‑lived tokens from the organization’s identity provider. Those tokens carry group membership that maps to a narrowly scoped role in hoop.dev’s configuration. The role tells hoop.dev exactly which tables or API endpoints the agent may reach. This setup decides who the request is, but it does not enforce any protection on its own.
The data path: inspection and enforcement
When the agent initiates a connection, hoop.dev becomes the sole conduit. At this point hoop.dev inspects each query, masks any PHI fields that are not needed for the model, and, if the query matches a risk pattern, pauses the request for a manual approval. Because the gateway sits between the token and the target, hoop.dev is the only place enforcement can happen.
Enforcement outcomes: audit, masking, approval, and replay
hoop.dev records every session with a timestamp, the identity that initiated it, and the full request‑response payload (with masked fields redacted). hoop.dev allows replay of the recorded session for forensic analysis, satisfying HIPAA’s audit‑trail requirement. Inline masking ensures that downstream systems never see unnecessary PHI, supporting the minimum‑necessary rule. Just‑in‑time approval adds a human checkpoint for high‑risk operations, providing a signed record that a qualified individual reviewed the request before execution.
If you remove hoop.dev from the data path, you lose these outcomes. The identity check still happens, but the request flows directly to the database, leaving no log, no masking, and no approval point.
Generating evidence for HIPAA audits
HIPAA auditors look for three artifacts: a record of who accessed PHI, what data was accessed, and whether the access complied with policy. hoop.dev produces each artifact automatically. The session log ties the OIDC token to the exact SQL statement, while the masking layer proves that only allowed columns were returned. Approval workflows create a signed record of the reviewer’s decision, which hoop.dev stores alongside the session log.
Because hoop.dev is open source and self‑hosted, organizations can store logs in their own immutable storage solution, aligning with internal retention policies. hoop.dev’s declarative configuration makes it easy to demonstrate that the same controls apply across all environments, from development to production.
Getting started
To adopt this approach, deploy the gateway near your AI workloads, configure OIDC authentication, and define scoped roles for each agent. Detailed instructions are available in the getting‑started guide. The learn section explains how to model masking rules and approval policies for PHI.
FAQ
- Do I need to change my existing AI code? No. The agent connects using the same client libraries (for example, the PostgreSQL driver). The only change is the endpoint, which now points at the gateway.
- How long are session logs retained? Retention is controlled by the storage backend you choose. hoop.dev does not impose a limit; you can configure any retention period that satisfies your audit policy.
- Can I audit a specific query after the fact? Yes. hoop.dev stores each session with full request and response metadata (masked as configured), and you can replay the session to see exactly what the AI agent saw.
Ready to see the code in action? Explore the open‑source repository on GitHub and start building a HIPAA‑ready AI pipeline today.