fix: custom auth headers not stripped on cross-origin redirects#10892
Conversation
|
@sapirbaruch this fails ci, please check linting |
…ders - Fix delete logic to iterate Object.keys(headers) and compare lowercased, so headers like X-API-Key are stripped regardless of the casing preserved by follow-redirects - Add sensitiveHeaders?: string[] to AxiosRequestConfig in both index.d.ts and index.d.cts - Add three HTTP adapter tests: cross-origin strips, same-origin preserves, and case-insensitive matching
There was a problem hiding this comment.
1 issue found across 8 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Resolved conflicts in README.md and THREATMODEL.md: - README.md: kept sensitiveHeaders docs block, adopted upstream's updated beforeRedirect comment and fuller security note - THREATMODEL.md: kept PR's version (follow-redirects@^1.16.0, sensitiveHeaders mitigation row) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Hi @jasonsaayman — all three points from your review have been addressed in the subsequent commits:
Happy to address any further feedback. |
Thanks nothing further to do, I am trying to make sure we dont release docs on un-released improvements so thats why im making some adjustments. |
Found this while auditing redirect behavior in a service that uses
X-API-Keyfor authentication. Standard headers likeAuthorizationare stripped correctly on cross-origin redirects, but any custom auth headers survive the redirect to the new origin.This extends the existing cross-origin header-stripping logic to also cover a configurable list of sensitive header names via the new
sensitiveHeadersconfig option. On a cross-origin redirect, any header in that list is removed from the outgoing request.Refs #10711.
Summary by cubic
Fixes a security bug where custom auth headers could leak on cross-origin redirects in the Node HTTP adapter. Adds a case-insensitive
sensitiveHeadersoption with fail-closed origin checks and prototype‑pollution guards.Description
Summary of changes
options.beforeRedirects.sensitiveHeadersto strip caller‑listed headers on cross‑origin redirects (case‑insensitive).isSameOriginRedirect(fail closed on parse errors) and export__isSameOriginRedirectfor tests.sensitiveHeadersas an array of strings; reject withERR_BAD_OPTION_VALUEotherwise.Object.prototype.sensitiveHeaderswhen reading config.sensitiveHeaders?: string[]toindex.d.tsandindex.d.cts.follow-redirects@^1.16.0.PRE_RELEASE_CHANGELOG.md; keep README snippet.Reasoning
X-API-Key) to other origins while preserving same‑origin behavior.Additional context
maxRedirectsis0.Docs
Add
/docs/updates withsensitiveHeadersexamples and security notes. Keep them aligned with the README snippet and the new entry inPRE_RELEASE_CHANGELOG.md.Testing
Added/updated unit tests for:
__isSameOriginRedirect.Object.prototype.sensitiveHeaders.Semantic version impact
Patch: backward‑compatible security hardening behind an optional Node‑only config.
Written for commit d493090. Summary will update on new commits.