cd /news/ai-safety/pii-masking-at-the-llm-gateway-log-t… · home › topics › ai-safety › article
[ARTICLE · art-173135] src=dev.to ↗ pub= topic=ai-safety verified=true sentiment=↑ positive

PII masking at the LLM gateway: log the redaction, not the PII

Base Interactive built PII masking into BaseLLM, its self-hosted AI gateway, that scans prompts server-side before they reach the model and logs only the redaction events rather than the original text. The gateway offers five masking modes, validates check digits for Turkish ID and tax numbers, IBANs, license plates and Luhn for cards, and blocks secrets by default with a 403 response. In the company's own test set of 22 realistic samples, 20 were detected with no false positives, and audit records are linked with a SHA-256 chain so tampering is visible.

recommendation

Mask PII at the gateway before prompts reach the model, block secrets by default, and log only redaction events with a hash chain rather than retaining original prompts.

more in playbook: Securing agents and AI tools
by read1 min views2 publishedNov 20, 2026

If you put an LLM gateway in front of your models, sooner or later someone pastes a customer record into a prompt. Masking it is the easy part. The harder question is what you write to your own logs. A common mistake is to keep the original prompt "for audit". Then your audit log holds the exact personal data you wanted to protect.

This is how we handle it in BaseLLM, the self-hosted AI gateway we build at Base Interactive.

The gateway scans the text before it reaches the model. Detection is rule based and runs on the server, so the text is not sent to another service for checking. Settings are per project.

There are five modes:

TCKN 100***** 46, ***4567 <TELEFON_1>, the real value is put back in the answer[REDACTED:TC_KIMLIK] 403 pii_blocked, the request never reaches the model Secrets (API keys, tokens, connection strings) have their own 29 rules and are blocked by default with 403 secret_blocked.

Regex alone masks too much. An 11 digit order number looks like a Turkish ID number. So we validate check digits for Turkish ID and tax numbers, IBANs, license plates, and Luhn for cards. In our own test set of 22 realistic samples, 20 were detected with no false positives. Names and addresses can't be found with patterns, so they are out of scope (you can add your own patterns).

pii.detection), and audit records are linked with a SHA-256 chain so a changed record is visible So the log proves the masking happened, without becoming a second copy of the data.

Masking is one technical measure, not full compliance by itself. But it is the part security teams ask about first.

Details: https://llm.baseinteractive.com.tr/en/docs/data-masking

── more in #ai-safety 4 stories · sorted by recency
── more on @base interactive 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/pii-masking-at-the-l…] indexed:0 read:1min 2026-11-20 · —