OIDC: a sign-in with an unverified email pre-creates an account a later verified sign-in links to #90

Merged
jfro merged 6 commits from fix-83-oidc-unverified into main 2026-11-13 11:41:18 +00:00
Owner

What changed

An unverified OIDC sign-in can no longer make an account a later sign-in joins, and the owner's email-link confirm now removes its identities, API keys and every outbound setting (backups, Vikunja, LanguageTool, OCR provider, reMarkable pairing); F2, F4, F5, F6, F7 are fixed and precommit passes (C30).

Red, then green

  • An unverified OIDC sign-in A makes an unconfirmed user, and a verified sign-in B (different sub, same email) is refused instead of being linked to A's user; IdPs that omit email_verified still get a first sign-in.: bash -o pipefail -c 'eval "$(mise activate bash --shims)"; MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs 2>&1 | tail -3'
    • fails on the base (60213ac): exit 1
    • passes on the branch (6a8536a): exit 0
  • New accounts tests: an email-link confirm clears outbound settings an unverified sign-in set, keeps a confirmed user's, and keeps adopted pre-user data.: export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs
    • fails on the base (60213ac): exit 1
    • passes on the branch (c6a850f): exit 0

Checks

  • mix precommit (compile --warnings-as-errors, deps.unlock --unused, format, full suite) passes on the #83 branch. (Upper Wolfjaw): bash -o pipefail -c 'eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3', exit 0
  • Read the diff and reran the accounts and OIDC tests (63 pass): unverified or missing email_verified makes an unconfirmed user, and any later same-email identity is refused (citext covers case). Untested: users made before the fix stay linkable, the magic-link path when email login is enabled, and the browser flow. (Prover): bash -o pipefail -c 'eval "$(mise activate bash --shims)"; MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs 2>&1 | tail -3', exit 0
  • mix precommit passes on the #83 branch at 51140ed. (Upper Wolfjaw): bash -o pipefail -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3', exit 0
  • mix precommit passes on the #83 branch at 98fec93 (F5 fix). (Upper Wolfjaw): bash -o pipefail -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3', exit 0
  • At aa1ee1b the F2 and F4 probes still pass, and so do the accounts and OIDC controller suites (68 tests), including the new test that relinks a provider that omits email_verified. (Nye): set -e; for p in probe83 probe83b; do /home/peak/work/rm-analyzer-1-6-1/probes/$p.sh .; done; /home/peak/work/rm-analyzer-1-6-1/run-tests.sh . test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs, exit 0
  • mix precommit passes at d16b7ae (F7 fix), including two new OIDC controller tests: another email from a signed-in browser gets its own account, and a stale session can't link. (Upper Wolfjaw): bash -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3', exit 0
  • At d16b7ae (review/83e) the F2, F4 and both F7 probes (mine and Upper Wolfjaw's) pass along with the accounts and all controller tests, 104 tests: a signed-in browser now links a provider account only for the user's own email within 10 minutes of sign-in. (Nye): cd /home/peak/work/rm-analyzer-1-6-1 && W=rm-analyzer && git -C $W rev-parse --short HEAD && cp probes/nye_probe83_test.exs probes/nye_probe83b_test.exs $W/test/rm_analyzer/ && cp probes/nye_probe83d_test.exs $W/test/rm_analyzer_web/ && ./run-tests.sh $W test/rm_analyzer/nye_probe83_test.exs test/rm_analyzer/nye_probe83b_test.exs test/rm_analyzer_web/nye_probe83d_test.exs test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/; rc=$?; rm -f $W/test/rm_analyzer/nye_probe83_test.exs $W/test/rm_analyzer/nye_probe83b_test.exs $W/test/rm_analyzer_web/nye_probe83d_test.exs; exit $rc, exit 0
  • mix precommit passes at c6a850f: compile with warnings as errors, unused deps, format, full suite. (Upper Wolfjaw): export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && mix precommit 2>&1 | tail -3, exit 0
  • At c6a850f I read the diff and ran the full suite (1374 pass) in my own worktree. I looked for other outbound tables, other confirm paths, a re-pair that keeps an old row, and a strict email_verified check; I found no gap. Untested: users made before the fix, real browser flow, and concurrent sign-ins. (Prover): bash -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs 2>&1 | tail -3', exit 0

Found and fixed

  • F2 bug: With the #83 patch, an unverified OIDC sign-in still pre-creates a takeover account through email login: the real owner's magic-link sign-in confirms the unconfirmed user and the attacker's identity stays linked, so the attacker signs in to the victim's account (needs email login on alongside OIDC). (fixed)
  • F4 bug: With the F2 fix (head 92b892e), an MCP API key the unverified OIDC sign-in made while the account was its own survives the owner's email-link confirm, so the attacker's key still reaches the owner's notes after the identity is unlinked. (fixed)
  • F5 bug: A legit user from an IdP that omits email_verified (allowed by D6) is permanently locked out of OIDC once they use an email link: confirm deletes their identity, and re-sign-in with the same sub then fails with :unverified_email. The stated risk ("must sign in by OIDC again") is wrong; there's no way back. (fixed)
  • F6 security: At 9430059 the email-link confirm unlinks the unverified identity and deletes its API keys, but S3 backup settings the unverified sign-in saved while it held the account stay put, so after the real owner confirms, their library backs up daily to the attacker's bucket. (fixed)
  • F7 security: At aa1ee1b (series head 98fec93) any provider sign-in from a signed-in browser joins the signed-in account whatever its email, so a different person's verified account (or anyone holding a session briefly) gets a permanent SSO login to the owner's account with no recent-auth check; on main that sign-in gets its own account. (fixed)

Risks

A legit user whose IdP omits email_verified loses those outbound settings and their reMarkable pairing at their first email-link sign-in and has to set them up again (accepted in D14). Adopted pre-user OCR/pairing rows are kept by timestamp (second precision). Other non-outbound data the unverified sign-in made (chats, drafts) stays.

Prover

Passed (Sonnet): At c6a850f I read the diff and ran the full suite (1374 pass) in my own worktree. I looked for other outbound tables, other confirm paths, a re-pair that keeps an old row, and a strict email_verified check; I found no gap. Untested: users made before the fix, real browser flow, and concurrent sign-ins.

Every command above was run by Fortysix's Basecamp itself, on the branch named.

## What changed An unverified OIDC sign-in can no longer make an account a later sign-in joins, and the owner's email-link confirm now removes its identities, API keys and every outbound setting (backups, Vikunja, LanguageTool, OCR provider, reMarkable pairing); F2, F4, F5, F6, F7 are fixed and precommit passes (C30). ## Red, then green - An unverified OIDC sign-in A makes an unconfirmed user, and a verified sign-in B (different sub, same email) is refused instead of being linked to A's user; IdPs that omit email_verified still get a first sign-in.: `bash -o pipefail -c 'eval "$(mise activate bash --shims)"; MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs 2>&1 | tail -3'` - fails on the base (60213ac): exit 1 - passes on the branch (6a8536a): exit 0 - New accounts tests: an email-link confirm clears outbound settings an unverified sign-in set, keeps a confirmed user's, and keeps adopted pre-user data.: `export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs` - fails on the base (60213ac): exit 1 - passes on the branch (c6a850f): exit 0 ## Checks - mix precommit (compile --warnings-as-errors, deps.unlock --unused, format, full suite) passes on the #83 branch. (Upper Wolfjaw): `bash -o pipefail -c 'eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3'`, exit 0 - Read the diff and reran the accounts and OIDC tests (63 pass): unverified or missing email_verified makes an unconfirmed user, and any later same-email identity is refused (citext covers case). Untested: users made before the fix stay linkable, the magic-link path when email login is enabled, and the browser flow. (Prover): `bash -o pipefail -c 'eval "$(mise activate bash --shims)"; MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs 2>&1 | tail -3'`, exit 0 - mix precommit passes on the #83 branch at 51140ed. (Upper Wolfjaw): `bash -o pipefail -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3'`, exit 0 - mix precommit passes on the #83 branch at 98fec93 (F5 fix). (Upper Wolfjaw): `bash -o pipefail -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3'`, exit 0 - At aa1ee1b the F2 and F4 probes still pass, and so do the accounts and OIDC controller suites (68 tests), including the new test that relinks a provider that omits email_verified. (Nye): `set -e; for p in probe83 probe83b; do /home/peak/work/rm-analyzer-1-6-1/probes/$p.sh .; done; /home/peak/work/rm-analyzer-1-6-1/run-tests.sh . test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs`, exit 0 - mix precommit passes at d16b7ae (F7 fix), including two new OIDC controller tests: another email from a signed-in browser gets its own account, and a stale session can't link. (Upper Wolfjaw): `bash -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; mix precommit 2>&1 | tail -3'`, exit 0 - At d16b7ae (review/83e) the F2, F4 and both F7 probes (mine and Upper Wolfjaw's) pass along with the accounts and all controller tests, 104 tests: a signed-in browser now links a provider account only for the user's own email within 10 minutes of sign-in. (Nye): `cd /home/peak/work/rm-analyzer-1-6-1 && W=rm-analyzer && git -C $W rev-parse --short HEAD && cp probes/nye_probe83_test.exs probes/nye_probe83b_test.exs $W/test/rm_analyzer/ && cp probes/nye_probe83d_test.exs $W/test/rm_analyzer_web/ && ./run-tests.sh $W test/rm_analyzer/nye_probe83_test.exs test/rm_analyzer/nye_probe83b_test.exs test/rm_analyzer_web/nye_probe83d_test.exs test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/; rc=$?; rm -f $W/test/rm_analyzer/nye_probe83_test.exs $W/test/rm_analyzer/nye_probe83b_test.exs $W/test/rm_analyzer_web/nye_probe83d_test.exs; exit $rc`, exit 0 - mix precommit passes at c6a850f: compile with warnings as errors, unused deps, format, full suite. (Upper Wolfjaw): `export PATH=$HOME/.local/bin:$PATH && eval "$(mise activate bash --shims)" && mix precommit 2>&1 | tail -3`, exit 0 - At c6a850f I read the diff and ran the full suite (1374 pass) in my own worktree. I looked for other outbound tables, other confirm paths, a re-pair that keeps an old row, and a strict email_verified check; I found no gap. Untested: users made before the fix, real browser flow, and concurrent sign-ins. (Prover): `bash -c 'export PATH=$HOME/.local/bin:$PATH; eval "$(mise activate bash --shims)"; MIX_ENV=test mix test test/rm_analyzer/accounts_test.exs test/rm_analyzer_web/controllers/oidc_controller_test.exs 2>&1 | tail -3'`, exit 0 ## Found and fixed - F2 bug: With the #83 patch, an unverified OIDC sign-in still pre-creates a takeover account through email login: the real owner's magic-link sign-in confirms the unconfirmed user and the attacker's identity stays linked, so the attacker signs in to the victim's account (needs email login on alongside OIDC). (fixed) - F4 bug: With the F2 fix (head 92b892e), an MCP API key the unverified OIDC sign-in made while the account was its own survives the owner's email-link confirm, so the attacker's key still reaches the owner's notes after the identity is unlinked. (fixed) - F5 bug: A legit user from an IdP that omits email_verified (allowed by D6) is permanently locked out of OIDC once they use an email link: confirm deletes their identity, and re-sign-in with the same sub then fails with :unverified_email. The stated risk ("must sign in by OIDC again") is wrong; there's no way back. (fixed) - F6 security: At 9430059 the email-link confirm unlinks the unverified identity and deletes its API keys, but S3 backup settings the unverified sign-in saved while it held the account stay put, so after the real owner confirms, their library backs up daily to the attacker's bucket. (fixed) - F7 security: At aa1ee1b (series head 98fec93) any provider sign-in from a signed-in browser joins the signed-in account whatever its email, so a different person's verified account (or anyone holding a session briefly) gets a permanent SSO login to the owner's account with no recent-auth check; on main that sign-in gets its own account. (fixed) ## Risks A legit user whose IdP omits email_verified loses those outbound settings and their reMarkable pairing at their first email-link sign-in and has to set them up again (accepted in D14). Adopted pre-user OCR/pairing rows are kept by timestamp (second precision). Other non-outbound data the unverified sign-in made (chats, drafts) stays. ## Prover Passed (Sonnet): At c6a850f I read the diff and ran the full suite (1374 pass) in my own worktree. I looked for other outbound tables, other confirm paths, a re-pair that keeps an old row, and a strict email_verified check; I found no gap. Untested: users made before the fix, real browser flow, and concurrent sign-ins. Every command above was run by Fortysix's Basecamp itself, on the branch named.
jfro added this to the v1.6.1 milestone 2026-11-13 03:08:36 +00:00
A first sign-in whose email isn't verified (or whose IdP omits
email_verified) still gets an account, but it's left unconfirmed, and
no other identity is ever linked to an unconfirmed user. Before, the
account was confirmed, so a later verified sign-in with the same email
was joined to whoever first claimed the address.

Closes #83
A magic link confirms an unconfirmed user; only a sign-in that didn't
verify the email makes one, so its identity is dropped then and can't
get in to the owner's account (F2 on #83).

Refs #83
The unverified sign-in that made an unconfirmed account could make API keys
while it held the account; confirming by email link now deletes them along
with its identity, so none reaches the owner's notes (F4 on #83).

Refs #83
An email-link confirm unlinks the sign-in that made an unconfirmed
account, which left an owner whose provider omits email_verified with
no way back to single sign-on. A provider sign-in started while signed
in now links to that (confirmed) user, and the unverified-email message
says how.

Closes #83
A provider sign-in started while signed in joined that account whatever
its email said, so another person's provider account, or anyone holding
the session for a moment, got a lasting sign-in to it. It now joins only
when the email is the signed-in user's own and they signed in within the
last 10 minutes; any other sign-in is handled as if nobody were signed in.

Closes #83
fix(accounts): an email-link confirm clears where an unverified sign-in sent notes
All checks were successful
CI / test (pull_request) Successful in 2m17s
c6a850f513
Whoever held an account made by an unverified OIDC sign-in could point its
backups, Vikunja, LanguageTool, OCR provider or reMarkable pairing at their
own, and the owner's email-link confirm kept them. The confirm now clears
those settings too. An OCR provider or pairing the first user adopted from
before there were users stays unless it changed since.

Closes #83
jfro merged commit 5eea6caae9 into main 2026-11-13 11:41:18 +00:00
jfro deleted branch fix-83-oidc-unverified 2026-11-13 11:41:18 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!90
No description provided.