Control
Sensitive data masking
Sensitive data masking is the layer of BaseLLM, the AI gateway by Base Interactive, that finds personal data and secrets in text bound for the model and masks or blocks them before the request leaves your network. BaseLLM scans the text bound for the model before it leaves your network. It detects personal data in known formats and secrets, and logs every detection. Your applications need no changes.
How it works
Scanning happens inside the gateway, before the request reaches the model. Detection is rule-based and runs entirely on the server; text is never sent to an external service. Settings are per project: your legal project can block while your call center masks.
- Personal data (PII)
identifies a person: Turkish national ID numbers (TCKN), phone numbers, emails, IBANs, card numbers and similar. - Secret
grants system access: API keys, personal access tokens (PAT), passwords, database connection strings. - Masking
partially hide: Part of the value is hidden; the model gets the context but can't see the value. - Redact
remove and label: The value is removed entirely and replaced with its type: [REDACTED:PHONE]. - Placeholder
restored later: The model sees <TELEFON_1>; the real value is put back in the response.
Five modes
| Mode | Input | Output |
|---|---|---|
| Report only | A request with personal data | Request goes through as is, and is logged |
| Mask | TCKN 10000000146, phone 0532 123 45 67 | TCKN 100*****46, phone ***4567 |
| Placeholder | Call the customer at 0532 123 45 67… | To model: Call the customer at <TELEFON_1>… |
| Redact | TCKN 10000000146 | TCKN [REDACTED:TC_KIMLIK] |
| Block | The same sentence | 403 pii_blocked; never reaches the model |
| Secret · block | OPENAI_API_KEY=sk-proj-Q7mZ2xK9… | 403 secret_blocked |
| Secret · mask / redact | sk-proj-… | sk-proj-**** / [REDACTED:SECRET] |
In Placeholder mode the user sees the full text and the model doesn't. It works for standard, streaming and Decisions (JEV) responses. Personal data protection is off by default; when you turn it on, the default mode is Mask. In the API the modes are named mask, redact, block, pseudonymize and report.
Detected types and validation
| Group | Types |
|---|---|
| Identity and contact | TCKN, phone, email |
| Official IDs | Tax ID, passport, license plate, date of birth |
| Reference numbers | Customer no., account no., policy no. |
| Cards and accounts | Credit card, CVV, expiry date, Turkish and international IBAN |
| Network | IP address |
Check digits are validated for TCKN, tax IDs, IBANs, cards and license plates; credit cards use the Luhn algorithm. This keeps order and customer numbers from being masked by mistake. Variants with spaces and dashes are detected too: +90 (532) 123-45-67, ahmet [at] banka.com, TC 100 000 001 46.
Secret scanning
Scanning uses 29 rules in four families: AI, code and DevOps, cloud and services, and generic patterns. It's on in every license and every project, and blocks by default. A project admin can switch the mode to mask (sk-proj-****) or redact ([REDACTED:SECRET]).
| Situation | HTTP | Error code | Message |
|---|---|---|---|
| Secret, Block mode | 403 | secret_blocked | Request blocked: credential or secret detected… |
| Personal data, Block mode | 403 | pii_blocked | Request blocked by PII policy |
Organization settings, logging and license
- Custom pattern
word list or pattern: E.g. POL- + 6 digits; on match, mask, tag only or block. - KVKK Article 6
by keyword: KVKK (Turkey's data protection law) special categories such as health, religion and criminal records; off (default), report, block. - Test box
try before you turn on: Sample text is tested with your saved settings; it's never sent anywhere or stored.
| Feature | License | Default |
|---|---|---|
| Secret scanning | Every license | On · block |
| Personal data masking | pii_masking | Off · mask |
| Response scanning | Follows the request setting | Same as settings |
| Event log and counters | Every license | On · 90 days |
| Teams / Slack notification | Every license | Off |
Raw values are never stored. Only the masked sample, counters and location are kept, and every detection is written to the audit log as pii.detection. Event records are kept for 90 days by default; set PII_EVENT_RETENTION_DAYS to anywhere from 0 to 3650 days. When notifications are on, at most one message is sent per project every 5 minutes, and the message never includes the secret itself.
Frequently asked questions
How does PII masking work in an LLM gateway?
The request is scanned inside BaseLLM with rule-based detection before it reaches the model. Depending on the mode, a match is masked, replaced with a placeholder, redacted, or the request is blocked with 403. The text is never sent to an outside service. See Five modes.
Is masked data written to the audit log?
Raw values are never stored in any record. Every detection is written to the Audit Log as pii.detection, holding only the masked sample, counters and location. A SHA-256 fingerprint chain shows whether an audit record was changed.
Which personal data types are detected?
Turkish ID number, phone, email, tax ID, passport, licence plate, date of birth, customer / account / policy number, credit card, CVV, expiry date, Turkish and international IBAN, and IP address. Names and addresses are out of scope; you can define an organisation-specific pattern for them.
Do we need to change our applications?
No. Scanning happens in the gateway; your application only connects to the OpenAI-compatible endpoint. Rules are switched on and off per project.
Is this enough for KVKK or GDPR?
Masking is one technical measure; full compliance depends on your organisation's legal assessment. BaseLLM supports it with records, masking and keyword checks for special-category data (KVKK article 6).