Group
  • Security

    Harden my magic link login

    Makes email login links single-use, short-lived, and bound to the browser that requested them.

    • Improve quality
    • Debug & fix
    • Intermediate
    • General

Free Prompt

Audit my magic link (passwordless email) login flow for weaknesses. Look at token generation, storage, expiry, and consumption. Apply these requirements: tokens are generated with a cryptographically secure random source with enough entropy (at least 128 bits); they're single-use and expire quickly (15 minutes is standard); requesting a new link invalidates previous unused ones; the request endpoint is rate limited per email and per IP so it can't be used to spam someone's inbox; the response never reveals whether the email is registered; and where practical, the link is bound to the requesting browser (a cookie set at request time checked at consumption) so a link forwarded or intercepted elsewhere doesn't work. After successful login, issue a proper session with the same protections as password login. Do not change the user experience of the flow; keep the same emails and pages. Use the existing email sending code. Show me each gap found and the fix. Give me a verification pass: request a link, use it, confirm reuse fails; request a second link and confirm the first is dead; hammer the request endpoint and confirm rate limiting engages.

What This Does / How This Helps

Tightens every part of passwordless login: strong tokens, single use, fast expiry, resend invalidation, and rate limits on requests. A magic link is a bearer credential delivered by email, so every weakness in the flow is a direct account takeover path. Links that work twice, live forever, or pile up in the inbox (each new request leaving old ones valid) widen the window for interception. And an unthrottled request endpoint lets anyone flood a victim's inbox with your emails. The verification pass exercises the whole lifecycle, including the checks people forget: old links dying when new ones are requested, and request rate limiting.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts