fix: ensure corsEnabled: false protocol handlers do not work across protocols (40-x-y)#51271
Merged
Conversation
5 tasks
VerteDinde
approved these changes
Apr 23, 2026
41cd3ce to
10f91f4
Compare
…rotocols (#51152) * fix: ensure corsEnabled: false protocol handlers do not work across protocols Subresource requests for registered custom protocols are routed to ElectronURLLoaderFactory via the renderer's per-scheme URLLoaderFactoryBundle entry, which bypasses the network service's CorsURLLoaderFactory. This meant a cross-origin page could fetch() a scheme registered with {supportFetchAPI: true} and read the response body even when {corsEnabled: true} was not set. Replicate CorsURLLoader::StartRequest's kCorsDisabledScheme gate in ElectronURLLoaderFactory::CreateLoaderAndStart so cross-origin mode=cors requests to such schemes fail before the JS handler runs, and tag cross-origin mode=no-cors responses as opaque so the body is not script-readable while <img> and similar subresource loads continue to work. Re-enable the long-disabled "disallows CORS and fetch requests when only supportFetchAPI is specified" test, add coverage for the opaque/no-cors, same-origin, handler-not-invoked, corsEnabled-unaffected and net.fetch-unaffected cases, and migrate spec helpers that were exercising a {supportFetchAPI: true} scheme cross-origin to a corsEnabled scheme. * chore: oxfmt (cherry picked from commit 92f0993)
10f91f4 to
7749395
Compare
ckerr
approved these changes
Apr 23, 2026
Member
|
rebased to get past the |
|
Release Notes Persisted
|
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.
Manual backport of #51152 to
40-x-y.See that PR for details.
Notes: Ensured cross-origin
fetch()and XHR are blocked for custom protocols registered withsupportFetchAPI: trueunlesscorsEnabled: trueis also set; cross-originmode: 'no-cors'requests now receive an opaque response.