Skip to content

fix: strip every credential header on a cross-origin redirect - #8

Merged
jrosskopf merged 1 commit into
mainfrom
fix/unify-credential-headers
Sep 12, 2026
Merged

jrosskopf merged 1 commit into
mainfrom
fix/unify-credential-headers

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Three places decide what counts as a credential header — the trace redactor, the response cache key, and the cross-origin redirect strip. They kept separate lists and drifted.

The redirect strip named five headers where the redactor named seven, so X-Access-Token survived a redirect and was sent to whatever host the Location header pointed at.

Reproduced

Six credential headers through a 302 to a second local server:

header that reached the redirect destination: X-Access-Token

Change

  • The strip erases by predicate over the single list, not by matching a second hand-written copy. That also fixes case sensitivity: it compared names verbatim, so x-api-key would have been kept where X-API-Key was stripped.
  • x-csrf-token, apikey and ocp-apim-subscription-key added to that one list, so all three uses gain them together.

Tests live in erpl-web (test/cpp/test_http_redirect_credentials.cpp) because http_client.cpp needs DuckDB's vendored httplib. erpl-web: 430 cases / 2171 assertions green.

Found by an agent-crew review.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Three places decide what counts as a credential header: the trace
redactor, the response cache key, and the cross-origin redirect strip.
They kept separate lists and drifted. The redirect strip named five
headers where the redactor named seven, so X-Access-Token survived a
redirect and was sent to whatever host the Location header pointed at.

The strip now erases by predicate over the single list rather than
matching a second hand-written copy of it, which also fixes the case
sensitivity: it compared names verbatim, so a header spelled
"x-api-key" rather than "X-API-Key" was kept.

x-csrf-token, apikey and ocp-apim-subscription-key are added to that one
list, so all three uses gain them together.

The test sends six credential headers through a 302 to a second local
server and asserts none of them arrive. Before this change X-Access-Token
did.
@jrosskopf
jrosskopf merged commit f9e3b40 into main Sep 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant