Skip to content

Bug: PII masking leaves the start of an email visible when the local part has an apostrophe or accent #4777

Closed

Description

@yannickmonney

Bug: PII masking leaves the start of an email visible when the local part has an apostrophe or accent

P3. Locally reproduced at current main 4e3c8e40fe05706a5e8796bb30b024b58c1038f9 by the TALE-223 coordinator, with an independent read-only review.

Reproduction and result

With PII protection on in mask mode and every built-in pattern enabled, the shipped scrubber masks only the tail of these addresses:

Input Result on main Expected
mail john.o'[email protected] today mail john.o'[EMAIL] today mail [EMAIL] today
write to jörg.mü[email protected] today write to jörg.mü[EMAIL] today write to [EMAIL] today

The text the model receives still contains the person's first name and part of their surname. In a chat this is also the text Tale stores and shows (docs/en/platform/admin/governance/guardrails.md:34). The apostrophe is an ordinary character of an email local part (RFC 5322 atext) and is common in names such as O'Brien. Non-ASCII local parts are internationalized addresses (RFC 6531). The pattern file names "Punycode/IDNA and quoted local parts" as accepted false negatives and calls its form pragmatic, declining to chase RFC 5322 (configs/platform/system/pii/patterns/email.yml:5-8). Neither input is a Punycode address or a quoted local part, and the result is a partial match that leaks the name, not a miss.

Root

configs/platform/system/pii/patterns/email.yml:12: the local part is [a-zA-Z0-9._%+-]+, so the match starts after the last character outside that class, in the middle of the address. The validator (services/platform/lib/pii/patterns/email.ts) only checks lengths.

Evidence and controls

The probe below ran in an admitted, bounded check under Node vitest (pii project, one worker). Both inputs fail. The control mail [email protected] today gives mail [EMAIL] today.

Probe (uncommitted test in services/platform/lib/pii/)
import { describe, expect, it } from 'vitest';
import { createScrubber } from './index';

const scrubber = createScrubber({
  mode: 'mask',
  patterns: {
    email: true, phone: true, creditCard: true, cvc: true, iban: true, ipAddress: true,
    macAddress: true, jwt: true, ssn: true, dateOfBirth: true,
    address: { locales: '*' }, nationalId: { locales: '*' },
  },
});
const masked = (input: string) => {
  const o = scrubber.scrub(input);
  return o.kind === 'modified' ? o.text : input;
};

describe('email: the whole local part is masked', () => {
  it.each([
    ["mail john.o'[email protected] today", "john.o'"],
    ['write to jörg.mü[email protected] today', 'jörg'],
  ])('%s leaves no part of the address behind', (input, fragment) => {
    expect(masked(input)).not.toContain(fragment);
  });
  it('control: an ASCII dot-atom address is masked whole', () => {
    expect(masked('mail [email protected] today')).toBe('mail [EMAIL] today');
  });
});

Deduplication and acceptance

All 1,385 issues were searched for email masking, apostrophes and partial masking. #1618 (closed) was about several different PII items in one prompt being only partly masked. That is a different cause from a single address being split. The fixture corpus has no apostrophe or non-ASCII local part. services/platform/tests/pii/smoke.test.ts:438-440 scrubs the NFD address mu\[email protected] and asserts only that the text was modified, which the split mü[EMAIL] passes. When that test was added (#1883, 121733ea3), its comment said the regex "matches the ASCII tail '[email protected]'"; #2857 (2743ee48e) dropped the comment. The non-ASCII half was therefore known and tolerated, but never recorded as an accepted limitation.

Acceptance:

  • Mask the whole address when the local part contains RFC 5322 atext characters such as ' or non-ASCII letters, or extend the match back to the token boundary, without swallowing neighbouring text in scripts written without spaces (the frozen ja and zh-Hans corpus records addresses that follow CJK text directly).
  • If any form stays unsupported, record it as an accepted limitation in email.yml and the guardrails guide.
  • The existing email positives and negatives stay green.

Limits: only the scrubber was exercised; the paths that call it were not run.

Activity

  1. added
    agent-ready
    on Oct 29, 2026
  2. added a commit that references this issue on Oct 30, 2026
    09f1396
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions