Skip to content

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

Closed

Description

@juliusmarminge

Path segments that are credentials leak into server span attributes and request logs

Problem

UrlParams.CurrentRedactedNames and Redacted URL params keep credentials in the query string out of url.full. Many apps put credentials in the path instead. Examples are signed asset URLs (/assets/<signed-token>/file.png), upload URLs (/upload/<token>) and webhook URLs (/hooks/<id>/<secret>). A path token has to stay in the path when relative URLs need to keep working, e.g. an HTML file loading its siblings, and when a third party can't append query params.

For those routes, both built-in HTTP server observability points record the raw path:

  • HttpMiddleware.tracer sets url.full / url.path from the raw request URL, after the handler returns (tracing.addUrlAttributes).
  • HttpMiddleware.logger logs http.url as the request URL with search and hash stripped, i.e. the full path.

The only workaround today is a central, URL-based predicate: TracerDisabledWhen for spans, plus a global middleware calling withLoggerDisabled for logs. That list sits away from the routes and has to be updated by hand for every new route. It also drops the span and the log line entirely rather than redacting them. A route handler can't fix this itself, because the tracer adds URL attributes after the handler exits.

Proposal

Let a route mark its path as sensitive. The router already knows the matched pattern, since it sets http.route:

HttpRouter.add("GET", "/assets/*", handler, { sensitivePath: true })

For a matched sensitive route:

  • the tracer records url.path / url.full from the route pattern (/assets/*, query still redacted by CurrentRedactedNames) instead of the raw path
  • the logger logs http.url as the route pattern

A more general alternative would be a Context.Reference URL redactor used by both the tracer and the logger, e.g. HttpMiddleware.UrlRedactor: (request) => string. That still needs a central list, though. The per-route flag keeps the decision next to the route that mints the credential, and requests stay visible in traces and logs.

Context

This came up in T3 Code, which works around it with a prefix list today: pingdotgg/t3code#39464. It's a follow-up to the Redacted URL params / CurrentRedactedNames work.

Activity

  1. self-assigned this
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions