Skip to content

Magic link doesn't support PKCE + opens up PKCE bypass for OTP #2536

@lauri865

Description

@lauri865

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Only OTP supports PKCE, but not magic link, opening us up to a host of vulnerabilities: phishing, account takeovers via emails, etc.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Just read this line:

auth/internal/api/verify.go

Lines 135 to 138 in cda62a9

flowType := models.ImplicitFlow
var authenticationMethod models.AuthenticationMethod
if strings.HasPrefix(params.Token, PKCEPrefix) {
flowType = models.PKCEFlow

PKCE flow is triggered only for the token param, and not token_hash.

Expected behavior

PKCE enabled for magic link flows.

Docs imply that PKCE is enabled for magic link emails, but that's not the case:

Image

Also here: https://supabase.com/features/passwordless-login-via-magicklink

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions