Repository navigation
fix(api): moved to a private fix - #618
Closed
gloryfromca wants to merge 1 commit into
Closed
gloryfromca wants to merge 1 commit into
gloryfromca wants to merge 1 commit into
Conversation
gloryfromca
commented
Nov 20, 2026
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
force-pushed
the
fix/refuse-cross-site-requests
branch
from
November 20, 2026 10:09
64c7c9b to
cb7fff2
Compare
gloryfromca
commented
Nov 20, 2026
7 tasks done
Kendrick-Song
approved these changes
Nov 20, 2026
Kendrick-Song
left a comment
Collaborator
There was a problem hiding this comment.
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, publicHost) 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.
- A malformed
HostorOriginnow gets a 500 (200 onmain).Host: [::1raisesValueError('Invalid IPv6 URL')fromurlsplitat cross_site.py#L94, andOrigin: http://[::1does the same at #L111; each is logged with a full traceback. h11 accepts such aHost, so a real uvicorn server reaches this. Treating aValueErrorthere as a refusal would fix it. - The module docstring overstates when browsers send
Origin. Per the Fetch standard, no-corsGETs (<img>,<script>, navigations) carry noOrigin: aGET /healthwithSec-Fetch-Site: cross-siteand noOrigingets a 200. This is not exploitable today, because everyGETroute is read-only and a no-cors response is opaque to the page, but the guard silently relies on that. Suggest rewording it; optionally, refusingSec-Fetch-Site: cross-site(Fetch Metadata) would cover these requests as well. create_appnow callsload_settings()at construction whensettingsisNone(app.py#L119), and the lifespan calls it again (#L89). When anapplicationis 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 "Noneloads them when the lifespan starts" no longer holds. Resolving settings once would avoid both.*.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.CrossSiteRefusedErrorshipped in v1.7.1 (everos.core.errors); its removal could get a line in the CHANGELOG.
Member
|
Folding this into a larger change; closing in favor of that. |
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.
Closed in favor of a private fix. Details will be published in a security advisory once a fixed release is out.