Skip to content

Commit 2a250cf

Browse files
committed
feat: increment refresh token counter by 2 for mfa verify
1 parent 7f36eb0 commit 2a250cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/api/token.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,13 @@ func (a *API) updateMFASessionAndClaims(r *http.Request, tx *storage.Connection,
333333
return apierrors.NewInternalServerError("Failed to get session's refresh token key").WithInternalError(terr)
334334
}
335335

336-
counter := *session.RefreshTokenCounter + 1
336+
// Incrementing the refresh token counter by 2 here is
337+
// counter intuitive, but is important for security. It
338+
// means that the previous refresh token (issued with
339+
// AAL1) will no longer be able to issue AAL2 sessions.
340+
// It forces the client to have received the refresh
341+
// token from the MFA verification flow.
342+
counter := *session.RefreshTokenCounter + 2
337343
session.RefreshTokenCounter = &counter
338344

339345
issuedRefreshToken = (&crypto.RefreshToken{

0 commit comments

Comments
 (0)