Skip to content

fix: return verify-disabled error code when WebAuthn MFA verification is off - #2803

Open
Dhvanit41 wants to merge 1 commit into
supabase:masterfrom
Dhvanit41:fix/mfa-webauthn-verify-disabled-error-code
Open

Dhvanit41 wants to merge 1 commit into
supabase:masterfrom
Dhvanit41:fix/mfa-webauthn-verify-disabled-error-code

Conversation

@Dhvanit41

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When MFA verification is disabled for WebAuthn (GOTRUE_MFA_WEB_AUTHN_VERIFY_ENABLED=false), POST /factors/{id}/verify returns:

{ "code": 422, "error_code": "mfa_webauthn_enroll_not_enabled", "msg": "MFA verification is disabled for WebAuthn" }

The message says verification is disabled, but the error code says enrollment is. Every other "verify disabled" path already returns the matching code:

Endpoint Phone TOTP WebAuthn
POST /factors/{id}/challenge mfa_phone_verify_not_enabled mfa_totp_verify_not_enabled mfa_webauthn_verify_not_enabled
POST /factors/{id}/verify mfa_phone_verify_not_enabled mfa_totp_verify_not_enabled mfa_webauthn_enroll_not_enabled

Both codes are part of the public ErrorCode union in auth-js, so a client that branches on error.code gets the wrong code at this one call site. It looks like a copy-paste slip from when WebAuthn MFA was added (#1775).

What is the new behavior?

VerifyFactor returns mfa_webauthn_verify_not_enabled for disabled WebAuthn verification, matching ChallengeFactor and the phone/TOTP branches. The message is unchanged.

Additional context

  • Added TestVerifyFactorVerifyDisabled, a table test that checks the verify-disabled error code for phone, TOTP and WebAuthn factors. The WebAuthn case fails on master (expected: "mfa_webauthn_verify_not_enabled", actual: "mfa_webauthn_enroll_not_enabled") and passes with this change.
  • Ran locally: go test ./internal/api/... (all packages pass), gofmt -s, go vet, staticcheck.
  • HTTP status stays 422, so the only behavior change is the error_code value on this path.

… is off

When MFA verification is disabled for WebAuthn, POST /factors/{id}/verify
returned the mfa_webauthn_enroll_not_enabled error code, even though the
message says verification is disabled. The challenge endpoint and the phone
and TOTP branches of verify already return their *_verify_not_enabled codes,
so clients checking error.code could not tell the two cases apart.

Return mfa_webauthn_verify_not_enabled instead, and add a test covering the
verify-disabled error code for phone, TOTP and WebAuthn factors.
@Dhvanit41
Dhvanit41 requested a review from a team as a code owner September 15, 2026 04:45
@Dhvanit41

Dhvanit41 commented Sep 15, 2026

Copy link
Copy Markdown
Author

@fadymak this one is ready to review whenever you get somechance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant