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

ModeInputOutput
Report onlyA request with personal dataRequest goes through as is, and is logged
MaskTCKN 10000000146, phone 0532 123 45 67TCKN 100*****46, phone ***4567
PlaceholderCall the customer at 0532 123 45 67…To model: Call the customer at <TELEFON_1>…
RedactTCKN 10000000146TCKN [REDACTED:TC_KIMLIK]
BlockThe same sentence403 pii_blocked; never reaches the model
Secret · blockOPENAI_API_KEY=sk-proj-Q7mZ2xK9…403 secret_blocked
Secret · mask / redactsk-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

GroupTypes
Identity and contactTCKN, phone, email
Official IDsTax ID, passport, license plate, date of birth
Reference numbersCustomer no., account no., policy no.
Cards and accountsCredit card, CVV, expiry date, Turkish and international IBAN
NetworkIP 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]).

SituationHTTPError codeMessage
Secret, Block mode403secret_blockedRequest blocked: credential or secret detected…
Personal data, Block mode403pii_blockedRequest 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.
FeatureLicenseDefault
Secret scanningEvery licenseOn · block
Personal data maskingpii_maskingOff · mask
Response scanningFollows the request settingSame as settings
Event log and countersEvery licenseOn · 90 days
Teams / Slack notificationEvery licenseOff

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).