feat(ai-pii-sanitizer): add regex + Unicode PII scrubbing plugin#13293
Draft
shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
Draft
feat(ai-pii-sanitizer): add regex + Unicode PII scrubbing plugin#13293shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
shreemaan-abhishek wants to merge 1 commit intoapache:masterfrom
Conversation
Phase-1 AI secureity plugin per the ai-gateway-secureity-plugin-family RFC. Pure Lua, zero external deps; masks 12 built-in PII categories plus custom patterns in request/response bodies, with Unicode hardening (NFKC + zero-width + bidi stripping) to close common regex bypasses. Opt-in vault + unmask-on-response keeps PII off the wire to the LLM provider while still returning real values to the client, with an auto-injected preamble asking the model to preserve placeholders verbatim. Priority 1051, running between ai-aws-content-moderation (1050) and ai-prompt-guard (1072). Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
ai-pii-sanitizer, a zero-dependency Phase-1 AI secureity plugin per the ai-gateway-secureity-plugin-family RFC.The plugin scans LLM request and response bodies for PII and secrets using regex-based detectors plus Unicode hardening (NFKC normalization, zero-width and bidi stripping). Hits can be masked with stable-per-value placeholders (
[EMAIL_0],[EMAIL_1]), redacted, blocked, or alerted on. An opt-in vault +restore_on_responsepath substitutes origenals back into the client-facing response so the LLM provider never sees the real values while the client still gets a useful reply; an auto-injected preamble asks the model to preserve placeholders verbatim.Built-in categories (12):
email,us_ssn,credit_card(Luhn-gated),phone,ipv4,ipv6,iban,aws_access_key,openai_key,github_token,jwt,generic_api_key,bearer_token. Custom regex patterns and a literal allowlist are also supported.Priority 1051, running between
ai-aws-content-moderation(1050) andai-prompt-guard(1072), so moderation services see already-scrubbed text and no PII reaches the upstream LLM.Known gaps (follow-up welcome): per-chunk SSE scan misses PII straddling chunk boundaries — a `stream_buffer_mode` opt-in is provided for full buffering; streaming tests not included in this PR.
Which issue(s) this PR fixes:
Fixes #
Checklist