Skip to content

Redact secret path params in HTTP server spans and logs - #10790

Merged
tim-smart merged 7 commits into
mainfrom
http-redacted-path-params
Nov 20, 2026
Merged

tim-smart merged 7 commits into
mainfrom
http-redacted-path-params

Conversation

@effect-bot

@effect-bot effect-bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The built-in server tracer and request logger record the raw URL path, so tokens in path segments end up in url.path, url.full and http.url. Query redaction doesn't help there. This adds per-param path redaction.

HttpRouter.add("GET", "/hooks/:id/:secret", handler, { redactedParams: ["secret"] })
HttpRouter.add("GET", "/assets/*", handler, { redactedParams: ["*"] })

HttpApiEndpoint.get("asset", "/assets/:token/file", { params: { token: Schema.String } })
  .annotate(HttpApi.RedactedNames, { params: ["token"] })

/hooks/123/s3cret?key=q is recorded as /hooks/123/REDACTED. Query values listed in UrlParams.CurrentRedactedNames stay redacted in url.full, the log still has no query, and the handler sees the URL as sent.

How it works

  • HttpRouter: redactedParams is on route, add (the layer and the HttpRouter service method, including prefixed) and Route. 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.
  • The renderer follows the FindMyWay pattern 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.
  • A router mounted as the handler of another route combines its path with the one the outer route recorded, so it can only add redactions. If the outer route has no redactedParams, the mount prefix is put back in front.
  • HttpMiddleware.logger now computes http.url on exit, so it sees the path recorded during routing. HttpMiddleware.tracer uses it for url.path and url.full, and for the message and error.request.url of the synthesized 5xx ResponseError. Other fields of that request, such as originalUrl, are unchanged.
  • HttpApi.RedactedNames.params is merged across API, group and endpoint like query and headers, and is passed to the endpoint route as redactedParams.

Not covered (documented in the JSDoc)

  • Requests that never match the route: 404s, wrong-method requests and responses from global middleware such as CORS preflights.
  • Messages and request of errors raised by the handler.
  • HttpApiClient spans. The client only has a URL string, so that needs its own design.

Closes #10788
Closes EFF-4048

@changeset-bot

changeset-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7cbb8e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

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

@effect-janitor effect-janitor Bot added the 4.0 label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.10 KB 40.10 KB 0.00 KB (0.00%)
basic.ts 7.31 KB 7.31 KB 0.00 KB (0.00%)
batching.ts 11.22 KB 11.22 KB 0.00 KB (0.00%)
brand.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
cache.ts 11.73 KB 11.73 KB 0.00 KB (0.00%)
config.ts 23.13 KB 23.13 KB 0.00 KB (0.00%)
differ.ts 22.24 KB 22.24 KB 0.00 KB (0.00%)
http-client.ts 27.50 KB 27.50 KB 0.00 KB (0.00%)
http-router.ts 38.53 KB 37.78 KB +0.76 KB (+2.00%)
logger.ts 12.19 KB 12.19 KB 0.00 KB (0.00%)
metric.ts 9.65 KB 9.65 KB 0.00 KB (0.00%)
optic.ts 7.24 KB 7.24 KB 0.00 KB (0.00%)
pubsub.ts 16.21 KB 16.21 KB 0.00 KB (0.00%)
queue.ts 13.12 KB 13.12 KB 0.00 KB (0.00%)
schedule.ts 11.99 KB 11.99 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.31 KB 14.31 KB 0.00 KB (0.00%)
schema-binary.ts 42.72 KB 42.72 KB 0.00 KB (0.00%)
schema-class.ts 21.97 KB 21.97 KB 0.00 KB (0.00%)
schema-codegen.ts 30.73 KB 30.73 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.59 KB 30.59 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.28 KB 28.28 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.57 KB 15.57 KB 0.00 KB (0.00%)
schema-string.ts 12.51 KB 12.51 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.45 KB 16.45 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.65 KB 39.65 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.16 KB 21.16 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.30 KB 21.30 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.41 KB 21.41 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.45 KB 26.45 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.49 KB 21.49 KB 0.00 KB (0.00%)
schema.ts 21.07 KB 21.07 KB 0.00 KB (0.00%)
stm.ts 14.46 KB 14.46 KB 0.00 KB (0.00%)
stream.ts 10.58 KB 10.58 KB 0.00 KB (0.00%)

effect-bot and others added 7 commits November 20, 2026 06:57
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
effect-bot force-pushed the http-redacted-path-params branch from e4d8ece to 7cbb8e6 Compare November 20, 2026 07:03
@tim-smart
tim-smart merged commit 9f9d58b into main Nov 20, 2026
18 checks passed
@tim-smart
tim-smart deleted the http-redacted-path-params branch November 20, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP server: credentials in URL paths leak into span attributes and request logs

2 participants