auth: auth.signUp() doesn't error for existing accounts - security vulnerability

Bug report

Describe the bug

supabase.auth.signUp() is not erroring for existing accounts. Right now, you can submit an existing email with any incorrect password, and supabase will return you the account metadata (without a jwt).

To Reproduce

Go to this example app Sign-up with an email and a password Log out Try to sign up again with the same email using any password you want. Try asdfasdfasdf if you want! You will get an alert saying you logged in, but you won’t get a working access token. Just the email you submitted. You can also view the request in the Network tab of the Dev Tools and see metadata about the account, like when it was created and what provider it uses.

Expected behavior

Attempting to sign up with an existing email should throw an error.

System information

  • Version of supabase-js: [1.2.1]
  • Version of Node.js: [14.17.4]

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 18
  • Comments: 94 (12 by maintainers)

Most upvoted comments

This ‘security fix’ seems like ‘security through obscurity’ . IMHO it doesn’t make sense for supabase to be opinionated about how a signup process should be handled by developers. There are many use cases where a back-end service may need to know if a user already exists and having to store an additional user profile table just to be able to figure this out seems to be an unnecessary extra step. Perhaps the ‘service key’ responses can be accurate while the ‘app key’ responds with a generic ‘invalid credentials’?

Ahh, very interesting. Would be great to maybe add that to the docs somewhere, because I suspect I won’t be the only one confused by it. Firebase returns an error in this situation so that is what I was expecting, but I like the faux info return as an even better solution! Thanks for the response and enjoy your weekend.

Hey everyone thanks for your comments!

To be clear this is not an example of security through obscurity, the red herring here might be the presence of faux info or the fact that we haven’t done a good job of documenting this behavior. As long as we don’t leak any info about whether a user account exists or not on any public endpoint, then the information is secure (at least as far as this specific issue is concerned).

The correct solution here is to take this one step further: If a user tries to sign up who already has an existing account, we still return a “check your inbox for confirmation email” message, but we instead send them an account recovery email (which is actually just a magic link) then the developer can decide whether to direct them to a password reset page or just allow them to go about their session as normal.

This solves for:

  • UX concerns (a user who has forgotten that they have an account and is expecting a confirmation email, will receive an account recovery email - note: the developer can edit the template in supabase dashboard)
  • DX concerns (there should be no extra call required to detect account existence and trigger account recovery)
  • Security (the presence of an account is never revealed on any public endpoint)

An important reason for why we decided to be “secure by default” on issues like this, is partly because of the number of users adopting our auth service. I could fairly easily take your email address, make a sign-up request to every known supabase endpoint on the internet, building up a map of all the various services that you are/are-not subscribed to. Which is quite a large privacy concern.

I propose that we do several things:

As always any help on these ones would be hugely appreciated. And thanks again for the active discussion and helping improve the product 🙏.

You can use this method until Supabase solves this problem

        const {error, data} = await supabase.auth.signUp({email, password})
        if(data?.user?.identities?.length === 0){
              alert("This user already exists")
         }

I also agree that security through obscurity is not a good way to fix this as most services online do tell you if a user already exists, what they do have however is a rate limit on how many logins you can try within a certain time period to prevent brute force attacks. This fix should probably be reverted as the behaviour is unexpected and it seems to be confusing users more than anything.

hey @CalebLovell this is actually a fix for a previous security issue.

Previously the interface was leaking information by allowing an attacker to see whether a given email had an account or not. Now the endpoint returns a “success” response regardless of whether an account exists already or not.

The metadata you see in the response is actually faux info - the user ID is random and the datetimes are set to the time that the request was made.

note: this is only the case for supabase instances where AUTOCONFIRM is disabled (as per the default) for accounts who have enabled AUTOCONFIRM (where accounts don’t require email confirmation) the behavior is the same as before (error on duplicate accounts)

hope this helps!

How is this hack:

const {error, data} = await supabase.auth.signUp({email, password})
if(data?.user?.identities?.length === 0){
    alert("This user already exists")
}

still the acceptable solution? A hacker could also read this thread and exploit the hack to see if the user exists. This means that the “security” argument is not valid.

It’s almost over half a year and this issue seems stale.

We are hitting the exact same issue. Registered users with verified email addresses can forget they already signed up, they go through the sign up process, we show the message to check their emails, but no email arrives.

Any solutions?

@awalias so if the user is trying to create an account, when they already have one, is there a way to let me know?

@awalias - There still seems to be a mismatch here that I’m trying to work through. My account is set-up to require email confirmations.

  • If I try to signUp a user using the email address for an existing user that has not been confirmed, it returns the obfuscated user, and an additional “Confirm Your Signup” email is sent to the email address
  • If I try to signUp a user using the email address for an existing user that has already been confirmed, it returns the obfuscated user, but no email is sent to the user

Based on what you mentioned above, it would seem that a confirmation/recovery email should be sent in both case and in the UI, one can simply direct the user to check their email. That said, I’m not sure how to handle the case where a user already signed up using that email without them getting confused on the what the password is. In the case of a confirmed user getting an account recovery email, their mental model would be the password they just entered, which would be wrong if it’s different than the one actually associated with the account.

For anyone stumbling on this issue.

The docs for auth.signup mention:

When either Confirm email or Confirm phone (even when phone provider is disabled) is disabled, the error message, User already registered is returned.

So disabling the Enable phone confirmations setting in the phone provider on the auth providers page (while having Confirm email enabled in the email provider) should throw the User already registered error.

To have the same behaviour locally, add the following to config.toml:

[auth.sms]
enable_signup = false
enable_confirmations = false

Sources: https://github.com/supabase/supabase/issues/18195#issuecomment-1903824780 https://github.com/supabase/supabase-js/issues/947

Thanks to @842u

In the case where a user forgets they are already signed up with their email address, most websites will show some variation of “there’s already an account for this email address”.

If a user tries to sign up with an email that already has an account associated with it, how can I tell so I can let the user know?

@awalias so if the user is trying to create an account, when they already have one, is there a way to let me know?

Building off of this, I think the crux of this issue and what we want to know is what should an average auth flow look like, implementation-wise, when built with Supabase? The only guide available in the official documentation uses magic links “for simplicity” but doesn’t really touch on how to handle any error or edge-case scenarios, which is extremely important in production.

I’d just like to know how to do it properly, whichever the security measures taken are.

TLDR: you guys at Supabase have created an amazing product, but you’re on the wrong here. Do the wise thing and listen to your customers

I don’t understand why this is such a problem. Almost every service I use shows an error message if an user tries to sign up with an already existing email (even supabase themselves). image

@hf thank you for taking the time to answer. I trust that you will find the best solution. I figured I would share my opinion/preference, while taking the “attacker” angle into account.

Ideally, if the e-mail address is already registered, there are 2 cases:

  1. The user has already confirmed their email address. We show the “Check your email for the confirmation link.” message for security purpose (so an attacker can’t tell that there is an account under this email address), but we actually send the user an e-mail to tell him that he’s already got an account.

  2. The user has not yet confirmed their email address. We show the generic check your email message again and we send the user the confirmation email again.

Presently, if a user is already registered, we show the check your email message but the user receives no email whatsoever.

hey! Was just discussing this issue with @hf in depth - his opinion is that since it’s still possible for people to determine the existence of accounts with side-channel attacks (e.g. time how long it takes to get a response, if an email is sent it will take longer etc.) that by default we should return an error similar to how firebase does it. e.g. “This email already exists”.

Then the idea is to make this functionality optional to people who require more privacy controls. There is some draft documentation on the issue here: https://github.com/supabase/supabase/blob/f8682bbb095d728ee19a581170a5d972a39543e4/apps/reference/docs/guides/auth/auth-security.mdx#user-information

In the meantime I will check if we can revert the default behavior to always give an error for existing accounts

@naegelin I also agree with your idea that the admin endpoints should return truthful responses, if you are creating an account from the backend. We recently added auth.api.createUser I’m not sure what the behavior of this method is for existing accounts.

edit: it looks like this already works as expected - again the issue here is lack of documentation

{
  data: null,
  error: {
    message: 'Email address already registered by another user',
    status: 422
  }
}

UX is not something you can sacrifice Security is not something you can sacrifice But they often go against each other and then one has to make a choice, like the lifetime of an access token. So it’s up to a specific case, company requirements, etc to identify what is the most optimal solution.

This behavior without doubt must be configurable. I’m very surprised it’s not now. We are a local B2B company and we are much more concerned about users forgetting their email accounts then with leaking that an email exists in our system. Please, make it a config. The developers must be able to decide what is best for them, not you.

Seems like if we can just check if(data?.user?.identities?.length === 0){ then bad hackers could just read this thread, detect supabase, and check that too. So, why not just return an error code instead?

Hey guys, here’s an interesting finding → it appears that if you’re running signUp from the server side / from a serverless function (using the service key), the returned error actually contains the message “User already registered” as opposed to running is anonymously - case in which, yes, a fake user is returned. So a reliable alternative would be to just create a custom Edge function and have that invoked. Then the function can handle the scenario however you want (send an email, forward the error etc.).

Being a leader in the industry requires difficult decisions to be made. A lot of this seems to revolve around hesitation and trying to appeal to everyone, and it’s not like there hasn’t been time to decide on a roadmap for this: it’s been nearly 3 years. The result is a lackluster solution for everyone.

Every security control can be defeated. Supabase shouldn’t be responsible for solving every edge case of security for app developers and many companies have regulatory guidance on how to implement authentication flows. There should be a straight forward api available for server to server calls so that developers can decide what the proper pattern would be for themselves based on their own needs. The current Supabase position is to create an associated “user profile” table inside supabase in order to recreate missing functionality (such as basic checks to see if a user exists). The more of these types of work arounds a developer needs to create, the less compelling supabase becomes over say a vanilla postgres + hasura instance. I would also argue that for B2B applications where access is not available to the general public many of the concerns around account harvesting, fake registration etc are much less of an issue.

Disabling the phone confirmation (whether you are using it or not) will work.

@hf I understand the strong desire to avoid providing any means for hackers to identify valid email addresses but the resulting UX is horrible and this is a policy that should be determined by each organizations using Supabase, not Supabase itself (globally). The result is a nasty and problematic onboarding experience. I was in your shoes arguing for tighter control until I became responsible for user creation and management at coindesk.com where I had to be more pragmatic because of this was the #1 reason for new users to abandon the onboarding process (and resulting Support nightmare).

We keep discussing this, but it’s such a hard choice to make for people.

What I don’t understand is why this cannot simply be an option on the email or general Auth settings, that organizations can choose the behavior of.

(I want to use Supabase, but I am now actively working on moving my projects to Firebase due to the onboarding user experience forced on us by Supabase.)

I propose that we do several things:

As always any help on these ones would be hugely appreciated. And thanks again for the active discussion and helping improve the product 🙏.

2.5 years later it looks like:

  • the docs link is now a 404
  • this second point has not been done yet. The example signup just tells duplicate signup user to look for the confirmation email that is not coming.
  • the third point: I don’t know how many duplicate signups you need to request but I have been testing this quite a bit and have not received any emails for a “successful” but duplicate signUp.

I have yet to find any guidance from Supabase on how to handle the user experience and UI flow for when a user attempts a duplicate signup. The example code just tells them to check for the confirmation email (which is an incorrect UI that misleads the user).

So the official answer here is to create an edge function that uses the admin API to find out if a user exists and then expose that to the anon client for improved UX handling? If we’re going to expose that anyway, what’s the point of hiding it in an edge function and using the admin API?

I’ve been huge on Supabase for a long time now but the handling of this mess is almost enough to make me switch to Firebase where they actually return an error for an error.

@Saranoja thank you!! That’s super helpful to know.

@awalias @kiwicopple hope supabase leave the freedom to developers to decide how to handle existing accounts instead of dictating a solution that is really not helpful for a lot of use cases

I also agree that security through obscurity is not a good way to fix this as most services online do tell you if a user already exists, what they do have however is a rate limit on how many logins you can try within a certain time period to prevent brute force attacks. This fix should probably be reverted as the behaviour is unexpected and it seems to be confusing users more than anything.

Correct. Rate limited logins would be the correct process for this, but it’s also difficult to defend against some forms of attack unless they are targeting one specific account, in which case locking that account from logging in for a duration or until an account owner performs some verification process.

If an attacker is aiming to test as many accounts as possible, then the options are either cookies (easily defeated) or IP blocking (also easily defeated). There’s some hybrid options out there such as behaviour analysis, but they have their own set of limitations and potential for false positives.

Rate-limiting registration isn’t feasible to introduce as an attacker could easily bombard the system with fake registrations and block legitimate users from registering. For ecommerce sites, this would potentially make it a haven for scalpers. At the same time, it becomes difficult for developers when they’re unsure if an account exists during registration.

What most online services have is a generic truthy response during the account recovery process. For example, instead of saying “An email was sent to the account we found”, they’ll instead say “If an account with this email exists, we have sent an email to it”. I believe rate limiting per account already exists for this in Supabase.

It’s a difficult problem to solve because there’s potential for hackers to use the sign up process to ascertain if an account exists (as opposed to testing login), but developers want to know if an account exists when a user is registering.

It’s strange that it works only after disabling Enable phone confirmations in the phone provider, even though the provider itself was already disabled. I also tried signing up with unique details but using the same email—expected it to trigger the email_exists error code, but instead it returns user_already_exists.

Another victim here. And just to be clear this has nothing to do with email confirmation but the enable phone confirmation under phone provider even if we are not using it. our workaround is to just disable that and then the user_already exists starts showing up. Very peculiar .

What I don’t understand is why this cannot simply be an option on the email or general Auth settings, that organizations can choose the behavior of.

It can be an option, but it needs to be built securely and for us to be able to maintain it properly. I understand your predicament and past experience, but in this case it’s not just one web property that we’re securing but tons. Some want this, some want the other thing.

If we commit to adding an option now, we have to commit to maintain the option until end-of-time. This is not something we’re prepared to do at this stage, but is definitely at the forefront of the team’s mind. Until we identify a way to do this properly we are not going to jump into quick fixes.

Same problem, this is an incredibly goofy decision to not return a basic error. At least make it configurable to turn the error on and off.

I’m seeing it does return an error. When using the following:

const { error } = await supabase.auth.signUp({ email, password })

error.message will contain “user already registered” as the error message, if the user already exists.

For anyone stumbling on this issue.

The docs for auth.signup mention:

When either Confirm email or Confirm phone (even when phone provider is disabled) is disabled, the error message, User already registered is returned.

So disabling the Enable phone confirmations setting in the phone provider on the auth providers page (while having Confirm email enabled in the email provider) should throw the User already registered error.

To have the same behaviour locally, add the following to config.toml:

[auth.sms]
enable_signup = false
enable_confirmations = false

Sources: supabase/supabase#18195 (comment) supabase/supabase-js#947

Thanks to @842u

Funny but it works 😄

This is a very odd design. AWS cognito returns the error message. It seems really dogmatic to have gone down this route and now you are just defending the point because its been done. Is there any way to tell the user the account already exists?

I’ve been huge on Supabase for a long time now but the handling of this mess is almost enough to make me switch to Firebase where they actually return an error for an error.

Sorry to hear that. It’s hard for us to decide anything more concretely on this point since some Supabase users expect this behavior, while others like you expect the other one.

We keep discussing this, but it’s such a hard choice to make for people. Until we are able to devote more time to figure out how to make this “anonymization” configurable, the behavior remains the same.

As mentioned here: https://github.com/supabase/auth-js/issues/513#issuecomment-1826233042, it seems to me that the latest docs have clarified the approach:

If signUp() is called for an existing confirmed user: When both Confirm email and Confirm phone (even when phone provider is disabled) are enabled in your project, an obfuscated/fake user object is returned. When either Confirm email or Confirm phone (even when phone provider is disabled) is disabled, the error message, User already registered is returned.

It’s still not an optimal solution, but at least we can get an explicit error message by disabling the email confirmation. The error response looks like:

{"code":422,"error_code":"user_already_exists","msg":"User already registered"}

@awalias, would it be possible to get an update on where supabase stands on this issue? The behaviour is a little strange to say the least, and it seems like there isn’t a firm stance ~3 years after this has been first reported. I love the package so far, but there’s the odd bug/strange behaviour here and there that would be great to get resolved. Hacking around this by checking the identities array isn’t optimal.

Same problem, this is an incredibly goofy decision to not return a basic error. At least make it configurable to turn the error on and off.

it would be really helpful if you can let developers decide how to handle this instead of forcing a solution. it’s always a balance between security and convenience and nothing is absolutely secure. each service has different needs and developers can choose what works the best for their use cases

There’s a simple way to implement this check yourself.

Create a database function called get_user_id_by_email:

BEGIN
  RETURN QUERY SELECT au.id FROM auth.users au WHERE au.email = $1;
END;

and call it in your app like this:

const { data: emailExists, error } = await supabase.rpc("get_user_id_by_email", { email: "foo@example.com" });
if (emailExists?.length) console.log('Email already exists');

I’ve already done this but you can’t stop a User from being created via Social auth (like Google, Apple etc) as you can’t check an email from Social prior to the user logging in, only afterwards. And by that time the User is already created, which doesn’t make any sense.

There’s a simple way to implement this check yourself.

Create a database function called get_user_id_by_email:

BEGIN
  RETURN QUERY SELECT au.id FROM auth.users au WHERE au.email = $1;
END;

and call it in your app like this:

const { data: emailExists, error } = await supabase.rpc("get_user_id_by_email", { email: "foo@example.com" });
if (emailExists?.length) console.log('Email already exists');

I’m new to supabase and am running into this same issue. It’s very confusing.

If an account already exists, having a magic link automatically sent to the user would work fine but… it doesn’t happen so…

Seems like if we can just check if(data?.user?.identities?.length === 0){ then bad hackers could just read this thread, detect supabase, and check that too. So, why not just return an error code instead?

Yep I’m using this workaround too, seems to work as intended, thanks - but yeah I don’t see the point of sending obfuscated user data when it can easily be debunked in this way. As devs we should get the choice on how to handle this, not have user authentication flow behaviour forced upon us.

@hf Thank you for your response. That was actually very insightful and explains well why any technical changes are not easy to pull off for Supabase as a company with its current values and promises.

However, I think there is a lot that can be done besides technical changes.

  1. Communication: Had I read this issue a week ago, I would have been very disappointed. It’s one of those threads that devolves into a collection of rants, but no reaction from the devs for years. This issue doesn’t have the most thumbs up in this repo but the most comments and participants. More regular feedback could help people feel heard and not ignored.
  2. API Documentation: The docs currently state Be aware that if a user account exists in the system you may get back an error message that attempts to hide this information from the user. I had no idea what this was supposed to tell me. What does this statement mean for me as a developer? What does it mean for my users? What is the recommended workflow in that situation?
  3. Tutorials: I started working with Supabase Auth through the Build a User Management App with Flutter guide and everything seemed so easy. However, going from magic links to email+password felt very confusing. Auto-confirmation is active when developing locally but it is deactivated by default on hosted Supabase, so locally I get an error message signing up twice, but in production that doesn’t happen. And then no email gets sent…

Tackling these issues does not require years to pull off and would probably save a lot of people a lot of time and energy. Better documentation would have saved me a few hours for sure.

There are simpler solutions than making it an option, such as for these “successful” registrations, just send the confirmation email, or one that says “You already have an account; here is a link to login.” The problem is the expected email never comes and no messages can indicate to the user that it is not coming, because the Supabase client is not informed that it was not a successful registration.

Just send any reasonable email on a successful registration. We don’t really need the option, just that if you’re dead set against changing the SB behavior then give us the ability to do so.

You’re already sending the confirmation email on a successful new registration; the problem here is you consider a duplicate registration to be successful as well but don’t send the email. Solutions that don’t affect other Supabase clients:

  • For a registration attempt by a known user, send an email that says “You already have an account; here is a link to login.” instead of the email confirmation message. or
  • Add a field to the result coming black to the client such as “exists: true” so that we can see this. It’s less secure for emails but at least we can retain the users being onboarded.

@hf I’m not expecting a quick fix, as @SEI-John pointed out, it has been years already. I would like Supabase to recognize that this is a business decision to be made by the developer’s company, and to commit to ANY solution that seem YOUR team deems reasonable that includes at least some level of pragmatism for this case. The bottom line is a forced horrible UX for your customers’ customers. You need to do something about that.

I’ve been a professional full-time developer since January 1984 and it seems the focus of the company is not on the ball on this one (at all). The staunch defense of the status quo has shaken my faith in Supabase, even though I have been a huge fan for years and want to keep using it.

In case this helps anyone, we don’t verify emails in our dev/staging environment but we do verify emails in production. Due to this, we have a signUp function that looks like:

export const signUp = async (email: string, password: string) => {
  const { data, error } = await supabase.auth.signUp({
    email,
    password,
  });

  // in staging, we don't verify primary emails
  // Supabase returns a nice error
  if (error?.message === "User already registered")
    return { data, error: "Please sign in with your existing account" };

  if (error) {
    logger(error.message, "error");
    throw new Error(error.message);
  }

  // in production, we verify primary emails
  // supabase returns a user object with no identities if the user exists
  if (data?.user?.identities?.length === 0) {
    return { data, error: "Please sign in with your existing account" };
  }

  return { data, error };
};

Complete protection against user enumeration seems hard to achieve with email-based logins. This is why I consider username-based logins to be an easy and practical solution to this problem. It’d be much simpler to ask users to choose a username/login that doesn’t identify them, than to ask them to create an anonymous email/phone number and come back and use this “anonymous” email.

Users would still need to provide their emails/SMS upon registration(to support OTP, magic links, etc…) but it’d only ask for the username upon signing in. Yes, this means that supabase would still need to have some mechanism to prevent leakage of the existence of an email if the system is to have a functionality like “Forget username? send it to email…” but I imagine that protection against such a leakage would be easy to implement by always responding in a constant time.

I noticed that someone asked for this feature https://github.com/supabase/gotrue/issues/903 a while ago but it was closed. I think the supabase team should reconsider this feature.

Privacy is a superhigh priority and should always be approached with an opt-out model rather than an opt-in model.

It makes sense to maintain privacy, but it doesn’t make sense not to email existing users.

Let’s assume that my user registered with Github.

If he loses access to github or wants to create a password, he will be waiting for the email forever and will think that not receiving it is an error.

This is very confusing. User should be able to confirm their new form of authentication via email

It’s Jan 2025 and now 3+ years since this issue was raised. Seriously guys @ supabase answer this simple riddle for me:

  • if a user wants to use a social login to my app
  • how can I onboard them
  • if I can’t tell that they’re an existing customer
  • so I am forced to make them go through my extra onboarding screens again?

Unbelievable.

@itsmartinhi It has been years now. Ant said some things here that I quoted but years later they are still 0 for 3 on those. I was 100% into Supabase until this issue, so it is one of the biggest disappointments in my 40-year professional career. Neither Firebase nor AppWrite have behavior like this, and are much more responsive to developers. Hint: I switched to AppWrite over this issue and it’s very similar but much more predictable, usable, and feature-rich.

I’m not sure if this is the best approach, but this works well enough for me. I have an SQL function that checks if the user’s email exists, which I call with RPC from my server action before the user is signed up.

That’s the way! Are there any security or performance concerns?

For this issue i ended up creating a rpc function that verifies if the email exist into auth.users table.

CREATE OR REPLACE FUNCTION public.check_user_existence(user_email text)
 RETURNS TABLE(
  email_exist boolean
 )
 SECURITY DEFINER
 LANGUAGE sql AS
$func$

SELECT 
  EXISTS( 
  SELECT 1
  FROM auth.users
  WHERE email = user_email
  ) as email_exist
$func$;

@Klustre What suggested solution are you referring to? (The .length “workaround” only works for some providers and isn’t a general solution.) Do you mean for all developers to write a server-side function to use the Admin API to provide a new endpoint that does what registration should, and exposes the existence test anyway?

The solution suggested in the quote of my post.

For the record, the title is wrong here, there is no security issue if Supabase just emailed the user to login if they attempt to register a second time.

I very much agree with this and I’ll personally see what can be done on this point.

@hf I regularly get users that forgot that they signed up already and then wonder why they didn’t receive a confirmation email after signing up again. The quoted solution above seems to be the best, considering the concerns. This issue is close to 3 years old and since you mentioned it comes up monthly I’d expect it to be a priority.

Is there some problem with just sending them that email that I’m overlooking? It just needs to inform them of their account status (they already had one) and include a link to the login page.

Yes, there is. You’re concerned only about your project and your user’s experience, but we are concerned about all of Supabase customers and users’ experience.

I can’t just add a new email template on a whim. One of our product tenets is that Supabase Auth should be invisible. Once you set it up, you don’t need to think about it ever again. Adding a new email template without making it conditional on some configuration option breaks that tenet, and also the promise to our developers that once you set it up one way it will continue to work that way until the end of time. The reason why this is a “breaking change” is that email templates are customizable. Say we’ve got a customer that has a Spanish-speaking user base and the email templates are all in Spanish. I can’t just force a default English template on them.

So yes now you can say, OK but let’s add a configuration option for this. And that’s probably the only viable alternative at this point, but we also don’t want developing with Supabase Auth to turn into a hundred atomic decisions that we then can’t remove or restructure.

Secondly, there’s the problem with cost. We can’t just start sending more emails without asking for approval from customers. It’s them who are paying for email sending so just randomly sending out more emails on every duplicate sign up is irresponsible for us to impose on everyone. We need to consult customers, but also don’t want to bother them about Auth at all.

Third and final, let’s say we go with this “fix” of adding a new email template or something similar, there’s a config option you turn on, and so on. Who cares about the end user? How do we prevent them from being constantly spammed by attackers, bots, script kiddies, etc? Sending an email on each signUp can have serious consequences – worrying the user too much that someone’s trying to get in their account, causing too many similar emails to be received by say Gmail can decrease the reputation of the sending domain making your emails less reliable long-term.

I understand your frustration, and I would be frustrated too. We are trying to do good here for everyone, and this is just going to take more time. I hope I’ve illustrated how a seemingly simple and “no-brainer” feature request turns into a product decision nightmare at scale.

There exists a workaround with the admin API which you can use to go around this problem should it matter to you for the time being. Please let us know if there’s any additional admin API we can provide to make this workaround easier.

I will personally try to see if there’s a sufficiently easy way to do this email sending approach, which feels right but requires more serious work, research and strategy to pull off. I can’t comment when this will land, in what way, shape or form. When we have updates, we’ll share those here.

For the record, the title is wrong here, there is no security issue if Supabase just emailed the user to login if they attempt to register a second time.

I very much agree with this and I’ll personally see what can be done on this point.

Adding to the complexity, when email confirmation is enabled, using a service won’t throw an error for an existing confirmed email. However, if you self-host supabase manually or via CLI, it will throw an error stating 'User already registered".

It’s been more than two years 👀. It happens all the time that users forget that they registered before…

You can use this method until Supabase solves this problem

        const {error, data} = await supabase.auth.signUp({email, password})
        if(data?.user?.identities?.length === 0){
              alert("This user already exists")
         }

This method only works for accounts which have been registered with OAuth. Accounts that have been registered with password and email still returns identity for invalid users. (At least on Flutter)

Must be something with the Flutter version of the lib, or something else wrong on your end. Works great for me in JS (email/password auth). I’m guessing we’re relying on an undocumented, implementation detail for it to work that way, but what can ya do…

You can use this method until Supabase solves this problem

        const {error, data} = await supabase.auth.signUp({email, password})
        if(data?.user?.identities?.length === 0){
              alert("This user already exists")
         }

This method only works for accounts which have been registered with OAuth. Accounts that have been registered with password and email still returns identity for invalid users. (At least on Flutter)

@awalias Any updates on this issue? The UX is very poor without a way of letting them know that they already have an account. And if I have to pre-vet the user, then that’s a poor DX.

Hey no updates on this yet. I understand the pain the community and customers are feeling with this, but we do require some more time to figure out how to properly approach this. We can’t keep flipping between “more secure” and “less secure” messages.

From https://github.com/supabase/supabase/blob/f8682bbb095d728ee19a581170a5d972a39543e4/apps/reference/docs/guides/auth/auth-security.mdx#user-information

“information about whether an account exists in the system can leak even if the application returns an ambigouous message such as “If you have an account an email has been sent.” This is because the final part of the request handling will need to send out an email message or SMS using a third-party system. This makes requests naturally last longer when an account exists.”

I don’t understand this- couldn’t this email or SMS process happen asynchronously so that you can return the response immediately in all cases?

Adding the “send message” instruction to the asynchronous queue is a branch that can fairly easily be detected too. (This is because a non-existing user will never reach that branch making slight timing differences apparent with not-so-sophisticated statistical methods.)

Masking this sort of stuff is never really going to work well and consistently, and there will always be some edge case that can’t be masked for maintainability, performance or cost reasons. This is why our thinking is moving in the direction of having a message that explains what the user’s doing wrong instead of trying to mask it.

But as I mentioned, we need a bit more time to figure out how to support both types of use cases. Expect some progress for this in the next couple of months.

Alternatively, your proposed fix of sending it whether there is an account or not means it will always take the same (long) time.

This is true, but as explained above it’s practically impossible to mask this.

@awalias Any updates on this issue? The UX is very poor without a way of letting them know that they already have an account. And if I have to pre-vet the user, then that’s a poor DX.

From https://github.com/supabase/supabase/blob/f8682bbb095d728ee19a581170a5d972a39543e4/apps/reference/docs/guides/auth/auth-security.mdx#user-information

“information about whether an account exists in the system can leak even if the application returns an ambigouous message such as “If you have an account an email has been sent.” This is because the final part of the request handling will need to send out an email message or SMS using a third-party system. This makes requests naturally last longer when an account exists.”

I don’t understand this- couldn’t this email or SMS process happen asynchronously so that you can return the response immediately in all cases?

Alternatively, your proposed fix of sending it whether there is an account or not means it will always take the same (long) time.

Is there any update to this? We need a clear solution for letting users know if they’ve already signed up, like how @awalias mentioned. I can see many users getting stuck and waiting for a sign up email that will never come.