Skip to content

Four copies of the email-masking regex disagree, so josé@example.com reaches the Assay engine unmasked while PEOPLE masks it #2866

Open

Description

@drpaulobernardy

Summary

The email pattern the scrubbers use for masking is defined in four files, in two different forms. Two are ASCII-only: LIFEOS/RELAY/context/Status.ts:79 and LIFEOS/ASSAY/Engine.ts:150 (used by redactForEngine, :173, on text sent to the engine). Two accept Unicode letters: LIFEOS/PEOPLE/Identity.ts:73 and LIFEOS/RELAY/bridge/record.ts:133. On the same text, "write to josé@example.com" is masked by the Unicode two and left whole by the ASCII two, and "write to a%b@example.com" becomes "write to a%[email]" in Engine.ts. Addresses with non-ASCII characters are uncommon, so the practical reach is small (not measured). Measured on 94bd8f2.

Where

  • ASCII: LIFEOS/RELAY/context/Status.ts:79, LIFEOS/ASSAY/Engine.ts:150
  • Unicode: LIFEOS/PEOPLE/Identity.ts:73, LIFEOS/RELAY/bridge/record.ts:133

Repro

From the repo root, bun emails.ts, with emails.ts:

import { readFileSync } from "node:fs";
const copies = { "LIFEOS/RELAY/context/Status.ts": "EMAIL", "LIFEOS/ASSAY/Engine.ts": "EMAIL_RE",
  "LIFEOS/PEOPLE/Identity.ts": "EMAIL", "LIFEOS/RELAY/bridge/record.ts": "EMAIL" };
for (const s of ["write to josé@example.com", "write to a%b@example.com"]) {
  console.log(JSON.stringify(s));
  for (const [f, name] of Object.entries(copies)) {
    const src = readFileSync(`LifeOS/install/${f}`, "utf8").match(new RegExp(`const ${name} = (/.*/[a-z]*);`))![1];
    console.log("  " + f.padEnd(34), JSON.stringify(s.replace(eval(src), "[email]")));
  }
}

Output:

"write to josé@example.com"
  LIFEOS/RELAY/context/Status.ts     "write to josé@example.com"
  LIFEOS/ASSAY/Engine.ts             "write to josé@example.com"
  LIFEOS/PEOPLE/Identity.ts          "write to [email]"
  LIFEOS/RELAY/bridge/record.ts      "write to [email]"
"write to a%b@example.com"
  LIFEOS/RELAY/context/Status.ts     "write to [email]"
  LIFEOS/ASSAY/Engine.ts             "write to a%[email]"
  LIFEOS/PEOPLE/Identity.ts          "write to [email]"
  LIFEOS/RELAY/bridge/record.ts      "write to [email]"

Fix

Root cause: each scrubber keeps its own copy of the pattern, so the Unicode form that PEOPLE/Identity.ts and record.ts use never reached the other two. A general fix is one module that holds the contact patterns and that every scrubber imports: a change to the pattern then reaches all of them at once, and they can no longer disagree.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions