Repository navigation
Security: a two-factor challenge is not a session - #220
Merged
Merged
Conversation
The password step of a 2FA sign-in returns a five-minute challenge, signed with the shared JWT secret and carrying the user's sub. decode_token, which every session check uses (the API middleware and the live-audio websockets), accepted it, so the password alone opened the API. decode_token now refuses it; the second step reads it through decode_challenge_token as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1geD2ELWgL2sDpxYbx3Aw
davior
marked this pull request as ready for review
November 4, 2026 20:52
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.
Summary
A 2FA bypass, live in production; this is the source of it. When someone with two-factor on signs in,
POST /api/auth/loginreturns a five-minute challenge token for the second step. It is signed withJWT_SECRET_KEYand carries the user'ssub.decode_token, which every session check uses (the API middleware and the live-audio websocketsstt_streamandflux_stream), did not look at thetwofa_pendingclaim. So the challenge worked as a full session: the password alone opened the API, as a bearer header or as thegecko_sessioncookie. The same token opened GAM and GVC (fixed in gam#62 and gvc#41, both merged) and the suite (fixed in its M6 accounts work).decode_tokennow refuses a token withtwofa_pending(it raisesJWTError, so every caller answers 401 as for any bad token).decode_challenge_token, which decodes directly and still requires the claim, so 2FA sign-in works exactly as before.Test plan
tests/test_auth_cookie.py:test_a_two_factor_challenge_does_not_open_the_api: a challenge is refused as a bearer header and as the cookie.test_the_second_step_still_reads_its_challenge: the challenge still works for step two, and a session still cannot stand in for a challenge.pytest -q: 1399 passed, 1 skipped.Deployment
docker compose up --build -d). No configuration, no migrations.curl -f http://localhost:18081/api/health. Signing in with 2FA still works end to end (password, then code). Normal sessions are unaffected.Generated by Claude Code