Repository navigation
VeilStream: stop SINs, addresses, names and wrapped PII reaching the model - #11
Open
PermutationResearch wants to merge 1 commit into
Open
PermutationResearch wants to merge 1 commit into
PermutationResearch wants to merge 1 commit into
Conversation
… the model
Through the proxy's default regex detector, these values reached the
upstream model in clear (fake data, local echo upstream):
- Canadian SIN / NAS in any format ("046 454 286", "046-454-286",
"sin":"046454286"); only the US 3-2-4 SSN shape was matched.
- Street addresses and postal codes ("1234 Rue Sainte-Catherine Ouest",
"88 boulevard René-Lévesque Est", "77 Main Street", "H3G 1P1"); the
server detector had no address pattern.
- Names with accents or hyphens, names after French introductions
("je m'appelle Élodie Gagnon-Bouchard"), and names in "name" fields.
- Any value wrapped onto the next line: name, card, SIN and email.
Detection changes in src/veilstream/detector.ts:
- SIN: any 9-digit format next to SIN / NAS / social insurance /
assurance sociale, or a 3-3-3 grouped number with a valid Luhn digit.
- ADDRESS: French order (number, street type, name, direction) and
English order (number, name, street type); POSTAL_CODE: Canadian codes.
- PERSON: Unicode name words, French introductions, courtesy titles
(M., Mme, Dr.), and quoted or unquoted name fields.
- Patterns read a single line break as a space, with offsets unchanged,
so wrapped values match; a blank line still separates form fields, a
word followed by a colon is a field label, and trailing whitespace is
left outside the masked span. Emails match across a break next to @.
- Capture-group offsets come from the `d` flag instead of assuming the
group ends the match, which was wrong for "name":"…" fields.
The default policy redacts SIN, ADDRESS and POSTAL_CODE irreversibly, as
it already does for SSN, so a reply shows [SIN] or [ADDRESS] where the
original value was. Names, emails, phones and cards still round-trip.
Measured with the server detector, main -> this branch:
- 600-case generated corpus: recall 0.393 -> 0.445 (ADDRESS 0/75 -> 33/75,
PERSON 149/675 -> 224/675); cases with a false mask unchanged at 75.
- Structured benchmark (4000): ADDRESS 0/853 -> 257/853, SSN 496 -> 566
of 608. France set (257): ADDRESS 0/274 -> 16/274.
- New masks outside labelled spans are real PII those sets leave
unlabelled (names in card/ID-only sets, addresses, postal codes) plus
three 9-digit numbers that happen to pass the SIN check.
test/veilstream-pii-leaks.test.ts covers each leak (all 8 failed before)
and ordinary text that must stay untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An end-to-end check of the private chat proxy found values going to the upstream model unmasked. The test used fake data and a local echo upstream.
046 454 286, street addressÉlodie Gagnon-Bouchard, NAS046-454-286, address88 boulevard René-Lévesque Est"name":"Paul Roy","sin":"046454286",77 Main StreetThe same script re-run through the real proxy on this branch: no case leaks any value.
What changed (
src/veilstream/detector.ts,policy.ts)88 boulevard René-Lévesque Est), English order (77 Main Street), and Canadian postal codes. Before this, the server detector had no address pattern at all.je m'appelle,mon nom est,je suis), courtesy titles (M.,Mme,Dr.), and quoted or unquoted name fields.@.dflag. Before, the code assumed the group ended the match, which was wrong for"name":"…".Trade-off: SIN, ADDRESS and POSTAL_CODE use the policy's irreversible redaction, as SSN already does. The model's reply therefore shows
[SIN]or[ADDRESS]where the user's original value was. Names, emails, phones and cards still round-trip exactly.Measured (server detector,
main→ this branch)The structured sets now have more cases with a mask outside a labelled span: 2255 → 2562 of 4000, and 134 → 184 of 257 for France. I reviewed the new masks. They are real PII those sets don't label:
45 Avenue des Champs-Élysées;Two genuine over-masks found during review were fixed before this commit: names joined across a blank line into the next form label, and card numbers consuming the following line break.
Tests
test/veilstream-pii-leaks.test.ts: one test per leak, all 8 seen failing onmain, plus ordinary text that must stay untouched ("Order 123 456 789", "The Montreal Canadiens won", "Je suis content").npm run typecheckpasses; Biome and ESLint are clean on changed files.DEV_MODE=true npm test: 697 of 698 pass. The failure is the live-inspector jailbreak test, which hits a cold ML inspector on port 8001 and exceeds its 2 s timeout. It fails, then passes, on rerun, so it is unrelated to this change.Not in this PR
packages/veilstream-browserhas its own copy of the regex detector, still without these fixes. The server build compiles onlysrc/, so merging the two detectors means changing how they are built and shared. That is a separate change.PII_DETECTOR_URL), not more regex.🤖 Generated with Claude Code