Skip to content

security: PII scrubbing on ingest pipeline (UU PDP compliance) #294

Description

@ajianaz

What

Implement server-side PII detection and scrubbing on the Sentry envelope ingest pipeline.

Why

BMAD CLO finding (🔴 CRITICAL): Sentry SDKs routinely capture user emails (session auth), IP addresses, request headers, cookies, and stack traces with variable values (may contain passwords, tokens, PII).

Under UU PDP (Indonesia Law No. 27/2022), TrapFall as a data processor storing this is non-compliant. Fines: up to 2% of annual revenue.

Changes

  1. IP anonymization: Truncate or hash IPv4 (last octet), IPv6 (last 80 bits) on ingest
  2. PII pattern scrubbing: Regex-based detection for:
    • Email addresses → [REDACTED:email]
    • Credit card numbers → [REDACTED:cc]
    • API keys / tokens (common patterns: sk-, Bearer , ghp_, AKIA) → [REDACTED:token]
    • Phone numbers (ID format) → [REDACTED:phone]
  3. Configurable scrubbing rules: Allow users to add custom regex patterns via config
  4. Stack trace scrubbing: Detect sensitive variable names (password, token, secret, api_key) and redact their values
  5. MCP redaction: Apply same scrubbing to MCP tool responses before returning to AI agents
  6. Add config flag TRAPFALL_PII_SCRUBBING=true (default: true)

Testing

  • Unit tests for each PII pattern type
  • Integration test: send envelope with known PII → verify scrubbed in storage
  • Integration test: verify MCP responses don't contain raw PII
  • Test custom regex rules work correctly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions