shreemaan-abhishek opened a new pull request, #13293:
URL: https://github.com/apache/apisix/pull/13293

   ### Description
   
   Adds `ai-pii-sanitizer`, a zero-dependency Phase-1 AI security plugin per 
the [ai-gateway-security-plugin-family 
RFC](https://github.com/api7/rfcs/blob/c0ce47f722ac1721fe3cf2981cd6face70ab88c1/features/ai-gateway-security-plugin-family/README.md).
   
   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_response` path substitutes originals 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) and 
`ai-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
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to