Skip to main content
Back to Community & Earn Hub

SOC 2 Type II & HIPAA Compliance for US Enterprise AI Agents: Implementing Zero-Retention LLM Gateways, PII Redaction, and Immutable Audit Trails

@rohan_mehta4 days ago·2 min read 2000 views
SOC 2 Type II & HIPAA Compliance for US Enterprise AI Agents: Implementing Zero-Retention LLM Gateways, PII Redaction, and Immutable Audit Trails

Passing US Enterprise InfoSec Questionnaires

Every B2B AI startup selling into the US market eventually hits the same 200-question SOC 2 Type II / HIPAA Security Questionnaire from a prospective Fortune 500 or healthcare buyer:

  • "Do your sub-processors retain customer prompts or train on PHI/PII?"
  • "Can you prove what exact database rows and external APIs your autonomous agent touched during a user session?"
  • "Is customer data guaranteed to stay inside US-East / US-West regions?"

Answering these cleanly requires architectural enforcement at your LLM & MCP Gateway, not just legal PDFs.


Compliance Gateway Architecture (US-East Zero Retention)

text
[US Enterprise User / SaaS App]
         │
         ▼
[1. Local Presidio PII / PHI Scrubber (<12ms)]
  • Masks SSNs, MRNs, Credit Cards, Emails -> Reversible Vault Tokens (<SSN_1>)
         │
         ▼
[2. Zero-Data-Retention (ZDR) Regional Gateway]
  • AWS Bedrock (us-east-1) / Anthropic ZDR / VPC vLLM (BAA-covered)
  • Zero prompt logging on provider side
         │
         ▼
[3. Immutable WORM Audit Trail (S3 Object Lock / Append-Only Postgres)]
  • Logs {actor_id, tool_name, args_hash, policy_decision, timestamp_utc}

Python PII Tokenization Middleware Before LLM Egress

Instead of stripping PII destructively (which breaks downstream tool calls like lookup_patient_id), replace sensitive fields with session-scoped reversible placeholders before tokens ever leave your VPC:

python
from presidio_analyzer import AnalyzerEngine
import uuid

analyzer = AnalyzerEngine()

class ReversiblePiiVault:
    def __init__(self):
        self.token_map: dict[str, str] = {}

    def redact_before_llm(self, text: str) -> str:
        results = analyzer.analyze(
            text=text,
            entities=["US_SSN", "CREDIT_CARD", "PHONE_NUMBER", "EMAIL_ADDRESS"],
            language="en",
        )
        # Replace from right to left so character offsets stay valid
        redacted = text
        for res in sorted(results, key=lambda r: r.start, reverse=True):
            original = text[res.start:res.end]
            placeholder = f"<{res.entity_type}_{uuid.uuid4().hex[:6]}>"
            self.token_map[placeholder] = original
            redacted = redacted[:res.start] + placeholder + redacted[res.end:]
        return redacted

    def restore_for_authorized_tool(self, tool_args: dict) -> dict:
        # Re-hydrate inside trusted VPC only when executing an authorized internal tool
        serialized = str(tool_args)
        for placeholder, original in self.token_map.items():
            serialized = serialized.replace(placeholder, original)
        return eval(serialized)  # Use recursive dict walk in production

Key US Compliance Controls Auditors Check

  1. Signed BAAs + Zero Data Retention (ZDR): Standard consumer/developer API tiers often retain logs for 30 days for abuse monitoring. Enterprise healthcare/fintech requires explicit ZDR flags or AWS Bedrock/Azure Private Link inside us-east-1.
  2. Immutable Tool Audit Logs: Store every MCP tool invocation in an S3 Object Lock (WORM) bucket or append-only audit table so neither admins nor compromised agents can erase execution history.
  3. Tenant-Isolated Encryption Keys (CMK): Use AWS KMS Customer-Managed Keys per enterprise tenant for vector/episodic memory stores.
3 Comments

Discussion

@elena_rostova3 days ago

Spot on for US healthcare and fintech InfoSec reviews. We also require AWS KMS Customer-Managed Keys (CMK) on the S3 Object Lock audit bucket—several Fortune 500 CISO teams explicitly check for tenant-isolated CMK revocation in their SOC 2 Type II vendor review.

Reversible PII tokenization before egress is the cleanest way to pass US healthcare InfoSec reviews. The model reasons over <US_SSN_8f2a1b> seamlessly without raw PHI ever touching external LLM inference servers.

@siddharth_rao4 days ago

S3 Object Lock (WORM) for MCP tool audit logs is a huge checkbox for SOC 2 Type II auditors—it proves nobody can retroactively alter what an autonomous agent modified.

Join the developer discussion

Sign in or create a free account to comment (+10 pts) and tag helpful AIStoreHub repositories.