Skip to content

[Docs]: corsEnabled has no documented meaning, and the GHSA-v3j7-r9gq-3gjw workaround describes it as doing the opposite #52498

Done

Description

@anir0y

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: true on 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 Origin in 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

  1. Document corsEnabled. Something like:

    corsEnabled boolean (optional) - Whether cross-origin requests to this scheme are permitted.
    When true, pages from other origins may fetch()/XMLHttpRequest this scheme and read the
    response. Electron does not validate Access-Control-Allow-Origin for custom schemes, so this
    grants access rather than enforcing the CORS protocol. Leave false for 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.)

  2. Amend the GHSA-v3j7-r9gq-3gjw workaround section, since apps are acting on it now. If the
    goal is to prevent cross-origin reads, the advice is to leave corsEnabled unset (which the fix
    now enforces), not to enable it. And the Origin-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

  1. nikwen commented on Jul 28, 2026

    @nikwen
    Member

    I agree that documenting the meaning of the flag is a good idea.

    That said, please do not have your AI generate issues!

    docs/api/structures/custom-scheme.md lists every privilege with a description except corsEnabled:

    That doesn't seem to be true:

    * `standard` boolean (optional) - Default false.
    * `secure` boolean (optional) - Default false.
    * `bypassCSP` boolean (optional) - Default false.
    * `allowServiceWorkers` boolean (optional) - Default false.
    * `supportFetchAPI` boolean (optional) - Default false.
    * `corsEnabled` boolean (optional) - Default false.
    * `stream` boolean (optional) - Default false.

  2. added theissue type on Jul 28, 2026
  3. electron-issue-triage commented on Oct 27, 2026

    @electron-issue-triage

    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!

  4. PalmerAL commented on Nov 22, 2026

    @PalmerAL
    Contributor

    @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: true really 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.

  5. nikwen commented on Nov 22, 2026

    @nikwen
    Member

    @PalmerAL Feel free to open a feature request (or a PR) to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions