Strip Sec-Fetch-* headers on redirect#4190
Open
AtomicNibble wants to merge 1 commit into
Open
Conversation
Fixes a network-service / renderer process kill on HTTP redirects of renderer-initiated subresource requests. On redirect, CEF restarts the request through the URLLoaderFactory (InterceptedRequest::FollowRedirect -> Restart -> ContinueToBeforeRedirect) instead of following it on the existing loader. The restart re-submits the network-service-managed Sec-Fetch-* headers that were populated on the prior hop. With kRestrictForbiddenSecurityHeaders now enabled by default in Chromium, CorsURLLoaderFactory::IsValidRequest -> ContainsForbiddenSecurityHeader rejects those renderer-forbidden headers via mojo::ReportBadMessage, tearing down the network service. Only renderer-initiated subresources (fetch/XHR/img/script) trigger this; browser-initiated top-level navigations skip the check, which is why a top-level redirect doesn't reproduce it. The fix strips the Sec-Fetch- header family by prefix (mirroring Chromium's own network::MaybeRemoveSecHeaders) from remove_headers before the restart, so new members like Sec-Fetch-Frame-Top / Sec-Fetch-Frame-Ancestors are covered without maintaining an explicit list. URLLoader re-derives them downstream (SetFetchMetadataHeaders), so this is lossless and mirrors CorsURLLoader's normal redirect path. Adds CorsTest.XhrRedirectSubresource and CorsTest.FetchRedirectSubresource regression tests.
Contributor
Author
|
Fix for #4189 |
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.
Fixes a network-service / renderer process kill on HTTP redirects of renderer-initiated subresource requests.
On redirect, CEF restarts the request through the URLLoaderFactory (InterceptedRequest::FollowRedirect -> Restart -> ContinueToBeforeRedirect) instead of following it on the existing loader. The restart re-submits the network-service-managed Sec-Fetch-* headers that were populated on the prior hop. With kRestrictForbiddenSecurityHeaders now enabled by default in Chromium, CorsURLLoaderFactory::IsValidRequest ->
ContainsForbiddenSecurityHeader rejects those renderer-forbidden headers via mojo::ReportBadMessage, tearing down the network service.
Only renderer-initiated subresources (fetch/XHR/img/script) trigger this; browser-initiated top-level navigations skip the check, which is why a top-level redirect doesn't reproduce it.
The fix strips the Sec-Fetch- header family by prefix (mirroring Chromium's own network::MaybeRemoveSecHeaders) from remove_headers before the restart, so new members like Sec-Fetch-Frame-Top / Sec-Fetch-Frame-Ancestors are covered without maintaining an explicit list. URLLoader re-derives them downstream (SetFetchMetadataHeaders), so this is lossless and mirrors CorsURLLoader's normal redirect path.
Adds CorsTest.XhrRedirectSubresource and CorsTest.FetchRedirectSubresource regression tests.