Skip to content

TT-032: Ingest PII scrub can stall the API on crafted free-text fields (ReDoS) #896

Closed

Description

@unjica

TT ID: TT-032 · Severity: P1 · Area: Ingest/API · Found by: QA · Production: API v1.22.21

Summary

The shared PII scrubber used on the ingest write path (apps/api/src/lib/pii-scrub.ts, also mirrored in @telemetry-tracker/core) contains a free-text regex whose matching cost grows quadratically with input length on certain non-matching strings. Ingest free-text fields (message, stack, event properties values, error context string leaves) have no length cap before scrubbing, and scrubbing runs synchronously on the request thread. A holder of a normal public ingest key (tt_live_…) can therefore send a single within-body-limit request that blocks the Node event loop of an API instance for a long time, delaying other tenants on that instance.

Confirmed twice: local measurements against the shipping scrubber (two independent runs) and a minimal production probe at a small, safe size (two adversarial + two benign controls, sequential, QA project key only).

Steps to reproduce (high level)

  1. Use any project with a public ingest key against POST /ingest/error (or /ingest/event).
  2. Send a body within the existing Fastify body limit whose message (or a single property / stack) is a long non-email string that forces the email-pattern regex to backtrack.
  3. Observe request wall time vs an equal-size benign payload; scale shows roughly 4× cost when length doubles.

Exact trigger strings, sizes, and timings are in the private security advisory and the internal QA report — not repeated here.

Expected

Scrubbing free-text fields stays roughly linear in length and finishes in low tens of milliseconds even near the body limit. Alternatively, free-text fields are truncated or rejected before scrubbing so a single field cannot approach the full body size.

Actual

  • One regex (EMAIL_RE) accounts for essentially all of the blow-up; other scrub patterns stay fast on the same inputs.
  • Near the 200 KiB body limit, local scrub time is on the order of tens of seconds for a single field (measured twice).
  • Production at a small probe size already shows a clear, reproducible latency delta vs benign (measured twice).
  • Session ingest is unaffected (email opt-in uses a fixed placeholder, not scrubPiiText). MCP/brief paths re-scrub stored text and can hitch on already-stored pathological rows; truncation there happens after scrub.

Likely cause

EMAIL_RE in scrubPiiText — nested/overlapping character classes with backtracking. No pre-scrub per-field max on ingest Zod schemas. bodyLimit alone is 200 KiB.

Suggested direction (not prescribing a patch)

  1. Cap or reject free-text field length before scrub on ingest.
  2. Replace or rewrite the email pattern so matching is linear (and apply the same fix in packages/telemetry-core).
  3. Optional time budget around scrub; longer-term, server-only adoption of @tacko/pii-scrub once its own perf/compat fixes land and pass independent QA — do not deploy that integration until then. SDK swap is out of scope for the first fix.

Notes

  • Not a confidentiality issue; impact is availability / cross-tenant latency on a shared API process.
  • Requires a valid ingest key (not anonymous).
  • Private advisory carries exploit detail for maintainers.

Activity

  1. added
    bug
    qa
    security
    on Oct 30, 2026
  2. unjica commented on Oct 30, 2026

    @unjica
    CollaboratorAuthor

    QA verification on production v1.22.23 (release #901, fix #897), 2026-10-30 13:30–13:33 CET.

    • /health reports 1.22.23 from 13:29:17 CET.
    • The minimal production probe used to confirm this issue was repeated twice (sequential, disposable QA project). The extra latency seen on v1.22.21 is gone: crafted and benign payloads now respond in the same range (about 0.19–0.32 s, within normal jitter), all 204.
    • Behaviour kept: an email in an error message is still replaced with [email] (2/2), and long text fields are stored at the new 16 KiB cap (2/2).
    • The scrubber code now on main was also measured locally against every shape from the original assessment: cost is linear, roughly 60 ms even at the full request size limit (was about 30 s), 2/2 runs.
    • Core path unaffected: published @telemetry-tracker/node 1.4.2 error + event ingest read back in the dashboard API (2/2).

    Note: @telemetry-tracker/core 1.5.3 (same client-side pattern) is not published yet; the server-side fix is what closes this. Verified → Closed.

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

    bugqasecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions