You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OAuth 2.1 server: no way to require MFA (aal2) for OAuth client access tokens #2838
Problem. Tokens issued by the OAuth 2.1 server always carry aal: "aal1" and amr: [{"method":"oauth_provider/authorization_code"}]. The OAuth session is created fresh at AAL1 (/oauth/token → IssueRefreshToken → models.NewSession), and the consenting session's AAL is never considered. The consent endpoints (GET /oauth/authorizations/{id}, POST …/consent) only require authentication, not a particular AAL, and the GET auto-approves a previously consented client. So a resource server that requires aal2 (e.g. an MCP server fronting sensitive data in a project that enforces TOTP for its users) cannot accept any OAuth token, and has no supported way to know that consent was given from an MFA-verified session.
An OAuth server setting to require aal2 on the consenting session for the authorize/consent endpoints, including the auto-approve path.
At minimum, pass the authorization/consent context (authorization id, or the consenting session's AAL) into the Custom Access Token Hook input, so projects can implement this themselves without relying on internal tables.
Related: #2801 (MFA verification deletes OAuth client sessions). Together these make MFA-enforced projects unable to use the OAuth 2.1 server for MCP clients.
Reacted by Adam Rokita, ghassen-agentic, rudrakshsisodia, Sidharth Vinod, vyomiii-a and allthehatz
We hit this in production: an MCP server behind the OAuth 2.1 server, in a project that enforces TOTP with a restrictive RLS policy on aal. It is reproducible on v2.197.0.
What we saw
A user who holds a verified TOTP factor and consents from an aal2 session gets an access token with aal: "aal1".
The session created at the token exchange is a new auth.sessions row at aal1, with no factor recorded and no link back to the consenting session.
So the resource server cannot tell "consented with the second factor" from "consented with a stolen password". GET /oauth/authorizations/{id} and POST …/consent both accept an aal1 JWT, and the GET auto-approves a previously consented client.
Trusting client_id does not help either, for the same reason: a password-only attacker can mint a client_id token without ever reaching the app's consent page.
What we did meanwhile
Our consent page writes a proof row through the service role, keyed on authorization id and user, after GoTrue returns success to an aal2 session. An AFTER INSERT trigger on auth.sessions (oauth_client_id IS NOT NULL) binds the new session to that proof. It binds only when exactly one approved, unexpired authorization for that user and client exists and carries a proof. This works because handleAuthorizationCodeGrant issues the session before destroying the authorization, in one transaction.
It works, but it depends on two internals we would rather not depend on: that ordering, and the shape of auth.oauth_authorizations.
What would let us delete it, in order of preference:
Carry the consenting session's aal and amr into the OAuth session at the exchange (option 1 in this issue).
Pass the authorization id, or the consenting session's aal, into the Custom Access Token Hook input (option 3), so projects can decide this in a supported way.
A setting that requires aal2 on the authorize and consent endpoints, including the auto-approve path (option 2). It would close the hole, but it does not give the token an aal2 claim, so RLS would still need a workaround.
Thanks for #2801 and #2898. The first stops MFA verification from deleting OAuth sessions. The second will need a change on our side, which we have already made: identity now comes from /oauth/userinfo.
Activity
RidderH commentedon Nov 12, 2026
We hit this in production: an MCP server behind the OAuth 2.1 server, in a project that enforces TOTP with a restrictive RLS policy on
aal. It is reproducible on v2.197.0.What we saw
aal2session gets an access token withaal: "aal1".auth.sessionsrow ataal1, with no factor recorded and no link back to the consenting session.GET /oauth/authorizations/{id}andPOST …/consentboth accept anaal1JWT, and the GET auto-approves a previously consented client.client_iddoes not help either, for the same reason: a password-only attacker can mint aclient_idtoken without ever reaching the app's consent page.What we did meanwhile
Our consent page writes a proof row through the service role, keyed on authorization id and user, after GoTrue returns success to an
aal2session. AnAFTER INSERTtrigger onauth.sessions(oauth_client_id IS NOT NULL) binds the new session to that proof. It binds only when exactly one approved, unexpired authorization for that user and client exists and carries a proof. This works becausehandleAuthorizationCodeGrantissues the session before destroying the authorization, in one transaction.It works, but it depends on two internals we would rather not depend on: that ordering, and the shape of
auth.oauth_authorizations.What would let us delete it, in order of preference:
aalandamrinto the OAuth session at the exchange (option 1 in this issue).aal, into the Custom Access Token Hook input (option 3), so projects can decide this in a supported way.aal2on the authorize and consent endpoints, including the auto-approve path (option 2). It would close the hole, but it does not give the token anaal2claim, so RLS would still need a workaround.Thanks for #2801 and #2898. The first stops MFA verification from deleting OAuth sessions. The second will need a change on our side, which we have already made: identity now comes from
/oauth/userinfo.