Skip to content

fix(pii): stop reporting timestamps, matrices, and vectors as PII - #304

Merged
rng1995 merged 8 commits into
mainfrom
naren/port-numeric-pii-fp
Nov 5, 2026
Merged

rng1995 merged 8 commits into
mainfrom
naren/port-numeric-pii-fp

Conversation

@rng1995

@rng1995 rng1995 commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Tier 1 PII scans judged numeric values by their shape alone. This PR checks each numeric candidate against its context as well.

Credit cards

  • A card-shaped number is skipped when a timestamp or digest label directly precedes it. Examples: timestamp_microseconds:, epoch nanoseconds =, "unix_time":, sha256:, checksum=, "sha256" ". Underscores separate words, so snake_case prefixes count too: event_timestamp:, "created_at_epoch":, file_sha256:. CamelCase prefixes such as eventTimestamp are not covered. The label check looks at no more than 100 characters before the number and must end right at the number. So a timestamp field does not hide a card number in a later field on the same line.
  • The card regex boundary changes from (?<![\d.])...(?!\d) to (?<![A-Za-z0-9.])(?<![A-Za-z0-9]_)...(?![A-Za-z0-9])(?!_[A-Za-z0-9]). Digits embedded in a longer ASCII token, such as a hex digest, id_1707938736269577 or 1707938736269577_suffix, no longer match. An underscore blocks a match only when it joins the number to a letter or digit, so a card in Markdown underscore emphasis (_4532015112830366_, __4532015112830366__) is still reported, as on main. The classes are ASCII on purpose. Python's \w would also match CJK, Hangul, Thai and accented letters, and Chinese, Japanese, Korean and Thai prose often writes a number directly between letters (カード番号は4532015112830366です). Such a card is still reported, as it is on main. The float guard and the long-digit-run guard still apply.
  • Numeric test-card exceptions (4111111111111111, 5500-0000-0000-0004, ...) are now compared with each candidate's digits, and they no longer exclude the whole line. A test card written with spaces (4111 1111 1111 1111) is excepted. A test card no longer hides a different card number on the same line.
  • The numeric exceptions add other widely published processor test cards: 4242424242424242, 4000056655665556, 4012888888881881, 5555555555554444, 5105105105105100, 2223003122003222, 6011111111111117 and 3530111333300000. A payment skill that lists several of them on one line, such as Cards: 4111111111111111, 4242424242424242, still passes.

Phone numbers

  • An international phone candidate that starts inside a scientific-notation literal is skipped. Example: the +00 exponent of 1.000000e+00. Other candidates on the line are still checked, so a real number after a matrix value is reported. The literal lookup is bounded to a 128-character window around the candidate.

GPS coordinates

  • A GPS-shaped pair now needs a geospatial cue. Accepted cues are:
    • GPS, geolocation, latitude/longitude, lat/lon/lng/LatLng, latlon/latlong/lonlat/lnglat keys, WGS 84, degrees or °;
    • an RFC 5870 geo: URI, or a map link: maps.google.*, google.<tld>/maps, maps.apple.com, openstreetmap.org or bing.com/maps. Host forms are bounded, so long lines stay linear;
    • a GeoJSON "type" of Point, LineString, Polygon, their Multi forms, Feature, FeatureCollection or GeometryCollection, or a "geometry": { member (it comes before "coordinates" when keys are sorted). Feature, the collection types and geometry are matched case-sensitively, as GeoJSON spells them, so "type": "feature" in other JSON is not a cue;
    • location, office or address.
  • The cue can be on the pair's line, on one of the two lines before it, or in the file name. Underscores count as word separators, so gps_coordinates: and start_lat count as cues.
  • Some labels mark the pair as technical data: waypoint, quaternion, pose, vector, calibration, roi, scale, coordinates =, and <pixel|texture|camera|...> coordinates. These labels outweigh location/office/address wording. They do not outweigh a GPS or latitude/longitude cue nearby.
  • The decision is made once per line, so long lines stay linear.

Docs

  • docs/tier1-validation.mdx (the pii accordion) and the comments in pii_patterns.yaml describe the rules, including the location forms that are no longer reported.
  • There is a CHANGELOG entry under Unreleased / Fixed.

Why

Ordinary technical content in a skill produced PII findings, and some of them blocked the gate:

  • Luhn-valid timestamps and hash digits (for example timestamp_microseconds: 1707938736269577) were reported as CRITICAL credit cards. validate <skill> --checks pii --tiers 1 on such a file ended with "Possible credit card number" and exit 1. It now passes with exit 0.
  • Scientific-notation matrices (1.000000e+00 0.000000e+00 ...) were reported as the phone number +00 0.000000. Because only the first match on a line was considered, that false positive could also hide a real phone number later on the line.
  • Robotics and graphics vectors (waypoints, poses, quaternions, calibration pairs) were reported as GPS coordinates.
  • A line holding a known test card and a real card, such as known=4111111111111111; card_number=4532015112830366, was dropped completely, so the real card was missed.

Behavior changes to note

  • Test cards. A test card no longer hides other numbers on its line. A Luhn-valid card next to a test card is now a CRITICAL finding, unless it is one of the listed test cards or the line has a textual exception such as test card, example or for testing. Textual exceptions are matched case-sensitively, as on main, so Test cards: does not trigger the test card exception. A line that lists only listed test cards passes, in any grouping. A line with only newly listed numbers (for example Visa 4012 8888 8888 1881, Discover 6011111111111117) also passes now. On main it failed.
  • GPS. A decimal pair with no cue on its line, the two lines before it, or the file name is no longer reported. Examples:
    • an unlabelled pair such as 37.123456, -12.654321;
    • coordinates: 37.7749, -122.4194;
    • prose such as Meet me at 37.7749, -122.4194;
    • an unlabelled YAML key such as home: 37.774929, -122.419416.
  • GeoJSON. Only positions within two lines of a cue are reported. A pretty-printed LineString with one position per line and four positions gives one finding instead of four. The file is still flagged. A position whose only cue is a "type" after "coordinates" is reported when a "geometry": { line is within two lines above it.
  • Labelled forms are still reported. Examples: Location: 37.7749, -122.4194, "latitude_longitude": ..., latlong: ..., a GeoJSON Point or Feature, a file named gps_points.txt, a map link such as https://www.google.com/maps/@37.774929,-122.419416,17z or https://maps.apple.com/?ll=..., and a geo:37.774929,-122.419416 URI.

Merge order

Kept from public

  • Line-level structure. Comment-line skipping, the frontmatter author-email rewrite, the IPv4 version-literal filter, home-path identity checks, confidence estimation and Null Island handling are unchanged. Grouping findings by value and reporting one finding per line are also unchanged. matched_value is the first candidate that survives filtering.
  • Report redaction. Report and metadata redaction of PII values is unchanged. The tests read card values from the scanner's own candidates, so they do not depend on whether a report redacts card numbers.
  • Textual exceptions stay line-level for every category. This covers the browser-automation and "for testing" card exceptions, and every GPS exception (%, viewport, ~, np.array, ...). Only numeric test-card exceptions moved to a per-candidate check. The 15-digit 378282246310005 stays in the list but no longer has any effect, because the card pattern matches 16 digits only.
  • Existing card guards. The float lookbehind (0.8603333333333333), the long-digit-run guard and the Luhn check are unchanged. The ASCII class covers digits, so the long-digit-run guard still holds.
  • Existing GPS precision rules. The pattern still requires 4+ decimal places, and the near-zero low-confidence downgrade is unchanged.
  • Scan scope. No file types are added. .csv is still not in the scannable extensions, so no CSV-column logic is introduced.

Tests

  • tests/validators/test_security.py adds 70 cases. 37 of them fail on unmodified main. The other 33 are controls that must keep passing.
    • Credit cards that are not reported:
      • timestamp, epoch, unix_time and digest labels in YAML, JSON and plain text, including snake_case prefixes (event_timestamp:, "created_at_epoch":, file_sha256:);
      • digits inside a hex digest or an identifier, with an underscore before or after them;
      • test cards in spaced, dashed and plain groupings;
      • lines that list several published test cards, including the 15-digit Amex number next to a 16-digit test card.
    • Credit cards that are still reported:
      • a card after a Luhn-valid timestamp on the same line;
      • a card next to a known test card, in plain or dashed form;
      • a card after an unrelated checksum word;
      • a card in Markdown underscore emphasis (_…_ and __…__);
      • a card written directly next to Japanese, Chinese, Korean or Thai letters.
    • Card assertions read raw values from _scan_file_for_pii, so they hold whether or not a report redacts card numbers.
    • Phones that are not reported: scientific-notation matrices, including signed and E forms.
    • Phones that are still reported: a real phone number later on the same line as a matrix value.
    • GPS pairs that are not reported:
      • waypoints (singular and plural), quaternions, poses and calibration pairs;
      • generic coordinates = / coordinates: assignments, and an unlabelled pair;
      • technical labels next to location/office wording;
      • a non-geographic "type": "Mesh" and a lower-case "type": "feature".
    • GPS pairs that are still reported:
      • lng, LatLng(, snake_case YAML keys, a location.json file name and a gps_points.txt file name;
      • an office cue two lines above the pair;
      • a GPS cue above a waypoint;
      • single-line and pretty-printed GeoJSON Points;
      • sorted-key GeoJSON with "type" after "coordinates", and a Feature bbox;
      • Google (/maps/@, .co.uk/maps, maps.google.com/?q=), Apple and Bing map links, a geo: URI, and latlong, latlon, lonlat and lnglat keys.
  • pytest tests/validators tests/golden tests/test_cli.py tests/test_commands.py tests/reporting tests/cli tests/test_oss_boundary.py tests/test_oss_source_hygiene.py tests/test_oss_packaging.py tests/test_publication_evidence.py tests/inference/test_finding_verifier.py tests/test_quality_policy_gate.py tests/test_public_benchmark_gate.py tests/test_ci_change_classifier.py tests/test_benchmark_rollout_docs.py tests/test_checks_routing.py -n 8: 5,362 passed, 1 skipped.
  • End-to-end check with a skill whose reference file has a timestamp, a waypoint and a matrix row, and whose SKILL.md lists 4111111111111111, 4242424242424242. validate <skill> --checks pii --tiers 1 exits 1 on main with a CRITICAL credit-card finding. On this branch it exits 0 with no findings. A skill with カード番号は4532015112830366です or Use _4532015112830366_ at checkout exits 1 with a CRITICAL credit-card finding on both. A skill with event_timestamp: 1707938736269577 and file_sha256: 1707938736269577 exits 1 on main and 0 on this branch. A skill whose SKILL.md says Open https://www.google.com/maps/@37.774929,-122.419416,17z to find my house shows the same PII advisory on both.
  • Performance check on lines of 380k to 520k characters full of GPS, GeoJSON, map-host, card, timestamp, underscore and phone candidates. Scan time stays linear: 0.2 to 0.7 s, against 0.2 to 0.4 s on main.
  • ruff check . passes. ruff format adds no new formatting differences in the changed files.
  • Gitleaks (the CI configuration, over every commit of the branch) finds no leaks.
  • scripts/check_oss_boundary.py passes.

🤖 Generated with Claude Code

Tier 1 PII scans judged numeric values by shape alone, so ordinary
technical content produced findings and some of them failed the gate.

Credit cards:
- Skip a card-shaped number when a timestamp or digest label directly
  precedes it (timestamp_microseconds:, event_timestamp:, unix_time,
  "created_at_epoch":, sha256:, checksum=). The label must end at the
  number and is searched in a 100-character window, so a timestamp
  field does not hide a card in a later field.
- Reject digits embedded in a longer ASCII token (hex digest,
  id_1707938736269577, 1707938736269577_suffix). An underscore counts
  only when it joins the number to a letter or digit, so Markdown
  emphasis (_4532015112830366_, __4532015112830366__) is still
  reported, and the classes stay ASCII so a card written next to CJK
  or Thai letters is still reported.
- Compare numeric test-card exceptions with each candidate's digits in
  any grouping instead of excluding the whole line, and add other
  widely published processor test cards.

Phone numbers: drop an international candidate that starts inside a
scientific-notation literal such as the +00 exponent of 1.000000e+00;
other candidates on the line are still checked.

GPS coordinates: require a geospatial cue on the line, the two lines
before it, or the file name. Cues include GPS, latitude/longitude,
lat/lng and latlong/lonlat keys, WGS 84, degrees, RFC 5870 geo: URIs,
Google/Apple/OpenStreetMap/Bing map links, and GeoJSON geometry,
Feature, collection, or "geometry" members. Technical labels
(waypoint, quaternion, pose, vector, calibration, pixel coordinates)
outweigh location/office/address wording but not a GPS cue.

Docs, YAML comments, and the CHANGELOG describe the new rules.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 9 findings (0 P1, 5 P2, 4 P3); 8 posted inline.

Findings outside the diff or about the description:

  • PR_DESCRIPTION: P3: The Merge order section says that #262 (release v0.7.0) edits CHANGELOG.md, and that if it merges first this entry should move under a new ## Unreleased. #262 already merged on 2026-10-30 and #302 reverted it the same day, so it will not merge again. Current main has no 0.7.0 section: the heading after ## Unreleased is ## 0.6.0, and this entry is already in the Unreleased / Fixed list. As written, the note could send a maintainer looking for a new ## Unreleased heading that #262 will never add, or lead them to move an entry that is already in the right place.

Suggested fix: Drop the #262 bullet, or make it general, for example: "If a release PR merges before this one, move this entry under the new ## Unreleased."

Comment thread docs/tier1-validation.mdx Resolved
rng1995 and others added 3 commits November 2, 2026 11:22
Conflicted files: CHANGELOG.md.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ropped

- Card boundary: a card after a backslash escape (\n, \t, \r) or a
  percent-encoded byte (%3D) is reported again, and the ASCII classes are
  scoped case-sensitive so IGNORECASE no longer lets them match the dotless i
  or the Kelvin sign.
- Timestamp labels: epoch and unix_time take the same unit suffixes as
  timestamp (epoch_us, epoch_micros, unix_time_us).
- GPS cues accept plurals (locations, offices, addresses, latitudes) and
  camelCase keys (homeLocation, gpsCoords); the unsplit text is still
  searched so GeoJSON types such as FeatureCollection match.
- A strong cue in the nearby lines or file name now outweighs a nearby
  "<pixel|camera|world> coordinates" label.
- Degrees and the degree sign are soft cues, so a technical label on the
  line wins over rotation wording in degrees.
- Every position inside a GeoJSON geometry's "coordinates" array is cued,
  found by one linear token pass per file, so pretty-printed Polygon and
  Multi* geometries are reported again.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
State which GPS cues are strong and which are soft, that vector labels
such as waypoint count only on the pair's own line while
"<pixel|camera|...> coordinates" also counts nearby, and that every
position inside a GeoJSON geometry's coordinates array is reported.
Update the CHANGELOG entry to match.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exemptions are where the risk is, so I ran a batch of card, phone, SSN and coordinate lines through main and this branch and compared. SSNs and normal phone formats are unchanged, and a card next to a timestamp or a test card, after \n or %3D, or in a plural or camelCase location key is reported as it should be. Two cases still hide real data that main reports: a technical word after a labelled coordinate pair, and a card behind a payment word and an underscore.

rng1995 and others added 3 commits November 3, 2026 04:18
Conflicted: CHANGELOG.md (kept both Unreleased / Fixed entries).

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
GPS cue words now accept plurals and a numeric suffix, so geolocations:,
latlngs, lats:, lat1/lon1, location1: and homeLocation2 keep their cue.
The GeoJSON type and geometry keys count double-quoted, single-quoted or
bare, so Python dicts, JS objects and one-line YAML geometry stay
reported; a bare type value must use GeoJSON's spelling. Nested
coordinates arrays are merged before their lines are marked, so deeply
nested input stays linear. Docs, CHANGELOG and pattern comments state
that block-style YAML geometry is cued only through the two-line window.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ter a payment word

A technical word (scale, vector, roi, calibration) now labels a coordinate
pair only when it comes before the pair, so "Location: 37.77, -122.41 (map
scale 1:5000)" is still reported. A card joined to a payment word by an
underscore (card_4532..., cc_4532...) is reported again; other identifiers
such as id_1707938736269577 stay skipped.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up on the current head. Both cases from my last review are fixed: Location: 37.774929, -122.419416 (map scale 1:5000) and the vector tiles line are reported again, and card_, CARD_...png and cc_ prefixes keep the card. I compared a few more lines against main and two narrower gaps remain, inline. Neither is blocking.

…bels reported

Split payment identifiers at camelCase boundaries and evaluate GPS labels for each coordinate pair.

Signed-off-by: Christopher Kevin <[email protected]>
@rng1995
rng1995 merged commit 4c3fc87 into main Nov 5, 2026
22 checks passed
@rng1995
rng1995 deleted the naren/port-numeric-pii-fp branch November 5, 2026 17:05
rng1995 added a commit that referenced this pull request Nov 5, 2026
Pick up the PII timestamp, matrix, and vector false-positive fix (#304);
no conflicts. Its numeric filters run before the waiver filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Narendran Raghavan <[email protected]>
rng1995 added a commit that referenced this pull request Nov 5, 2026
Resolve the CHANGELOG.md conflict: keep main's PII entry (#304) and add
this PR's refusal-fallback entry after it.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995 rng1995 mentioned this pull request Nov 6, 2026
7 of 8 tasks
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