Live data from Hacker News

Emailing a one-time code is worse than passwords

blog.danielh.cc

541–550 of 816 posts

Re: Emailing a one-time code is worse than passwords

#541

The attack pattern is: 1) User goes to BAD website and signs up. 2) BAD website says “We’ve sent you an email, please enter the 6-digit code! The email will come from GOOD, as they are our sign-in partner.” 3) BAD’s bots start a “Sign in with email one-time code” flow on the GOOD website using the user’s email. 4) GOOD sends a one-time login code email to the user’s email address. 5) The user is very likely to trust…

I work on a product that emails administrators with a list of actions they can take related to certain authorization requests. We got feedback from a customer that all requests were simultaneously approved then denied. It turns out their Microsoft provided email server follows all links and runs all javascript before showing it to the user

Re: Emailing a one-time code is worse than passwords

#542
post #414
post #279

I get the point. However, from my own experience this type of one-time passcode is unfortunately the 2nd well-understood authentication method for non-tech people surrounding me. The 1st is the password, of course. I don't know the general situation, but, at least in our small town, people would go to the phone service shop just for account setup and recovery, since it's just too complicated. Password managers and pa…

just stick with passwords then

I guess the problem is such people will mostly use passwords that are as weak as they can get away with.

Re: Emailing a one-time code is worse than passwords

#543
post #414
post #279

I get the point. However, from my own experience this type of one-time passcode is unfortunately the 2nd well-understood authentication method for non-tech people surrounding me. The 1st is the password, of course. I don't know the general situation, but, at least in our small town, people would go to the phone service shop just for account setup and recovery, since it's just too complicated. Password managers and pa…

just stick with passwords then

Good luck finding a suite of modern, convenient services that will allow you to do that nowadays. I wish we could opt-in with some sort of I-know-what-I'm-doing-with-passwords-and-take-full-responsibility option.

Re: Emailing a one-time code is worse than passwords

#544

Earlier quoted context omitted.

That's such a strawman argument. Read the link you pasted again

Strawman? We are talking about this link, right, the one that says: > I've already heard rumblings that KeepassXC is likely to be featured in a few industry presentations that highlight security challenges with passkey providers, the need for functional and security certification, and the lack of identifying passkey provider attestation (which would allow RPs to block you, and something that I have previously rallied…

Yes, read the quotes you took again. Attestation is not a thing currently. There is legitimate discussion about how to handle shitty password managers. If LastPass shits the bed again, it would be great to have a mechanism for others to block it or at least know that due to a major incident, keys from that tool are week. Debian OpenSSL keys were vulnerable for a long time and being able to know and alert or block private keys generated on a Debian machine is reasonable if not desirable. If KeepassXC is insecure or promote insecure practices who's fault is that and what do you suggest we do?

The entire issue is about doing the minimum possible of not exporting it in plaintext. Nothing is stopping you from decrypting it and posting it on your Twitter if you so wish. Just don't have the password manager encourage bad practices. How it that unreasonable?

Re: Emailing a one-time code is worse than passwords

#545
From a design perspective, the reason this flaw exists is because the code can be typed on any machine and sent through any intermediary. More secure schemes are possible without much effort. Magic links have some pros/cons but overall I think they are better.

Here is what I do when the user logs in and email verification is needed:

1. Generate a UUID on the server.

2. Save the UUID on the client using the Set-Cookie response header.

- The cookie value is symmetrically encrypted and authenticated via HMAC or AES-GCM by the server before it is set, such that it can only be decrypted by the server, and only if the cookie value has not been tampered with. This is very easy to do in hapi.js and any other framework that has encrypted cookies.

- Use all the tricks to safeguard the cookie from being intercepted and cloned. For example, use a name with the __Host- prefix and these attributes: Secure; HttpOnly; SameSite=Lax;

3. The server sends an email to the user with a link like https://site.com/verify?code=1234, where 1234 is the UUID.

4. The user clicks the link and has their email verified.

- When the link is clicked, the browser sends the Cookie header automatically, the server decrypts it and compares it to the UUID in the URL and if that succeeds, the email has been verified. Again, this is very easy in hapi.js, as it handles the decryption step.

- Including the UUID in the magic link signals that there is _supposed_ to be a cookie present, so if the cookie is missing or it doesn't match, we can alert the user. It also proves knowledge of the email, since only the email has access to the UUID in unencrypted form.

5. The server unsets the cookie, by responding with a Set-Cookie header that marks it as expired.

6. The server begins a session and logs the user in, either on the page that was opened via the link or the original page that triggered the verification flow (whichever you think is less likely to be an attacker, probably the former).

Note that there are some tradeoffs here. The upside is that the user doesn't need to remember or type anything, making it harder to make mistakes or be taken advantage of. The downside is that the friction of having to use the same device for email and login may be a problem in some situations. Also, some email software may open a different browser when the link is clicked, which will cause the cookie to be missing. I handle this by detecting the missing cookie and showing a message suggesting the user may need to copy-paste the link to their already open browser, which will work even if they open a new tab to do it (except for incognito mode, where some browsers use a per-tab cookie jar).

Lastly, no cookie is 100% safe from being stolen and cloned. For example, a social engineering attack could involve tricking the user into sharing their link and Set-Cookie header. But we've made it much more difficult. They need two pieces of information, each of which generally can't be intercepted, or used even if intercepted, by intermediary sites.

Re: Emailing a one-time code is worse than passwords

#546
post #502

Earlier quoted context omitted.

>"I’d rather granny needs to visit the bank to get access to her account again, than someone phishes her and steals all her money." More like abuelita gets robbed at gunpoint and made to unlock and clear out her bank account, then has no recourse at home because her device was taken. I live in a third world country and even 2FA simply isn't viable for me due to how frequent phone robberies are. I've had to do the pro…

A key part of the recent push for passkeys has been cross device syncing with your Google / Apple / whatever password manager account, so you end up in the same situation: if you can log in to Bitwarden to access your passwords, you can log in to your password manager to access your passkeys.

Did people not realize they can save their 2fa token and just use that with a new authenticator?

I haven't used a phone 2fa forever, but it was a much better system than this "email me a code" BS.

Re: Emailing a one-time code is worse than passwords

#547

Earlier quoted context omitted.

The website is abc.com the link in the email is abc.com

The link in the email is a mailchimp wrapped tracking link with a gibberish URL. What now

Or the email is rendered HTML, where the expected URL is used as the text for an anchor whose href is the malicious site.

Re: Emailing a one-time code is worse than passwords

#548
post #466

Earlier quoted context omitted.

>"I’d rather granny needs to visit the bank to get access to her account again, than someone phishes her and steals all her money." More like abuelita gets robbed at gunpoint and made to unlock and clear out her bank account, then has no recourse at home because her device was taken. I live in a third world country and even 2FA simply isn't viable for me due to how frequent phone robberies are. I've had to do the pro…

FYI, you can put a 2FA secret into Bitwarden and autofill the one-time passwords alongside the regular password. That would mitigate the impact of losing your phone.

FYI you can go `oathtool --totp -b "that secret code"` and never need a third party vendor again

Re: Emailing a one-time code is worse than passwords

#549

Earlier quoted context omitted.

> Wouldn't that be incredibly insecure? If done naively with a simple magic link, yes. > and if the user happens to click the link they've just given the attacker access to their account Worse: if the user's UA “clicks the link” by making the GET request to generate a preview. The user might not even have opened the message for this to happen. > Wouldn't that be incredibly insecure? It can be mitigated somewhat by ma…

> Worse: if the user's UA “clicks the link” by making the GET request to generate a preview. You mean something like a popover preview that appears when the user hovers over a link? Isn’t there a way to configure the `a` element so the UA knows that it shouldn’t do that?

> You mean something like a popover preview

That, or a background process that visits links to check for malware before the user even sees the message.

> Isn’t there a way to configure the `a` element so the UA knows that it shouldn’t do that?

If sending just HTML you could include rel="nofollow" in the a tag to discourage such things, bit there is no way of enforcing that and no way of including it at all if you are sending plain text messages. This has been a problem for single-use links of various types also. So yes, but not reliably so effectively no.

Re: Emailing a one-time code is worse than passwords

#550

Earlier quoted context omitted.

I would counter argue being the person pushing passkeys in an enterprise: noone in the business knows what attestation is, but we're going to do it because the interface recommends it.

I'm not sure it's the standards committee's fault that your employer hires people that don't know how to do their job. I think it's reasonable to have attestation for the corporate use case. If they're buying security devices from a certain vendor, it's reasonable for their server to check that the person pretending to be you at the other end is using one of those devices. It's an extra bit of confidence that you're…

It's the standards committees job to design standards that are difficult to misuse.
Post reply on HN