Repository navigation
Socrate v1.16.1
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 onadmin_logs.app_idand rewrites no data. - Client-facing changes:
- the sign-in attempt that locks an account answers
401 invalid_credentialsinstead of403
account locked; POST /api/profile/mfa/confirmanswers200with the firstrecovery_codesinstead of
204;- the
/api/profile/mfaposts are rate-limited per user (429); POST /api/profile/mfa/disableanswers403once the account is locked.
- the sign-in attempt that locks an account answers
- Recovery codes: deploy the admin console v1.7.4 (it sends the password and a code, and takes
confirm's codes), then runMFA_RECOVERY_CODES_REVERIFY_MODE=observeand look for
mfa_recovery_codes_reverifyevents withwould_refuse_missingbeforeenforce. - Token exchange and DPoP changes apply only with
TOKEN_EXCHANGE_MODEorDPOP_MODEon.
An existing public client withallow_token_exchangekeeps 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, defaultoff).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. Underenforceit needs{"password","code"}, checked as for MFA disable (each wrong
one counts toward the lockout;400without them,401when wrong,403once locked);
observeallows and auditsmfa_recovery_codes_reverifywith whether the request carried
them;offchanges nothing. So that turning MFA on still gives the first codes,POST /api/profile/mfa/confirmnow answers200with them (recovery_codes) instead of204: 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 isenforce. Deploy note:
upgrade the admin console (which sends the password and code, and takes confirm's codes)
before settingobserveorenforce. 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/disablechecked 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/mfaposts 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 answered403account locked, an answer an unknown email never
gets, so a few wrong passwords told whether an email names an account. That attempt is now
answered401invalid 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 gets403account locked. With
LOCKOUT_SOURCE_MODE=enforcethe same holds for the source lock. A wrong MFA code that locks
the account still answers403: whoever sent it has passed the password check. Client-facing
change: the locking attempt's status moves from403to401; 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_MODEshadoworenforce; 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(400on 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.
- an exchanged token never targets an operator console (
-
/oauth/revokeand/oauth/logoutcheck 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: underenforcesuch a token is ignored and the request is
handled as anonymous; underobservethe failure is logged and the token accepted; under
offnothing changes. They also accept theDPoPscheme when binding is on.
Fixed
-
cmd/seed -forceends earlier password-reset links. Resetting the superadmin with
-forceset a new password without recording when, so a reset link issued before it stayed
valid; it now setspassword_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 fromadmin_logs.app_idtoappsmade 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.