Repository navigation
A dashboard sign-in link asks before switching accounts unless this tab started the sign-in - #320
Merged
Merged
Conversation
…fore it signs in A dashboard link carrying #token=<jwt> was stored on any page, replacing the browser's session without a prompt, so anyone holding a valid token could sign a victim's dashboard into their own account (login CSRF): uploads, memories and minted agent tokens then landed in the sender's namespace. The sign-in gate now marks in session storage when this tab starts an SSO sign-in. Boot takes the mark with the link token and stores the token without asking only when the mark is under ten minutes old, or when the token names the same subject and org as the one held. Any other link token is held in memory only, behind a screen naming its subject and org: "Sign in as <subject>" stores it, "Cancel" drops it and keeps the browser's session. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ashboard opts out of cross-origin openers A fresh sign-in mark trusted any token that reached the tab while it was away at the identity provider: a page that opened the dashboard could navigate it to /me#token=<its own> after the tab left for /oauth/sso. The sign-in gate now writes a random nonce to session storage and starts /oauth/sso?n=<nonce> on every path (the button, the automatic resume). The server seals a well-formed nonce into the sign-in record its cookie carries and returns it as /me#token=<jwt>&n=<nonce>; a missing or malformed one is neither sealed nor echoed. Boot stores a link token without asking only when its nonce matches the one this tab kept (used up once), or when it names the account already held. A same-account token the server refuses gives the held token back instead of signing the person out. The confirmation screen also names the account the browser is signed in as. The dashboard page sends Cross-Origin-Opener-Policy: same-origin, so no other origin's window keeps a handle on it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…-ended card's new tab marks its own sign-in The nonce now comes back as /me?n=<nonce>#token=<jwt>, so a dashboard that predates it still reads the fragment as the token alone; the new dashboard reads n from the query and scrubs it with the token. The session-ended card's "Sign in in a new tab" opens /me?sign_in=sso, whose gate scrubs the ask and starts SSO with a nonce of that tab's own, so the returning token is stored without the confirmation screen. The confirmation offers a plain "Sign in" for a token without a subject, and passes axe. docs/architecture/security.md describes the tab binding of the hand-off and COOP. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The dashboard asks whoami about a same-account link's token with that token in its own Authorization header before writing anything. A refused or unanswered one leaves the held token in storage, so nothing has to be put back and no other tab hears of a token the server did not accept. docs/architecture/security.md keeps the separate-host rule for the MCP connect and device sign-ins, which the tab nonce does not cover. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… dropped where the page sends none A dashboard SSO sign-in the server could not finish restarts at /me?sign_in=sso, whose gate starts it again with a fresh tab nonce. That address starts nothing after a sign-out. Behind a proxy that adds Authorization, or with auth off, a #token= link is scrubbed and dropped without asking. docs/architecture/security.md describes COOP once and adds that a same-account token is stored once the server accepts it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…check retries a 503 /me?sign_in=sso starts SSO each time it is opened, unless the person signed out: every ask takes a click on another page, so it cannot loop and the five-minute guard on the automatic resume does not apply to it. The same-account link check asks whoami through the same 503 retry as boot, with the link's token in its own header. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… for Any site could send the browser to /me?sign_in=sso and have the gate start a sign-in whose token the tab then stores without the confirmation screen. The dashboard page's boot snippet now carries __LOOM_OWN_ORIGIN, true only when the load's Sec-Fetch-Site is same-origin or, from a browser that sends none, when its Referer has Loom's public origin; the gate scrubs any other ask and starts nothing for it. Boot keeps whoami's answer for a same-account link's token instead of asking again, and the link-mode tests wait for boot to finish. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ck handles default ports Boot scrubs ?sign_in=sso next to the link token, signed in or not, and passes whether it counts (a Loom page sent the browser there) to the gate, which starts once for it. The Referer fallback compares origins with same_origin, so a public URL that names its default port matches. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A counted ask always follows a click on a Loom page, so the sign-out check stays only on the automatic resume. A boot of /me?sign_in=sso that another site sent starts nothing and shows the SSO button. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e restart page links to the gate Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…account the server answered Any link token this tab did not ask for is asked about with whoami, with its own header, before anything else: one the server refuses or does not answer is dropped without the screen, nothing stored and no other tab told; the screen names the subject and org the server returned. A restart from the landing keeps the start page the first sign-in saved. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…swer A link token whoami refuses sets the gate's refused notice even when no mark or held token sends boot there. Whether a link names the held account compares the server's answer, not the link's unverified claims, and a confirmed link's token is asked about again before boot uses it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…only a same-account answer whoamiWhenReady(asToken) watched the stored token while it retried a 503, so another tab changing or clearing it made up a refusal. With asToken the stored token plays no part. Boot keeps the link's answer only when it names the held account, so a confirmed token is asked about again. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…n when another tab signs in Whitespace is stripped from a link's token once, so whoami is asked about the token setToken stores. The confirmation keeps the account held when it was put, and puts the question again when another tab stored a different token while it was up. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…he stored token Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
A dashboard link carrying
#token=signs the browser in without asking only when it answers the SSO sign-in this tab started, or when the token is for the account already signed in; any other link asks first, naming the account it signs in as.Why
The dashboard took a
#token=<jwt>fragment on any page and stored it, replacing whatever token the browser held, with nothing tying it to a sign-in this browser started. Anyone holding a valid token on the deployment (an org member, or anyone where self-signup is open) could send a link that silently signed the reader into the sender's account, so what the reader then did (documents uploaded, memories written, agent tokens minted on Setup) landed in the sender's namespace, every open tab following. The SSO round trip itself is bound to the browser by a sealed state cookie; the hand-off of the token to the dashboard after it was not.Design
loom_sign_in_pending_v1,{nonce, at}):/oauth/sso?n=<nonce>, from the button's plain click and from the automatic resume after an expired session. A click that opens another tab or window follows the bare link and writes no mark./oauth/ssoseals a well-formed nonce (16 to 64 url-safe characters) into the sign-in record its cookie already carries. The callback lands the token at/me?n=<nonce>#token=<jwt>, checking the nonce again before it goes in the URL; a missing or malformed one is neither sealed nor echoed.nfrom the landing's query and scrubs it with the token. It stores the token without asking whennmatches the tab's nonce, which is used up on every boot and lasts ten minutes. A token is also stored without asking when whoami, asked with that token in its ownAuthorizationheader (and asked again while a replica answers 503, as boot does), accepts it and answers with the subject and org of the token held; the link token's own claims are unverified and never decide: until then nothing is written, so a refused or unanswered one leaves the held token in place and no other tab hears of it./me, where Start again leads) keeps the start page the first sign-in saved, so the return goes there./me?sign_in=ssoasks the gate to start SSO with a nonce of that tab's own. Boot takes the ask from the address next to the link token, signed in or not, and passes it to the gate, which starts once for it, only when a Loom page sent the browser there. The dashboard page's boot snippet carries__LOOM_OWN_ORIGIN, true when the load'sSec-Fetch-Siteissame-origin(or, without that header, when theRefererhas Loom's public origin, default ports included); an ask from another site, or typed, is scrubbed and starts nothing, so no other site can start a sign-in whose token the tab stores unasked. A counted ask always follows a click on a Loom page, so it skips the five-minute guard that keeps the automatic resume after an expired session from looping. The session-ended card's Sign in in a new tab opens it, so that sign-in is stored without asking and the first tab picks it up as before; so does the server's Start again link when it could not finish a dashboard sign-in.Authorization, or with auth off, the page sends no token of its own: a#token=link is scrubbed and dropped without asking.Cross-Origin-Opener-Policy: same-origin, so a page of another origin that opened it keeps no handle to navigate it while it is away at the identity provider. The dashboard opens no popup it needs a handle to: its onewindow.open(the session-ended card's new tab) is same-origin withnoopener, external links carryrel="noreferrer", and SSO is a full-page navigation.Scope and risk
server/auth/oauth.py(the SSO start, the dashboard landing and its restart link),server/identity/app/dashboard_routes.py(COOP),frontend/src/lib/boot.ts,frontend/src/lib/navigation.ts,frontend/src/api.ts(whoamican ask about a token not yet stored),frontend/src/flows/TokenGate.tsx,frontend/src/components/SessionExpiredBar.tsx,frontend/src/App.tsx, their tests,docs/features/dashboard.mdanddocs/architecture/security.md. An SSO sign-in started outside the gate (typing/oauth/sso, a modified click on the button) carries no nonce, so its token asks to be confirmed unless it is for the account already signed in. The documented<server>/me#token=<jwt>flow for a minted token takes one confirmation click.Compatibility, rollout and rollback
/oauth/ssotakes an optional?n=; the dashboard SSO landing is/me?n=<nonce>#token=<jwt>when the start carried one, else/me#token=<jwt>as before; the dashboard page gainsCross-Origin-Opener-Policy: same-origin; the Start again link of a dashboard sign-in the server could not finish points at/me?sign_in=sso; the boot snippet gainswindow.__LOOM_OWN_ORIGIN.n, so the new/mepage that receives it asks to confirm the account, unless it is the account already signed in./me?n=<nonce>#token=<jwt>reads the fragment as the token and signs in, but leaves?n=in the address bar and does not return to the page the sign-in started on.nback, so its SSO sign-ins ask to confirm unless they are for the account already signed in./me?sign_in=ssoby the Start again link ignores the query and shows its SSO button.tab_nonceis optional).Tests
tests/unit/test_oidc_hardening.py: a well-formed nonce is sealed with the sign-in; missing or malformed ones are not; the landing carries the sealed nonce in the query with the fragment the token alone, and no query when there is no nonce or the sealed one is not well formed; a dashboard sign-in restarts at/me?sign_in=sso.tests/unit/test_dashboard_routes.py: the dashboard page sends COOP, and its own-origin flag is true for a same-originSec-Fetch-Siteor, without one, an own-originReferer, and false for cross-site, same-site,none, a foreign or look-alikeReferer, and no headers; aRefererwithout the default port matches a public URL that names it.frontend/src/App.boot.test.tsx: a link with no pending sign-in is not stored and shows the confirmation; confirming stores it; the screen names the subject and org whoami answered, not the token's claims; a link whose claims name the held account but whose whoami answer names another asks; a confirmed token is asked about again, and one refused then shows the refused gate; a refused link with no mark and no held token shows the refused gate; cancelling keeps the previous token and stores nothing; a token the server refuses is dropped without the screen; the landing from this tab's sign-in is stored silently and its query scrubbed; a fresh mark with no nonce or another nonce asks; a mark older than ten minutes counts as none; the same account is asked about with its own header before anything is stored, asked again after a 503 (also when another tab clears the stored token during the wait, since a link token's retry ignores the stored one), stored once whoami accepts it and not asked a second time by boot, while a refused or unanswered one leaves the held token stored and writes nothing; the screen names the held account as text; a token with%20%0Ain it is asked about and stored without the whitespace; another tab storing a token while the screen is up puts the question again, naming that account; the session-ended card opens/me?sign_in=sso; a signed-out boot there starts this tab's own sign-in once, one another site sent starts nothing and shows the SSO button, and a signed-in boot drops the ask from the address.frontend/src/lib/boot.test.tsalso coverstakeSsoAsk: it counts only with__LOOM_OWN_ORIGINtrue and scrubs the ask either way.frontend/src/App.linkModes.test.tsx: behind a proxy and with auth off a link's token is dropped unasked and scrubbed.frontend/src/lib/boot.test.ts: the nonce helpers, readingnfrom the landing's query, andsameAccountcomparing the server's answer with the held token.frontend/src/flows/TokenGate.test.tsx: both SSO starts carry the stored nonce,?sign_in=ssostarts one and is scrubbed, also while the resume guard is set, after a sign-out and once only, a modified click follows the bare link and writes no mark, a restart from/mekeeps the saved start page, and the confirmation passes axe with and without a subject.npm --prefix frontend test(1,951 tests),npm --prefix frontend run build, Biome, ruff and mypy on the touched server files pass.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I verified the defect by reading the code path and read the diff and its tests.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code