Repository navigation
Description
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)
- Use any project with a public ingest key against
POST /ingest/error(or/ingest/event). - 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. - 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)
- Cap or reject free-text field length before scrub on ingest.
- Replace or rewrite the email pattern so matching is linear (and apply the same fix in
packages/telemetry-core). - Optional time budget around scrub; longer-term, server-only adoption of
@tacko/pii-scrubonce 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
fix: apply review feedback on pii-scrub cost bounds
fix: adjust time bounds for CI performance
fix: remove depth limit in truncateRecordStrings
perf: bound PII scrubbing cost on ingest (Refs #896)
unjica commentedon Oct 30, 2026
QA verification on production v1.22.23 (release #901, fix #897), 2026-10-30 13:30–13:33 CET.
/healthreports 1.22.23 from 13:29:17 CET.[email](2/2), and long text fields are stored at the new 16 KiB cap (2/2).mainwas 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.@telemetry-tracker/node1.4.2 error + event ingest read back in the dashboard API (2/2).Note:
@telemetry-tracker/core1.5.3 (same client-side pattern) is not published yet; the server-side fix is what closes this. Verified → Closed.