[GH-ISSUE #4274] Add device binding option to magic link to make it phishing resistant #18514

Closed
opened 2026-04-15 17:00:43 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @mcm-ham on GitHub (Aug 27, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/4274

Is this suited for github?

  • Yes, this is suited for github

No response

Describe the solution you'd like

I would like to make the magic link authentication token device-bound to prevent token hijacking / phishing. The core idea is to ensure that the token can only be successfully redeemed from the same device or browser that requested it.

Here are some different approaches I've read when researching this:

Method Phishing Resistance How it Works
IP Address Binding Weak The token is tied to the requesting device's IP address. This is easy for an attacker to spoof.
User-Agent Binding Weak The token is tied to the browser's user-agent string. This is easily spoofed.
Device Fingerprinting Strong The most effective method. The token is cryptographically bound to a unique, multi-attribute fingerprint of the user's browser or device. If an attacker tries to use the token from their own device, the fingerprint mismatch will prevent the login.
Cookie-Based Binding Strong A temporary, cryptographically-signed cookie is set on the user's browser. The token can only be redeemed if the request is accompanied by this specific cookie.

Device fingerprinting uses a script on the client side to gather various data points. These include details like screen resolution, installed fonts, browser and operating system information, time zone, and a unique canvas rendering of a test image. While effective, this method has limitations. It can raise privacy concerns for some users because of the extensive data collection. Additionally, it is not foolproof, as some privacy-focused browser extensions and features like Private Mode can actively randomize or block the data, potentially causing a login to fail.

Downside to cookie is it only works on the same browser so if magic link opens another app it doesn't work.

Describe alternatives you've considered

Can't think of any.

Additional context

No response

Originally created by @mcm-ham on GitHub (Aug 27, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/4274 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. _No response_ ### Describe the solution you'd like I would like to make the magic link authentication token device-bound to prevent token hijacking / phishing. The core idea is to ensure that the token can only be successfully redeemed from the same device or browser that requested it. Here are some different approaches I've read when researching this: Method | Phishing Resistance | How it Works --- | --- | --- IP Address Binding | Weak | The token is tied to the requesting device's IP address. This is easy for an attacker to spoof. User-Agent Binding | Weak | The token is tied to the browser's user-agent string. This is easily spoofed. Device Fingerprinting | Strong | The most effective method. The token is cryptographically bound to a unique, multi-attribute fingerprint of the user's browser or device. If an attacker tries to use the token from their own device, the fingerprint mismatch will prevent the login. Cookie-Based Binding | Strong | A temporary, cryptographically-signed cookie is set on the user's browser. The token can only be redeemed if the request is accompanied by this specific cookie. Device fingerprinting uses a script on the client side to gather various data points. These include details like screen resolution, installed fonts, browser and operating system information, time zone, and a unique canvas rendering of a test image. While effective, this method has limitations. It can raise privacy concerns for some users because of the extensive data collection. Additionally, it is not foolproof, as some privacy-focused browser extensions and features like Private Mode can actively randomize or block the data, potentially causing a login to fail. Downside to cookie is it only works on the same browser so if magic link opens another app it doesn't work. ### Describe alternatives you've considered Can't think of any. ### Additional context _No response_
GiteaMirror added the lockedenhancement labels 2026-04-15 17:00:43 -05:00
Author
Owner

@himself65 commented on GitHub (Aug 27, 2025):

feel free to open a PR

<!-- gh-comment-id:3229919696 --> @himself65 commented on GitHub (Aug 27, 2025): feel free to open a PR
Author
Owner

@dosubot[bot] commented on GitHub (Nov 26, 2025):

Hi, @mcm-ham. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You proposed adding device binding to magic link authentication to improve security by limiting token redemption to the requesting device.
  • Suggested approaches included device fingerprinting or using cookies, acknowledging privacy and browser limitations.
  • The maintainer, himself65, responded positively and encouraged you to submit a pull request to implement this feature.
  • There has been no further activity or updates on this issue since that response.

Next Steps:

  • Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue.
  • If I do not hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

<!-- gh-comment-id:3582087896 --> @dosubot[bot] commented on GitHub (Nov 26, 2025): Hi, @mcm-ham. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You proposed adding device binding to magic link authentication to improve security by limiting token redemption to the requesting device. - Suggested approaches included device fingerprinting or using cookies, acknowledging privacy and browser limitations. - The maintainer, himself65, responded positively and encouraged you to submit a pull request to implement this feature. - There has been no further activity or updates on this issue since that response. **Next Steps:** - Please let me know if this feature is still relevant to the latest version of better-auth by commenting on this issue. - If I do not hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Author
Owner

@mcm-ham commented on GitHub (Dec 3, 2025):

This issue is still relevant.

<!-- gh-comment-id:3608655948 --> @mcm-ham commented on GitHub (Dec 3, 2025): This issue is still relevant.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 3, 2025):

@Bekacru The user mcm-ham has indicated that this issue is still relevant despite being marked stale and closed. Could you please take a look and assist?

<!-- gh-comment-id:3608663293 --> @dosubot[bot] commented on GitHub (Dec 3, 2025): @Bekacru The user mcm-ham has indicated that this issue is still relevant despite being marked stale and closed. Could you please take a look and assist?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18514