Skip to content

fix(api): moved to a private fix - #618

Closed
gloryfromca wants to merge 1 commit into
mainfrom
fix/refuse-cross-site-requests
Closed

gloryfromca wants to merge 1 commit into
mainfrom
fix/refuse-cross-site-requests

Conversation

@gloryfromca

@gloryfromca gloryfromca commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Closed in favor of a private fix. Details will be published in a security advisory once a fixed release is out.

@gloryfromca gloryfromca left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review withdrawn: this change is handled privately.

CORS allowed every origin with credentials and only the purge routes
checked Origin, so any page open in a browser on the same machine could
read, write and delete memories through the loopback server; a page
that rebinds its own domain to 127.0.0.1 could do the same.

CrossSiteGuardMiddleware now answers 403 CROSS_SITE_REFUSED, on every
route and preflight, to a request that carries another site's Origin or
arrives under a public domain name in Host. IP addresses, single-label
names and the reserved localhost / internal / test / invalid domains
are always accepted. [api] cors_origins and [api] allowed_hosts list
the web UIs and reverse-proxy domains a deployment needs; CORS allows
no origin by default. The purge-only check is folded into the
middleware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gloryfromca
gloryfromca force-pushed the fix/refuse-cross-site-requests branch from 64c7c9b to cb7fff2 Compare November 20, 2026 10:09

@gloryfromca gloryfromca left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review withdrawn: this change is handled privately.

@Kendrick-Song Kendrick-Song left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving: the guard closes a real hole, and the core logic checks out locally.

  • The new tests fail against main's src (11 failed, 12 passed) and pass on this branch; the API and purge unit tests (598) pass.
  • A rebinding request (same-origin Origin, public Host) is refused. The in-repo browser samples (the plugin dashboard, the game-of-throne demo) call through their own backend or proxy, so the CORS default change does not break them.

Please address 1 and 2 before merging; 3 to 5 are non-blocking.

  1. A malformed Host or Origin now gets a 500 (200 on main). Host: [::1 raises ValueError('Invalid IPv6 URL') from urlsplit at cross_site.py#L94, and Origin: http://[::1 does the same at #L111; each is logged with a full traceback. h11 accepts such a Host, so a real uvicorn server reaches this. Treating a ValueError there as a refusal would fix it.
  2. The module docstring overstates when browsers send Origin. Per the Fetch standard, no-cors GETs (<img>, <script>, navigations) carry no Origin: a GET /health with Sec-Fetch-Site: cross-site and no Origin gets a 200. This is not exploitable today, because every GET route is read-only and a no-cors response is opaque to the page, but the guard silently relies on that. Suggest rewording it; optionally, refusing Sec-Fetch-Site: cross-site (Fetch Metadata) would cover these requests as well.
  3. create_app now calls load_settings() at construction when settings is None (app.py#L119), and the lifespan calls it again (#L89). When an application is injected, as most tests do, the guard's [api] settings come from the environment rather than from the application's own settings, and the docstring's "None loads them when the lifespan starts" no longer holds. Resolving settings once would avoid both.
  4. *.local (mDNS, RFC 6762) and *.home.arpa (RFC 8375) hosts are refused by default. The error message says how to allow them, so this is acceptable; neither can be registered publicly, so they could also join the always-accepted list.
  5. CrossSiteRefusedError shipped in v1.7.1 (everos.core.errors); its removal could get a line in the CHANGELOG.

@dani1005

Copy link
Copy Markdown
Member

Folding this into a larger change; closing in favor of that.

@dani1005 dani1005 closed this Nov 22, 2026
@gloryfromca gloryfromca changed the title fix(api): refuse requests from browser pages of other sites fix(api): moved to a private fix Nov 23, 2026
@gloryfromca
gloryfromca deleted the fix/refuse-cross-site-requests branch November 23, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants