Repository navigation
Redact secret path params in HTTP server spans and logs - #10790
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 7cbb8e6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
Routes take a `redactedParams` option, and `HttpApi.RedactedNames` takes `params`. When a route with redacted params matches, the server span and the request log record the path with those values replaced by `REDACTED`. Co-authored-by: Julius Marminge <[email protected]>
- Redact every param of a route whose regex constraint has nested capture groups, since FindMyWay assigns those captures to the wrong names. - Drop the whole segment for an absent optional param, as the router does. - Combine the path recorded by a router mounted inside another route with the outer one, so it can only add redactions, and keep the mount prefix. - Use the request-scoped query names for the URL of the synthesized 5xx span error.
Deleting escaped tokens first could turn a capturing group such as `(\d?=k)` into an apparent lookahead, skipping the redact-all fallback. Also size the mount-prefix mask in UTF-16 code units.
Parse the route pattern when the route is added instead of on every matched request, count regex captures with the regex engine, store the character kinds as a string, pass the request state to responseSpanExit and read redacted params through a separate HttpApi getter.
Count captures on the constraint with its parentheses, so named and non-capturing groups no longer throw at registration, and redact every param unless the constraint has exactly one capture. Keep the leading slash of a bare wildcard visible, and note in HttpApi.RedactedNames that params also apply to request logs.
effect-bot
force-pushed
the
http-redacted-path-params
branch
from
November 20, 2026 07:03
e4d8ece to
7cbb8e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The built-in server tracer and request logger record the raw URL path, so tokens in path segments end up in
url.path,url.fullandhttp.url. Query redaction doesn't help there. This adds per-param path redaction./hooks/123/s3cret?key=qis recorded as/hooks/123/REDACTED. Query values listed inUrlParams.CurrentRedactedNamesstay redacted inurl.full, the log still has no query, and the handler sees the URL as sent.How it works
HttpRouter:redactedParamsis onroute,add(the layer and theHttpRouterservice method, includingprefixed) andRoute. When a route that has it matches, the router renders the path from the route pattern and the matched params and stores it in the request state. Routes without the option are unaffected.FindMyWaypattern grammar:::literals,-/.separators, regex constraints, optional params and wildcards. An absent optional param or wildcard drops its whole segment, as the router does. Values that are not redacted are percent-encoded again. If a regex constraint has its own capture groups, FindMyWay assigns values to the wrong names, so every param of that route is redacted.redactedParams, the mount prefix is put back in front.HttpMiddleware.loggernow computeshttp.urlon exit, so it sees the path recorded during routing.HttpMiddleware.traceruses it forurl.pathandurl.full, and for the message anderror.request.urlof the synthesized 5xxResponseError. Other fields of that request, such asoriginalUrl, are unchanged.HttpApi.RedactedNames.paramsis merged across API, group and endpoint likequeryandheaders, and is passed to the endpoint route asredactedParams.Not covered (documented in the JSDoc)
requestof errors raised by the handler.HttpApiClientspans. The client only has a URL string, so that needs its own design.Closes #10788
Closes EFF-4048