Repository navigation
Description
Preamble
This is a documentation issue, not a vulnerability report. The behaviour described below is
intended and covered by Electron's own tests — I confirmed that before opening this. The problem is
that the flag's meaning is undocumented, and the workaround text in a recently published advisory
describes it as doing the opposite of what it does.
What's missing
docs/api/structures/custom-scheme.md lists every privilege with a description except corsEnabled:
* `corsEnabled` boolean (optional) - Default false.
There is nothing stating what it does. Given the name, a reader can reasonably assume "CORS is
enforced for this scheme". The actual behaviour is closer to the opposite: it permits cross-origin
fetches of the scheme, and no Access-Control-Allow-Origin validation is performed on the response.
That reading is not a guess — it is what the test suite asserts (spec/api-protocol-spec.ts):
it('does not affect cross-origin fetch to a corsEnabled scheme', async () => {
protocol.handle('cors', () => new Response('ok')); // no Access-Control-Allow-Origin
await w.loadURL(remoteUrl); // a remote origin
const body = await w.webContents.executeJavaScript("fetch('cors://host/').then(r => r.text())");
expect(body).to.equal('ok');
});plus it('allows CORS requests by default'), which expects 200 for the same scheme.
Why it matters right now
The workaround section of GHSA-v3j7-r9gq-3gjw
(published 2026-07-27) says:
Set
corsEnabled: trueon schemes that must enforce CORS
Read alongside the tests above, that advice points developers toward a configuration in which the
response body remains readable cross-origin. An app that serves sensitive data from a custom scheme
and follows the workaround may believe it has restricted reads when it has not.
The same section also suggests:
validate the request
Originin your protocol handler before returning sensitive data
That one does not appear to be implementable on this path: the protocol.handle callback receives
Origin: null for these requests, so there is no origin available to validate. Logged from a handler
on 42.0.1:
[handler corson] request Origin header = null
Reproduction
Measured on 42.0.1 (which contains the advisory's fix). A page on http://127.0.0.1:<port>
fetching a custom scheme whose handler returns a secret, varying only the ACAO header:
scheme registered { standard, secure, supportFetchAPI } -> BLOCKED (expected, post-fix)
scheme registered { standard, secure, supportFetchAPI, corsEnabled } :
no Access-Control-Allow-Origin -> body readable, response.type "basic"
Access-Control-Allow-Origin: https://not-the-origin.example -> body readable
Access-Control-Allow-Origin: * -> body readable
The mismatched-ACAO row is the informative one: the response is readable whether the header is
absent, wildcard, or names a different origin, so no validation is taking place. response.type is
basic rather than cors. Behaviour is the same on 41.3.0 (before the fix), so this is
longstanding and not a regression from it.
Suggested changes
-
Document
corsEnabled. Something like:corsEnabledboolean (optional) - Whether cross-origin requests to this scheme are permitted.
Whentrue, pages from other origins mayfetch()/XMLHttpRequestthis scheme and read the
response. Electron does not validateAccess-Control-Allow-Originfor custom schemes, so this
grants access rather than enforcing the CORS protocol. Leavefalsefor schemes serving data
that other origins should not read. Default false.(Wording is a starting point, not a proposal I'm attached to — the maintainers know the intent.)
-
Amend the
GHSA-v3j7-r9gq-3gjwworkaround section, since apps are acting on it now. If the
goal is to prevent cross-origin reads, the advice is to leavecorsEnabledunset (which the fix
now enforces), not to enable it. And theOrigin-validation suggestion needs either removal or a
note that the header is not currently provided to handlers.
Happy to open a docs PR for (1) if that's useful. For (2) I assume amending a published advisory is
maintainer-only.
Environment
- Electron: 42.0.1 and 41.3.0 (prebuilt, npm)
- Platform: macOS (darwin x64)
Activity
nikwen commentedon Jul 28, 2026
I agree that documenting the meaning of the flag is a good idea.
That said, please do not have your AI generate issues!
That doesn't seem to be true:
electron/docs/api/structures/custom-scheme.md
Lines 5 to 11 in 8be23d1
electron-issue-triage commentedon Oct 27, 2026
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!
PalmerAL commentedon Nov 22, 2026
@nikwen Perhaps it's out of scope of this issue, but has there been any consideration towards changing this behavior?
My app has a custom protocol which I want to only be readable cross-origin only by certain origins. With the way this is implemented, it seems like it's impossible to do that. As the issue states, with
enableCors: true, setting access-control-allow-origin or checking the origin header don't work, so the protocol is readable by every other origin. If it's set to false, the protocol isn't readable by any other origin.IMO, requests on protocols with
enableCors: truereally should validate the access-control-allow-origin header. This is confusing enough that my AI agent wrote code assuming the header would be validated, and I only found out it didn't work that way after testing it. There's a minor note in the documentation about this now, but I think it should probably be a much more prominent warning if this behavior remains in place.nikwen commentedon Nov 22, 2026
@PalmerAL Feel free to open a feature request (or a PR) to change it.