How to test that identifiers never reach your logs
· 5 min read
“We mask identifiers before they are logged” is easy to say and hard to prove. A review of the code tells you what the author intended. A canary test tells you what the system does.
The method
- Make canaries. Generate synthetic identifiers that the detector will recognise: an Aadhaar number with a valid checksum, a PAN, a phone number and an account number with its usual label. Never use real people’s data.
- Plant them everywhere text can enter. The purpose, source and field names of an agent request. A malformed request body. A prompt sent for inspection. A destination URL. A model call. A tool call. Then the fields an operator can type in: names, owners, support tickets.
- Search every place data can land. A full dump of the gateway’s database, not only the audit table. The audit export in JSON and CSV. Traces, alerts, metrics and the process logs.
- Fail if any canary appears. And make sure the test can fail: an empty database dump should fail the run, since it proves nothing.
What it found in our product
We already had this test running in memory with a fake detector. Running it against the real stack, with Postgres and the real detector, found two things the in-memory version did not:
- Operator-typed text was stored as typed. A support ticket’s title and detail, and an agent’s owner field, held whatever an administrator pasted. Both now refuse text that contains an identifier, with a unit test for each.
- A bare 13-digit number is not an identifier. The detector needs a cue such as “A/c no.” before it treats a long number as an account number, so a bare number in a field name reached the audit record. This is a design limit of context-based detection, not a bug. We moved the canary’s cue into the test and documented the limit.
Why bother
An audit log that holds personal data becomes a liability. Under India’s DPDP Act, the log you keep to prove compliance should not itself be a store of the data you promised to protect. Proving it once is not enough: the canary run belongs in CI, so a new log line or a new field cannot quietly break the promise.
The same method works for any gateway or agent platform. Start with the dump of the whole database, because that is where the surprises are.
Where to go next
Our trust page states what has been tested and what has not. The platform page lists the identifier types the detector looks for, and security and deployment explains where data stays.