Skip to content

[BUG] PII scrubber redacts epoch-ms timestamps and long IDs as card numbers (no Luhn check) #205

Done

Description

@OkiriGabriel

Problem

services/pii_scrubber.py redacts any run of 13–16 digits as [REDACTED_CARD], with no Luhn check. The scrubber runs on every log line and tool result before the LLM, Slack and storage see them, so ordinary values are destroyed:

ts=1732600000123 level=error       -> ts=[REDACTED_CARD] level=error      (epoch milliseconds)
took 1234567890123 ns              -> took [REDACTED_CARD] ns
order 12345678901234 ok            -> order [REDACTED_CARD] ok

Epoch-millisecond timestamps are 13 digits, so the agent loses the timeline in JSON logs (Loki, CloudWatch, most structured loggers). Long numeric request, trace and order IDs disappear too, which makes it impossible to correlate events across services.

Proposed fix

  • Redact a card candidate only when it passes the Luhn checksum. Optionally also require a known IIN prefix (4, 51–55, 2221–2720, 34/37, 6011/65).
  • Keep obvious timestamps: 13-digit values starting 1 that fall within ±20 years of now.
  • Review the phone pattern for the same problem with 10-digit IDs.
  • Tests: Visa/Mastercard/Amex test numbers are still redacted; epoch ms, nanosecond durations and 14-digit order IDs are kept.

Files

services/pii_scrubber.py, tests/test_security.py (or a new tests/test_pii_scrubber.py)

Activity

  1. added
    bug
    on Nov 26, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions