fix(security): remove proxy and cookie auth headers on insecure redirect#653
Merged
MIchaelMainer merged 26 commits intomainfrom Feb 27, 2026
Merged
fix(security): remove proxy and cookie auth headers on insecure redirect#653MIchaelMainer merged 26 commits intomainfrom
MIchaelMainer merged 26 commits intomainfrom
Conversation
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
adrian05-ms
previously approved these changes
Feb 11, 2026
gavinbarron
previously approved these changes
Feb 11, 2026
baywet
reviewed
Feb 12, 2026
baywet
requested changes
Feb 12, 2026
Member
baywet
left a comment
There was a problem hiding this comment.
Left a question regarding the proxy authorization
…t require a proxy Remove ProxyAuthorization if: No proxy is configured (header is meaningless without a proxy) OR proxy is configured but the redirect URL is bypassed (won't use the proxy); Keep ProxyAuthorization if proxy is configured AND the redirect URL will use the proxy
…r on redirect This is useful for scenarios like API keys
7e8e746
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…iota-dotnet into mmainer/redirect-sec
baywet
reviewed
Feb 20, 2026
src/http/httpClient/Middleware/Options/RedirectHandlerOption.cs
Outdated
Show resolved
Hide resolved
Contributor
|
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
This was referenced Mar 3, 2026
This was referenced Mar 10, 2026
Merged
This was referenced Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current behavior is that RedirectHandler only removes Authorization header on redirects that change host and scheme.
This PR addresses the scenario where proxy authorization, cookie authorization, or API Key headers are present on redirect.
Security Changes to RedirectHandler
1. Sensitive Header Scrubbing on Redirects
File:
src/http/httpClient/Middleware/Options/RedirectHandlerOption.csScrubSensitiveHeaderscallback property - allows customization of which headers to remove during redirects. Useful for API Keys and other custom authorization headers.DefaultScrubSensitiveHeadersstatic method implementing secure default behavior:AuthorizationandCookieheaders when redirecting to a different host or schemeProxy-Authorizationheader when no proxy is active for the destination2. Proxy-Aware Header Handling
File:
src/http/httpClient/Middleware/RedirectHandler.csGetProxyResolver()method - returns a function that checks if a proxy applies to a destination URIGetProxyFromFinalHandler()method - traverses the handler chain to extractIWebProxyfromHttpClientHandler,SocketsHttpHandler, orWinHttpHandlerWhy These Changes Matter
AuthorizationCookieProxy-AuthorizationRef: microsoft/kiota-java#2081