Skip to content

Socrate v1.16.1

Choose a tag to compare

@github-actions github-actions released this 26 Nov 09:06
· 11 commits to main since this release
190c441

Security patch release on the v1.x line. It closes what was left of the v1.14.2 audit: turning
MFA off and replacing the recovery codes are re-proved and count toward the lockout, the attempt
that locks an account no longer reveals that it exists, token exchange never yields an
operator-console token, and revoke and logout check a DPoP-bound token's proof. One migration,
one new control (off by default, MFA_RECOVERY_CODES_REVERIFY_MODE), no change to discovery
or claims.

Upgrade notes

  • Migration 0038 (AUTO_MIGRATE=false: run it deliberately, after a backup). It drops the
    foreign key on admin_logs.app_id and rewrites no data.
  • Client-facing changes:
    • the sign-in attempt that locks an account answers 401 invalid_credentials instead of 403
      account locked;
    • POST /api/profile/mfa/confirm answers 200 with the first recovery_codes instead of
      204;
    • the /api/profile/mfa posts are rate-limited per user (429);
    • POST /api/profile/mfa/disable answers 403 once the account is locked.
  • Recovery codes: deploy the admin console v1.7.4 (it sends the password and a code, and takes
    confirm's codes), then run MFA_RECOVERY_CODES_REVERIFY_MODE=observe and look for
    mfa_recovery_codes_reverify events with would_refuse_missing before enforce.
  • Token exchange and DPoP changes apply only with TOKEN_EXCHANGE_MODE or DPOP_MODE on.
    An existing public client with allow_token_exchange keeps it, inert; turning it on for one is
    refused (400).

Security

  • Replacing the MFA recovery codes can require the password and a code
    (MFA_RECOVERY_CODES_REVERIFY_MODE, default off). POST /api/profile/mfa/recovery-codes
    hands out a fresh set of recovery codes, a second factor, to whoever holds the user's access
    token. Under enforce it needs {"password","code"}, checked as for MFA disable (each wrong
    one counts toward the lockout; 400 without them, 401 when wrong, 403 once locked);
    observe allows and audits mfa_recovery_codes_reverify with whether the request carried
    them; off changes nothing. So that turning MFA on still gives the first codes, POST /api/profile/mfa/confirm now answers 200 with them (recovery_codes) instead of 204: the
    code just used cannot be used again. Client-facing change: confirm's new body; a client that
    ignores it and asks for codes afterwards still works unless the mode is enforce. Deploy note:
    upgrade the admin console (which sends the password and code, and takes confirm's codes)
    before setting observe or enforce. The hosted account page, behind its fresh sign-in, is
    unchanged.

  • Turning MFA off counts failed attempts toward the account lockout, and the MFA routes are
    rate-limited.
    POST /api/profile/mfa/disable checked the password and the code without
    counting failures and had no rate limit, so whoever held a user's access token and password
    could try codes without limit and switch the second factor off; the hosted account page's
    disable step did not count a wrong code either. Both now go through the auth service's new
    ReverifyForMFAChange, which uses the sign-in checks (checkPasswordWithLockout, stepUpMFA):
    each wrong password or code counts, and a locked account is refused (403) before anything is
    checked. The /api/profile/mfa posts are rate-limited per user with the login limiter (429).
    Closes the gap the v1.14.2 audit's H-2 fix left on this route. No new setting.

  • The attempt that locks an account no longer reveals that it exists. The wrong password that
    reached the lockout limit was answered 403 account locked, an answer an unknown email never
    gets, so a few wrong passwords told whether an email names an account. That attempt is now
    answered 401 invalid credentials, like any wrong password; the account is still locked and
    the lock audited (account_locked), and, as since
    v1.15.0, only the right password then gets 403 account locked. With
    LOCKOUT_SOURCE_MODE=enforce the same holds for the source lock. A wrong MFA code that locks
    the account still answers 403: whoever sent it has passed the password check. Client-facing
    change: the locking attempt's status moves from 403 to 401; a client that showed "account
    locked" on it shows "invalid credentials" until the next attempt with the right password.

  • Token exchange hardening (only with TOKEN_EXCHANGE_MODE shadow or enforce; the v1.14.2
    audit's T-1 and T-3 leftovers):

    • an exchanged token never targets an operator console (OPERATOR_CONSOLE_CLIENT_IDS,
      ADMIN_CONSOLE_CLIENT_ID) or Socrate's admin portal, even one registered as the client's
      audience: it would be an admin-API credential (invalid_target, audited
      deny_reason: console_audience);
    • the token-issuance hooks (hooks.OnBeforeTokenIssue) now run on an exchange too, with grant
      token_exchange, and can veto it as any other grant;
    • a client without a secret can no longer be given allow_token_exchange (400 on create, or
      on an update that turns it on): the exchange authenticates the client, so it could never use
      it. An existing public client that has it keeps it, inert, and can still be updated otherwise;
    • a hook's veto on an exchange answers 403 access_denied, as on the other grants.
  • /oauth/revoke and /oauth/logout check a DPoP-bound token's proof (DPOP_MODE, default
    off; the v1.14.2 audit's G-4 follow-up). Their optional bearer identity was read without the
    binding check, so a stolen bound token, used as a plain bearer token, could log its user out
    (revoking their tokens) or name them to /oauth/revoke. They now use
    OptionalAuthMiddlewareWithDPoP: under enforce such a token is ignored and the request is
    handled as anonymous; under observe the failure is logged and the token accepted; under
    off nothing changes. They also accept the DPoP scheme when binding is on.

Fixed

  • cmd/seed -force ends earlier password-reset links. Resetting the superadmin with
    -force set a new password without recording when, so a reset link issued before it stayed
    valid; it now sets password_changed_at, as every other password change does (the v1.14.2
    audit's #366 follow-up). The account page's sign-in is also covered by the every-path lockout
    test.

  • Deleting an app keeps its admin-log rows' app_id (migration 0038, #260 follow-up). The
    foreign key from admin_logs.app_id to apps made app deletion null that column, so the admin
    log lost which app an action concerned. Migration 0038 drops every foreign key on it, as 0036
    did for the security audit log; the model no longer declares one (constraint:-), and app
    deletion leaves the rows as they are. Deploy note: migration 0038 runs on start; it drops a
    constraint only and rewrites no data. Rows nulled by earlier deletions stay null.