Skip to content

DataCollection phase 0: always redact sensitive header values #5422

Closed

Description

@jamescrosswell

Part of #5420. Phase 0 — hardening pre-work, no new public API.

Today only Authorization and Proxy-Authorization header values are redacted (src/Sentry/Internal/RedactedHeaders.cs, SentryRequest.AddHeaders, Protocol/Response.AddHeaders), and only in some paths. Apply the full sensitive-terms denylist filter to header values unconditionally — regardless of SendDefaultPii — in:

  • src/Sentry/SentryRequest.cs / src/Sentry/Protocol/Response.cs (AddHeaders)
  • src/Sentry.AspNetCore/ScopeExtensions.cs (request header capture)
  • src/Sentry.AspNet/Internal/SystemWebRequestEventProcessor.cs
  • src/Sentry/SentryHttpFailedRequestHandler.cs / SentryGraphQLHttpFailedRequestHandler.cs

Key names are kept; values become [Filtered]. Depends on the denylist/filter utility issue (#5421).

Also in scope: the Cookie/Set-Cookie header rule

SensitiveDataFilter.SensitiveKeyTerms deliberately holds only the spec's canonical 17 terms, which do not include cookie or set-cookie (see the discussion in #5440). Treating those as substring denylist terms would over-filter every other category — a query param ?cookie_consent=true, a cookie named cookie_prefs, or a header X-Cookie-Debug would all be filtered, which neither the spec nor the Java SDK does.

So the rule belongs here, at the header call site, as an exact, case-insensitive header-name match. Whenever a header map is filtered, a header named exactly Cookie or Set-Cookie must have its value replaced with [Filtered], in addition to the denylist filtering. This matches io.sentry.util.HttpUtils.filterHeaders in sentry-java:

final boolean sensitive =
    containsTerm(name, SENSITIVE_DATA_KEYS)
        || "Cookie".equalsIgnoreCase(name)
        || "Set-Cookie".equalsIgnoreCase(name);

Rationale: the value of a raw cookie header is unparsed and may carry any number of sensitive pairs, so it is never safe to send verbatim from the general header map. Per-cookie parsing and selective filtering — where non-sensitive cookie values are retained — is handled separately by dataCollection.cookies in #5423.

Note that Set-Cookie legitimately appears more than once in a response, so the header collection must not collapse duplicates. SensitiveDataFilter.FilterKeyValueData returns an ordered list of key-value pairs for this reason.

JS reference: getsentry/sentry-javascript#18311 (shipped standalone in 10.27.0, well before the option existed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions