Files
summercms/.planning/todos/done/2026-10-26-activate-by-code-second-factor.md

2.3 KiB

title, date, priority, area, g15office
title date priority area g15office
activate-by-code mints a session without the second factor when require_activation is off (finding F-1) 2026-10-26 low sm-user-plugin yfadd1mb

sm-user-plugin's POST /_user/api/v1/activate-by-code signs the account in (mintFor) without asking the login gates. Phase 19.6 plan 01 accepted that path because "a new or not-yet-activated account cannot have 2FA yet". That reason holds only with the default golem15.user.activation.require_activation: true. With require_activation: false and activate_mode: user, a not-activated account signs in with its password, can enable TOTP (sm-mfa-plugin), and a later activate-by-code with the mailed activation code answers {"message":"Account activated","token":…} with no challenge. The mailbox alone then stands in for the second factor, which a password reset does not allow (a reset mints no token).

Found and reproduced by 19.6-04 (security review finding F-1, 19.6-SECURITY-REVIEW.md "Open findings"): register in mode user, password login, TOTP setup and confirm, the next password login is challenged, IssueActivationCode, activate-by-code answers 200 with a token.

The user deferred it at 19.6-04 Task 5 (2026-10-26). Impact is low: it needs the non-default configuration, a user who enabled a second factor before activating, and the user's unexpired activation code.

To fix later:

  • In ActivateByCode, after VerifyActivationCode succeeds, call CheckLoginGates for the user (a source the mfa gate challenges, for example LoginSourcePassword, or a new LoginSourceActivation together with an sm-mfa-plugin gate change) and answer the gate's body instead of the token; the account stays activated.
  • Add a test in sm-user-plugin (a gate that challenges, then activate-by-code answers the challenge) and an end-to-end case in sm-mfa-plugin's TestEveryLoginPathIsGated, and update its tokenMints reason.
  • Release sm-user-plugin as a patch and bump sm-demo-app, sm-bm-app and fonoteka.go in separate commits (D-17 order).
  • Until then, TestEveryLoginPathIsGated/mint_sites lists ActivateByCode with a pointer to F-1, so any change to the mint sites fails until the list is updated.

Closed 2026-11-05

Fixed in quick 261105-oc5: sm-user-plugin b179e6b (activate-by-code asks the login gates). Untagged; release sm-user-plugin v0.1.20 and bump the apps.