Gateway-Level PII Redaction Before Provider Transmission
Sensitive Information Disclosure ranks second in the 2025 OWASP Top 10 for LLM Applications, covering the exposure of personally identifiable information (PII), credentials, and health records through the inputs and outputs of large language model applications. Every prompt an application sends to a third-party provider can carry names, email addresses, account numbers, and other regulated data, and once that text leaves your infrastructure you no longer control where it is logged or retained. Gateway-level PII redaction addresses this by detecting and rewriting sensitive values in the request path before any data reaches an external provider. Bifrost, the open-source AI gateway built in Go by Maxim AI, applies redaction as a policy at the gateway, so every model call across every provider passes through the same controls. This post covers how PII exposure happens in LLM requests and how to configure redaction before provider transmission.
What Is Gateway-Level PII Redaction
Gateway-level PII redaction is the practice of detecting sensitive data in an LLM request at a central proxy and rewriting or removing that data before the request is forwarded to a model provider. Instead of relying on each application to sanitize its own prompts, redaction runs once at the gateway that sits between your applications and every provider. This makes the control uniform, auditable, and independent of the code that generated the prompt.
The distinction that matters is placement. Application-level scrubbing depends on every team implementing the same logic correctly, and any service that skips it becomes a leak. A gateway enforces one policy on the request path that carries traffic to OpenAI, Anthropic, AWS Bedrock, Google Vertex AI, and other providers, which means a single configuration governs sensitive data handling everywhere.
Why PII Exposure in LLM Requests Matters for AI Teams
The prompt itself is a threat vector. Security analysis of LLM deployments increasingly treats the request, not just the response, as a source of sensitive-data disclosure, because prompts are logged, transmitted across services, and processed by third-party APIs. Research from Truffle Security cited by Duality Technologies found roughly 12,000 live API keys and passwords in a single major training-dataset crawl, a reminder that credential and PII leakage into model pipelines is a measured problem, not a hypothetical one.
Three properties of LLM request traffic make this difficult to contain:
- Loss of control after transmission. Once a prompt reaches an external provider, retention, logging, and downstream use are governed by that provider's terms, not yours.
- Distributed prompt assembly. Applications assemble prompts from system instructions, retrieved context, and conversation history, so PII can enter from sources the calling code never inspected. Academic work on indirect prompt injection for privacy extraction shows attackers can also engineer prompts to surface user data.
- Regulatory scope. Names, emails, national identifiers, and health data are regulated under frameworks such as GDPR and HIPAA. Sending them to a provider without controls creates compliance exposure that is hard to remediate after the fact.
For teams running AI in production, this is where a gateway earns its place. Routing all traffic through Bifrost gives you one enforcement point where sensitive data is detected and rewritten before it crosses a network boundary, backed by the governance model that already controls access, budgets, and rate limits.
Where PII Leaks in the LLM Request Path
PII enters the request path at several points, and each is invisible to controls that only inspect the final application database:
- Direct user input. End users paste emails, account numbers, and identifiers into chat interfaces.
- Retrieved context. RAG pipelines pull documents that contain PII into the prompt at query time.
- Conversation history. Multi-turn sessions accumulate sensitive values from earlier messages and replay them on every subsequent call.
- Logs and traces. Even when the model call is acceptable, raw prompts written to logs or exported to observability backends can persist PII well beyond the request.
A redaction layer has to address both the live payload sent to the provider and the copies of that payload that land in logs and trace exports. Handling only one leaves the other exposed.
How Bifrost Redacts PII Before Provider Transmission
In Bifrost, redaction is implemented through guardrails that validate requests and responses in real time against policies you define. Guardrails are built around two concepts: rules, written in Common Expression Language (CEL), that determine when and what content is evaluated, and profiles, which define how content is checked. Input guardrails inspect a request before the gateway forwards it to the provider, which is exactly the enforcement point gateway-level redaction requires.
For PII specifically, the Custom Regex guardrail evaluates request and response text against patterns you define and ships with a built-in PII Detection template. The template pre-fills common patterns for:
- Email addresses
- US phone numbers
- US Social Security numbers
- Credit-card-like numbers
- IPv4 addresses
Custom Regex runs in-process using Go's RE2-compatible engine, so pattern checks add negligible overhead to the request. Because it is pattern-based rather than semantic, teams can extend it with organization-specific patterns for internal IDs, project names, or non-US national identifiers. When a pattern matches, the gateway applies the configured action: detect only, block, or redact.
Credential leakage is handled separately by the Secrets Detection guardrail, which uses embedded Gitleaks rules to catch API keys, tokens, and private keys in prompts and completions. Running PII redaction and secrets detection together on the same request covers both personal data and leaked credentials in one pass. For semantic PII classification beyond regex, Bifrost also supports Microsoft Presidio and Azure AI Language PII as guardrail profiles.
A typical Custom Regex profile for PII redaction is configured through the dashboard or the management API:
curl -X POST <http://localhost:8080/api/guardrails/regex> \
-H "Content-Type: application/json" \
-d '{
"name": "pii-detection",
"enabled": true,
"config": {
"patterns": [
{
"pattern": "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b",
"description": "Email address",
"entity_type": "EMAIL",
"flags": "i",
"action": "redact",
"redaction_strategy": "replace",
"redaction_mode": "runtime"
}
]
}
}'
Redaction Strategies and Modes
When a guardrail's action is set to redact, the gateway rewrites matched text rather than blocking the request outright. This keeps applications functional while removing sensitive values from what the provider receives. Bifrost supports three redaction strategies that control the replacement value:
- Replace substitutes the match with its entity type, so
alex@example.combecomes[EMAIL]. - Mask preserves approximate length, producing
[EMAIL:****************]. - Hash substitutes a deterministic short hash, producing
[EMAIL:8c7dd922ad47494f], which lets you correlate repeated values without exposing them.
Redaction mode then decides where the rewrite applies, which is what separates a partial control from a complete one:
- Runtime redacts the live request or response so sensitive text never reaches the provider or the caller, and stores the already-redacted value in logs.
- Logs only leaves the runtime payload raw but redacts Bifrost logs and trace-export connector content, useful when the model call must proceed with original text but stored copies must not.
- Runtime plus reversible logs redacts the runtime payload and writes reversible placeholders such as
[EMAIL-1]to logs, so a permitted user can reveal original values for audit or debugging.
Because these modes cover the runtime payload, Bifrost logs, and trace-export connectors together, redaction closes the gap where sensitive data survives in stored copies after the live request is clean. Redaction can also run on outputs, and for streaming responses the gateway accumulates the full response before evaluating it so redaction applies to complete content.
Building a Compliance-Ready Redaction Layer
Redaction is one control in a broader data-governance posture, and Bifrost pairs it with the mechanisms regulated teams need. Virtual keys scope which consumers, teams, and projects can send traffic, and data access control restricts what each identity can reach. Audit logs produce immutable trails suited to SOC 2, GDPR, HIPAA, and ISO 27001 evidence, recording guardrail interventions alongside access events.
For organizations that cannot let request data traverse public networks at all, in-VPC deployment keeps the gateway and its logs inside private infrastructure with no public egress. Combined with redaction, this means sensitive prompts are both rewritten before provider transmission and confined to a controlled network perimeter. These capabilities are why Bifrost is positioned for enterprises and regulated industries where data handling is audited rather than assumed.
Setting up a redaction layer follows a consistent path:
- Route application traffic through Bifrost as a drop-in replacement by changing the base URL in existing SDK code.
- Enable the Custom Regex PII Detection template and add organization-specific patterns.
- Add the Secrets Detection guardrail to catch leaked credentials in the same request.
- Set the action to redact and choose a strategy and mode that match your logging and reveal requirements.
- Attach the profiles to rules scoped to the inputs, outputs, or both that need protection.
Placing redaction at the gateway means these steps are done once rather than in every service, and the governance layer applies them uniformly across all connected applications and providers.
Getting Started with Bifrost
Gateway-level PII redaction removes the reliance on every application to sanitize its own prompts and replaces it with one enforcement point on the request path. With Bifrost, you can detect PII with regex and semantic profiles, catch leaked secrets, and rewrite both the live payload and its stored copies before any data reaches an external provider, all governed by the same virtual keys, audit logs, and access controls that manage the rest of your AI traffic. Explore the Bifrost documentation and the governance resources to see how the pieces fit together.
To see how gateway-level PII redaction and governance work for your workloads, book a demo with the Bifrost team.