News for hackers. Stuff that matters.
Re:Magic/tragic email links: don't make them the only option by ctm92 on Wednesday January 08, 2025 @02:03AM (#42631784)
These days there's also to consider that some Mail Threat Protection Tools (at least Microsoft Defender in Exchange Online does this) click links in Mails to check them.

Recently ran into this issue as new mail accounts got confirmed automatically and magic links were invalid when the user clicked them, because Microsoft already logged in with it during checking.

Re:Magic/tragic email links: don't make them the only option by aspect0545 on Wednesday January 08, 2025 @03:13AM (#42632150)
What can you do to prevent automatic confirmation in that case?
Re:Magic/tragic email links: don't make them the only option by mixedbit on Wednesday January 08, 2025 @03:53AM (#42632337)
I run an authorization service that allows to log-in using magic links and we managed to solve this. First approach was for the link opening GET request to do not log the user in, but to include an HTML page with JavaScript that issued a POST request with a code from the link to log the user in. This worked well for a long time, because email scanners were fetching links from emails with GET requests but did not execute JavaScript on the fetched pages. Unfortunately, some time ago Microsoft tools indeed started to render the fetched pages and execute JavaScript on them which broke the links. What works now is to check if the link is open in the same browser that requested the link (you can use a cookie to do it) and only automatically login the user in these cases. If a link is open in a different browser, show an additional button ('Login as <email address>') that the user needs to click to finish the login action. MS tools render the login page but do not click buttons on it.

The issue that MS tools introduced is broader, because it affects also email confirmation flows during signups. This is less visible, because usually the scanners will confirm emails that the user would like to confirm anyway. But without additional protection steps, the users can be signed up for services that they didn't request and MS tools will automatically confirm such signups.

Re:Magic/tragic email links: don't make them the only option by szszrk on Wednesday January 08, 2025 @05:00AM (#42632640)
> check if the link is open in the same browser that requested the link (you can use a cookie to do it) and only automatically login the user in these cases. If a link is open in a different browser, show an additional button ('Login as <email address>') that the user needs to click to finish the login action.

Thanks for checking if it's the same browser. Some companies don't care about that (cough booking cough) so harmful actors just spam users with login attempts in hope a user will click by accident. And puff, random guy gets full access to your account. I got those every day, if I ever needed to login this way I would not be able to figure out which request is mine.

Re:Magic/tragic email links: don't make them the only option by vanviegen on Wednesday January 08, 2025 @08:45AM (#42634124)
Wouldn't that just log you in on the browser doing the clicking, instead of the attackers browser?
Re:Magic/tragic email links: don't make them the only option by szszrk on Wednesday January 08, 2025 @01:11PM (#42636833)
You mean in the booking example? They logged in the browser that... requested access. So basically anyone that knew your login/email.

I think it should check if browser requesting is the same as the one confirming, or just drop that whole dumb mechanism entirely.

Re:Magic/tragic email links: don't make them the only option by keskival on Wednesday January 08, 2025 @05:13AM (#42632722)
Ok, what if an email has "click this link if it was you who tried to log-in", or "if it wasn't you"?

Will Microsoft automatically authenticate malicious actors, or block yourself from services built with assumptions that the email client won't auto-click everything?

Re:Magic/tragic email links: don't make them the only option by mixedbit on Wednesday January 08, 2025 @05:35AM (#42632827)
Login links from my service were automatically clicked and rendered and I know that other services discovered similar problems. Based on this I think that it is very likely the case with all the links in emails, but I don't know if there is any additional heuristic involved that would treat some links differently.

See also this issue which suggests that all links are opened: https://techcommunity.microsoft.com/discussions/microsoftdef...

Note that this doesn't affect all Outlook users, this Microsoft Defender for Office 365 is a separate product that only some companies use.

Re:Magic/tragic email links: don't make them the only option by pmontra on Wednesday January 08, 2025 @08:48AM (#42634157)
> But without additional protection steps, the users can be signed up for services that they didn't request and MS tools will automatically confirm such signups.

Indeed it's a bad thing but how bad?

The admins of some web service get a database of emails, send them those registration links, make their mail software create the accounts and? They end up with a service with accounts that they could create without sending those emails, before they send some emails to solicit users to perform some action on their (long forgotten?) account. There is no additional threat unless I'm missing something.

The admins have only an extra thin layer of protection because of the confirmation step but I think that any court can see through it.

Re:Magic/tragic email links: don't make them the only option by mixedbit on Wednesday January 08, 2025 @09:12AM (#42634412)
The exploitation and potential damage would be service specific. Say a Dropbox like service for computer file syncing: An attacker creates an account for '[email protected]' and gets the signup email automatically confirmed. The attacker uploads some malware files to the account. After some time Alice attempts to create a valid account and resets password for '[email protected]'. Then Alice installs a desktop file syncing client provided by the service and malware files from the attacker get downloaded to her machine.

Another example would be if a company hosted a web app for employees that allowed signups only from @company.com addresses. In such case an attacker could be able to signup with such an address.

Re:Magic/tragic email links: don't make them the only option by pmontra on Wednesday January 08, 2025 @07:07PM (#42640049)
You are right. I didn't think about 3rd parties creating accounts on a service they don't control.
Re:Magic/tragic email links: don't make them the only option by aftbit on Wednesday January 08, 2025 @11:24AM (#42635776)
It defeats the email verification entirely. If that weren't necessary for something, why would the site require it?
Re:Magic/tragic email links: don't make them the only option by ku1ik on Wednesday January 08, 2025 @01:43PM (#42637153)
That check for the same browser is a great idea. Thanks!
Re:Magic/tragic email links: don't make them the only option by saagarjha on Sunday January 12, 2025 @03:54AM (#42672191)
This can be annoying when you intentionally want to log in to a browser that is not the one making the request, such as an in-app browser.
Re:Magic/tragic email links: don't make them the only option by miohtama on Wednesday January 08, 2025 @03:36AM (#42632262)
The link leads to a page where you need to press a button (HTTP POST).
Re:Magic/tragic email links: don't make them the only option by sandermvanvliet on Wednesday January 08, 2025 @03:27AM (#42632217)
As far as I know there’s nothing.

The alternative is to send an OTP in the mail and tell the user to enter that.

In that way there is no link to auto confirm.

However, if you do that ensure that you have a way to jump straight to the page to enter the OTP because (looking at you Samsung) the account registration process can expire or the app is closed (not active long enough) and your user is stuck

Re:Magic/tragic email links: don't make them the only option by robertlagrant on Wednesday January 08, 2025 @04:55AM (#42632607)
That seems like a really thoughtless idea.
Re:Magic/tragic email links: don't make them the only option by devnullbrain on Wednesday January 08, 2025 @06:13AM (#42633031)
I've had this problem as a user, accidentally previewing a link in iOS by tapping for too long.
Re:Magic/tragic email links: don't make them the only option by tuetuopay on Wednesday January 08, 2025 @11:44AM (#42635984)
This is even worse for copying the link. On iOS the contextual menu comes with the preview, which will destroy the magic link.
Re:Magic/tragic email links: don't make them the only option by littlestymaar on Wednesday January 08, 2025 @08:14AM (#42633834)
> These days there's also to consider that some Mail Threat Protection Tools (at least Microsoft Defender in Exchange Online does this) click links in Mails to check them.

What an insane policy, why am I surprised Microsoft came up with it…

Re:Magic/tragic email links: don't make them the only option by sbarre on Wednesday January 08, 2025 @09:04AM (#42634317)
It's not actually insane if the application hosting the link follows the principle that GET requests should not mutate state.

This problem is ~20 years old from when CMS platforms had GET links in the UI to delete records and "browsing accelerator" browser extensions came along that pre-fetched links on pages, and therefore deleted resources in the background.

At the time the easiest workaround was to use Javascript to handle the link click and dynamically build a form to make a POST request instead (and update your endpoint to only act on POST requests), before the fetch API came along.

Re:Magic/tragic email links: don't make them the only option by littlestymaar on Thursday January 09, 2025 @03:07AM (#42642928)
It is insane because it brings literally nothing security-wise (an attacker can easily detect that the link is being opened from something else than an end-user's browser, and not deliver the payload) while actualy compromising the security of their users (by allowing an attacker to know which addresses exist and which do not, which is very useful if you want to attack companies).
Re:Magic/tragic email links: don't make them the only option by saagarjha on Sunday January 12, 2025 @03:54AM (#42672190)
The idea is that the pre-fetching is done by an environment that looks similar to the end-user's browser.
Re:Magic/tragic email links: don't make them the only option by ctm92 on Wednesday January 15, 2025 @08:23AM (#42710494)
It does not only show to attackers that your address exists, it also shows that it is hosted on Microsoft 365 and is ATP is licensed.
Re:Magic/tragic email links: don't make them the only option by TeMPOraL on Wednesday January 08, 2025 @08:59AM (#42634259)
Come to think of it, magic links by definition violate the principle that GET requests should not change state. Defender & preview tools are actually following the established norms here - norms that were established decades ago precisely because we hit the more broad problem with C, U & D parts of CRUD, and collectively agreed that doing destructive operations on GET requests is stupid.
Re:Magic/tragic email links: don't make them the only option by kragen on Wednesday January 08, 2025 @09:50AM (#42634817)
You can GET a <form> which POSTs when you click the "log in" button.
Re:Magic/tragic email links: don't make them the only option by GTP on Wednesday January 08, 2025 @10:35AM (#42635283)
Yes, but the GET itself isn't changing any state. The state changes only after clicking on the button. This is OP's point.
Re:Magic/tragic email links: don't make them the only option by kragen on Wednesday January 08, 2025 @11:00AM (#42635535)
TeMPOraL said, "magic links by definition violate the principle that GET requests should not change state". That is a reasonable thing to think, but it is not true, because you can GET a <form> which POSTs when you click the "log in" button, unless you think a link to such a <form> page should be excluded from the definition of "magic link".
Re:Magic/tragic email links: don't make them the only option by Jolter on Wednesday January 08, 2025 @01:14PM (#42636850)
In your example, it seems to me that the POST request is the action that changes the state.
Re:Magic/tragic email links: don't make them the only option by kragen on Wednesday January 08, 2025 @01:36PM (#42637085)
Agreed.
Re:Magic/tragic email links: don't make them the only option by TeMPOraL on Wednesday January 08, 2025 @01:23PM (#42636952)
> unless you think a link to such a <form> page should be excluded from the definition of "magic link".

Yes. Linking to a form requiring user to press a button to submit an actual POST request is one proper way of doing it, and won't confuse prefetchers, previewers and security scanners - but it lacks the specific "magic" in question, which is that clicking on a link alone is enough to log you in.

Can't really have both - the "magic" is really just violating the "GET doesn't mutate" rule, rebranding the mistake we already corrected 20+ years ago.

(EDIT: Also the whole framing of "magic links" vs. passkeys reads to me like telling people that committing sins is the wrong way of getting to hell, because you can just ask the devil directly instead.)

Re:Magic/tragic email links: don't make them the only option by kragen on Wednesday January 08, 2025 @01:37PM (#42637092)
Aha, then we agree on the facts, just disagree about nomenclature.

Your theological analogy is hilarious!

Re:Magic/tragic email links: don't make them the only option by ku1ik on Wednesday January 08, 2025 @01:37PM (#42637091)
This is the way.