Skip to content

fix(redact): parcel IDs are not phone numbers - #2591

Closed
Two-Six-Alpha-1115 wants to merge 1 commit into
garrytan:mainfrom
Two-Six-Alpha-1115:fix/phone-e164-parcel-id-false-positive
Closed

Two-Six-Alpha-1115 wants to merge 1 commit into
garrytan:mainfrom
Two-Six-Alpha-1115:fix/phone-e164-parcel-id-false-positive

Conversation

@Two-Six-Alpha-1115

Copy link
Copy Markdown
Contributor

The problem

A county tax-map parcel ID (APN) reads as a national-format phone number to pii.phone.e164 — the same collision class as the digit-only UUID that insideUuid already guards.

parcel_id: "12-3456789.000"   →  MEDIUM pii.phone.e164
norm:      "123456789000"     →  MEDIUM pii.phone.e164

The regex is deliberately loose to catch international formats, and an APN satisfies it in both its punctuated and normalized forms.

This isn't a rare edge. Land, title and property-tax repos carry APNs by the hundred — one title branch tripped 2 MEDIUM findings on nothing but synthetic fixtures, and the same shape recurs in every fixture, mart and smoke in the domain. A guardrail that cries wolf on the domain's primary identifier is one people learn to wave through, which is how a real HIGH finding eventually gets ignored. That's the reason to fix it rather than live with the noise.

The guard

looksLikeParcelId(span, match), wired into the existing validate alongside insideUuid and looksLikeCompactTimestamp, following the same context-window approach insideUuid uses. Two deliberately separate tiers:

  1. Dotted form, exempt on shape. No phone convention puts a dot before a trailing 3–4 digit group after a 4–8 digit middle, so this cannot swallow a real number. Hyphen-only variants (22-0001-000) are not shape-exempted — those genuinely are phone-shaped.

  2. Digits-only form, exempt only on evidence. A bare digit run is phone-shaped in isolation, so it must be the exact digit-normalization of a punctuated APN within a 400-char window. Fixtures and marts always carry the pair; a real phone number has no such twin nearby. This reads the document's own evidence instead of guessing from digits.

Verification

A/B against the unmodified engine over inputs spanning every rule family — AWS key, PEM, GitHub PAT, email, public IP, credit card, SSN, compact timestamp, UUID, and nine phone formats. Exactly one behavior changed: the APN pair. Everything else byte-identical.

New test pins both directions (test/redact-parcel-id-false-positive.test.ts, 15 cases):

  • 9 real phone shapes stay flagged — US dashed/parens/dotted, E.164 US/UK/DE/PT, bare 11-digit
  • 3 APN shapes clean
  • 3 narrowness controls, including the load-bearing one: a bare digit run with no punctuated APN nearby is still flagged

Proven red under mutation. Stubbing the guard to return true — the dangerous blanket-exemption failure, which would quietly gut the pattern — fails 12 of 15. Stubbing to return false fails 3. Restored: 15/15 with the source byte-identical.

Existing suites green: redact-pattern-lint 49/49, gstack-config-redact-keys 6/6, browse/proxy-redact 8/8.

HIGH detection is untouched — PEM, GitHub PAT and Slack token all still block.

A county tax-map parcel ID (APN) reads as a national-format phone number
to `pii.phone.e164` — the same collision class as the digit-only UUID
that `insideUuid` already guards. `12-3456789.000` matches, and so does
its normalized `123456789000`.

This is not a rare edge. Land, title and property-tax repos carry APNs
by the hundred; a single title branch pushed 2 MEDIUM findings, and the
same shape recurs in every fixture, mart and smoke in the domain. A
guardrail that cries wolf on the domain's primary identifier is one
people learn to wave through, which is how a real HIGH finding
eventually gets ignored.

The guard is deliberately narrow, in two tiers:

1. The DOTTED form is exempt on its own shape. No phone convention puts
   a dot before a trailing 3-4 digit group after a 4-8 digit middle.
   Hyphen-only variants (22-0001-000) are NOT shape-exempted — those
   genuinely are phone-shaped.

2. A DIGITS-ONLY span is phone-shaped in isolation, so it earns the
   exemption only by evidence: it must be the exact digit-normalization
   of a punctuated APN within the surrounding window. Fixtures and marts
   carry the pair; a real phone number has no such twin. This reads the
   document's own evidence instead of guessing from digits.

Verified against the unmodified engine over inputs spanning every rule
family (AWS, PEM, GitHub PAT, email, IP, credit card, SSN, timestamp,
UUID, nine phone formats): exactly one behavior changed, the APN pair.

The new test pins both directions and was proven red under mutation —
stubbing the guard to `return true` (the dangerous blanket-exemption
failure) fails 12 of 15; `return false` fails 3.
@trunk-io

trunk-io Bot commented Aug 15, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@garrytan

Copy link
Copy Markdown
Owner

Thank you — this landed in v1.67.0.0 (credited in the CHANGELOG). Closing since the fix is on main. 🙏

@garrytan garrytan closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants