Repository navigation
Description
Bug report
A successful native TOTP removal can be reported to the client as mfa_factor_not_found after a synchronous security-notification email exceeds Auth's request deadline. The first attempt has already committed removal; the hosted gateway retries the DELETE and the second attempt correctly cannot find the factor. This is an ambiguous mutation outcome, not an observed authorization bypass.
Related but distinct: #1878 describes SMTP-timeout logging. This report concerns a committed MFA mutation and the retry/error contract.
Environment
- Hosted Supabase Auth in an isolated, owned development project.
@supabase/supabase-js2.118.0; native TOTP with authenticator-removed notification enabled and custom SMTP.- CLI/control-plane metadata reported Auth v2.197.0; this is not independent attestation of the running binary.
- Disposable accounts/factors only; no third-party project testing.
Reproduction
- For an owned confirmed user, enroll and verify a primary TOTP factor and a second backup factor. Obtain AAL2 through the native MFA flow.
- Call
auth.mfa.unenroll({ factorId: primaryId })once, with the matching user's session. Leave security notifications enabled. - When the notification SMTP operation stalls beyond the Auth request deadline, correlate the single client removal with Auth, audit and gateway logs, then read the remaining factor state.
The hosted failure is intermittent, not every removal. A deterministic upstream test could use a controlled slow SMTP fixture exceeding the request deadline; we have not run that proposed upstream fixture.
Independently correlated observation
One owned removal request on 2026-10-24 had the following sequence under the same correlation ID (identifiers and raw logs omitted here):
| Boundary | Sanitized observation |
|---|---|
| First Auth execution | HTTP 504 request_timeout at 10,001.746 ms; attached factor_unenrolled audit for its exact target |
| Gateway | Two upstream attempts, approximately 10,154 ms total |
| Repeated Auth execution | HTTP 404 mfa_factor_not_found, approximately 5.753 ms |
| Later notification log | Removal-notification send failure about 15 seconds after request start |
| State/ownership checks | Caller, audit actor, session and target matched; primary absent and backup preserved |
The installed SDK's removal path makes one DELETE; our application does not retry it. Attempt-count metadata alone was not treated as proof: the two correlated Auth outcomes and committed audit supplied the additional evidence.
Source corroboration
The inspected v2.197.0 UnenrollFactor commits factor deletion, audit and session downgrade, then synchronously calls sendMFAFactorUnenrolledNotification before its success response. The timeout middleware can return a timeout while that handler continues. This source ordering is consistent with the hosted trace; it does not by itself attest the hosted binary or all gateway configurations.
Expected behavior / requested investigation
Please investigate how to keep notification delivery reliable without allowing notification latency to turn an already committed factor removal into a failed/ambiguous response, and whether the gateway should repeat this mutation after that timeout. A durable provider-side asynchronous handoff would need delivery/retry guarantees; merely disabling security emails or increasing the timeout is not the requested resolution.
Without a gateway retry, a direct timeout/lost response can still leave the same commit uncertainty. Our app mitigation refreshes and reloads same-account factor readiness once, never retries DELETE, preserves the original failed outcome, and does not treat every not-found response as success. Strict native lifecycle/removal/audit tests remain intact. Later successful runs do not close the provider issue.
No credentials, TOTP secrets/codes, user/session/factor IDs, message bodies or raw logs are included. Sanitized correlation details can be shared privately with Supabase if needed.
Activity
ayu04ayush commentedon Oct 26, 2026
Hi I would like to work on this issue I will look into the MFA unenrollment flow and check how the notification email affects the response after the factor has already been removed I will explore handling notifications asynchronously and add tests for timeout and retry scenarios to make sure the removal result is handled correctly Could you assign this issue to me Thanks
Hallidayo commentedon Oct 26, 2026
Transferred from the
supabase/supabaserepo.melcheikh commentedon Nov 3, 2026
Opened #2897. It stops a committed change from being reported as a 504 when the notification mail is slow. It does not make delivery more reliable; the PR describes an outbox approach for that part, so this issue should stay open.