{"slug": "pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii", "title": "PII masking at the LLM gateway: log the redaction, not the PII", "summary": "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.", "body_md": "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.\n\nA common mistake is to keep the original prompt \"for audit\". Then your audit log holds the exact personal data you wanted to protect.\n\nThis is how we handle it in BaseLLM, the self-hosted AI gateway we build at Base Interactive.\n\nThe 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.\n\nThere are five modes:\n\n`TCKN 100***** 46`, `***4567`\n`<TELEFON_1>`, the real value is put back in the answer`[REDACTED:TC_KIMLIK]`\n`403 pii_blocked`, the request never reaches the model\nSecrets (API keys, tokens, connection strings) have their own 29 rules and are blocked by default with `403 secret_blocked`.\n\nRegex 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).\n\n`pii.detection`), and audit records are linked with a SHA-256 chain so a changed record is visible\nSo the log proves the masking happened, without becoming a second copy of the data.\n\nMasking is one technical measure, not full compliance by itself. But it is the part security teams ask about first.\n\nDetails: [https://llm.baseinteractive.com.tr/en/docs/data-masking](https://llm.baseinteractive.com.tr/en/docs/data-masking)", "url": "https://wpnews.pro/news/pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii", "canonical_source": "https://dev.to/ramazangulsen/pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii-4alf", "published_at": "2026-11-20 08:39:48+00:00", "updated_at": "2026-11-20 08:42:25.330719+00:00", "lang": "en", "topics": ["ai-safety", "ai-infrastructure", "large-language-models", "ai-agents", "mlops"], "entities": ["Base Interactive", "BaseLLM"], "also_reported_by": [], "takeaway": "Log redaction events with a SHA-256 hash chain instead of storing original prompts, and add check-digit validation (Turkish ID/tax numbers, IBANs, license plates, Luhn for cards) to cut regex false positives — Base Interactive detected 20 of 22 samples with none.", "recommendation": {"advice": "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.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii", "markdown": "https://wpnews.pro/news/pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii.md", "text": "https://wpnews.pro/news/pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii.txt", "jsonld": "https://wpnews.pro/news/pii-masking-at-the-llm-gateway-log-the-redaction-not-the-pii.jsonld"}}