Uh oh!
There was an error while loading. Please reload this page.
fix(metrics): bound endpoint/model labels against cardinality DoS (#451) - #482
Conversation
The in-flight middleware ran before authentication and route matching and used the raw request.uri().path() as the endpoint metric label, so an unauthenticated caller could mint unbounded Prometheus time series via unique /passthrough/:provider/*rest suffixes (or arbitrary 404 paths). The passthrough handler additionally used the caller-controlled *rest wildcard as the model label. Normalize the endpoint label to a fixed route template before recording (unknown paths bucket to "other"), and record a fixed sentinel for the passthrough model label instead of the raw suffix. Fixes#451
Warning Review limit reached
More reviews will be available in 42 minutes and 14 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Comment |
Problem
The in-flight metrics middleware runs before authentication and before route matching and used the raw
request.uri().path()as theendpointPrometheus label. An unauthenticated caller could therefore mint unbounded time series by varying the path — e.g. the/passthrough/:provider/*restwildcard suffix, or arbitrary 404 paths. The passthrough handler additionally used the caller-controlled*restwildcard as themodellabel.Fix
endpointlabel to a fixed route template before recording (normalize_endpoint_label); any unrecognized path (including unmatched 404s) buckets to"other". Passthrough collapses to/passthrough/:provider/*rest."passthrough"sentinel for the passthroughmodellabel instead of the raw suffix.Tests
endpoint_label_is_bounded_for_arbitrary_paths.metric-cardinality-passthrough-e2e.test.tsfires 25 unique unauthenticated passthrough paths and asserts no raw suffix leaks into a label and the passthrough endpoint collapses to a single template. Existingprometheus-metrics-e2estill passes (known routes are unchanged).Fixes#451