19 November 2026 · 12 min read · BlitzHash · Cloud, DevOps & Security

Account takeover protection for an AI-built app: 9 attacks we tested

Short answer: account takeover protection for an AI-built app comes down to four things your code has to do on purpose. Reset links must be random, short-lived and single-use. Every old session must die when a password changes. Email changes must ask for the password again and warn the old address. And admin accounts need a second factor. On Nov 19, 2026 we ran 9 takeover attacks against a small demo app built two ways. The naive build lost on all 9. The hardened build, with the same features, blocked all 9. If you want this test run against your own app before customers arrive, it's part of our Launch-Ready Check. For a quick first look on your own, start with the free self-check.

This guide is for founders who built their login with Lovable, Bolt, Cursor, Replit or v0 and now have real people signing up. You don't need to read code to use it. You need to know which questions to ask your app, and what a good answer looks like.

Why account takeover is the attack that hurts most

Most founders picture a hacker "breaking in" to the database. In practice, many incidents start with one account. Someone reuses a password that leaked from another site. Someone forwards an old email that still has a working reset link. Someone logs in on a shared laptop and never logs out. The attacker doesn't need to break your app. They only need your app to trust them as somebody else.

Once they're in, they see what that user sees: orders, messages, invoices, saved cards, team data. If the account is an admin, they see everyone's. And if your app lets them change the account email, the real owner can't even reset the password anymore, because the reset link now goes to the attacker.

AI coding tools are good at making a login screen that works. "Works" means a real user can sign up, sign in and reset a password. It doesn't mean the flow holds up when someone is actively trying to misuse it. Those are different tests, and only the first one shows up when you click around your own app.

Our test: one demo app, built two ways

We wrote a small Node.js app with the account features most AI-built apps ship with: sign in, forgot password, change password, change email, and an admin role. It keeps everything in memory and "sends" emails to an outbox we can read, so nothing touched a real inbox or a real user. Two accounts exist: Alice (a normal user) and an admin.

  • Naive build. This is the version you get when you ask for "a login with password reset" and accept the first thing that works. Error messages say whether an email exists. The reset link is built from the request's Host header. The reset token is the email plus a timestamp, encoded. Tokens never expire and can be reused. Changing or resetting a password leaves other sessions alive. Changing the account email needs no password. The admin signs in with a password only.
  • Hardened build. Same features, same screens. The differences are all in a few dozen lines of server code: one generic error message, a fixed app URL for links, a 32-byte random token stored as a hash, a 30-minute expiry, single use, all sessions revoked on any password change or reset, the current password required for email changes plus a notice to the old address, and an authenticator-app code (TOTP) required for the admin.

Then we played the attacker with 9 probes. Each probe is something that happens in real life, not a lab trick.

Account takeover protection for an AI-built app: the 9 attacks and what happened

Here's the result, probe by probe. "Naive" and "Hardened" are the two builds of the same app.

1. "Which emails have accounts here?"

An attacker with a list of leaked emails first wants to know which ones are your users.

  • Naive: login for an unknown email said "No account with that email" (404). For Alice it said "Wrong password" (401). The forgot-password form did the same thing: 404 for strangers, "Reset link sent" for Alice. That's a free list of your customers.
  • Hardened: every login failure said "Invalid email or password". Every reset request said "If that email has an account, a reset link is on its way". No difference to learn from.

One honest caveat: our hardened build still answered faster for unknown emails, because it skips the password check. OWASP's Forgot Password Cheat Sheet asks for consistent response *timing* too, not just consistent wording. We didn't fix or measure that here, so treat it as a follow-up item in your own app.

The attacker submits Alice's email on the forgot-password form, but sends the request with a fake Host header of attacker.example.

  • Naive: the email Alice received said https://attacker.example/reset?token=.... If she clicks it, her valid token goes to the attacker's server, and they reset her password.
  • Hardened: the link always said https://app.example/reset?token=..., because the base URL comes from a setting, not from the request.

OWASP calls this out directly: don't build reset URLs from the Host header; hard-code the URL or check it against a list of trusted domains. If you use Supabase Auth, the equivalent setting is your Site URL and the Redirect URLs allow list. Supabase's docs say the Site URL is "critical for email confirmations and password resets" and recommend an exact production URL rather than a broad wildcard.

3. Forging a reset token without the email

  • Naive: the token was just the email and the current time, encoded. We rebuilt it by trying 11 timestamps around "now" and reset Alice's password without ever seeing her inbox.
  • Hardened: 11 time-based guesses and 1,000 random tokens were all rejected. The real token is 32 random bytes from a secure generator, and the server only stores its hash.

You can't see this one from the outside, which is why it's dangerous. Ask your AI tool, or whoever reviews your code, one question: "How is the reset token generated, and where is it stored?" The answer should mention a cryptographically secure random generator and a database row, not a timestamp, a user ID or a JWT nobody checks.

Alice requested a reset, didn't use it, and forgot about it. A month later someone gets into her old inbox or finds the forwarded email.

  • Naive: the link still worked: 200, "Password updated".
  • Hardened: 400, "Link expired or already used". The same link worked fine at 29 minutes in our sanity check, so real users aren't punished.
  • Naive: Alice used her link, then the same link reset the password again a minute later. Anyone who saw that email later could take the account.
  • Hardened: the second use was refused. After a successful reset, every outstanding reset link for that account is marked used.

6. A stolen session after Alice changes her password

The attacker has a session from a shared computer or a stolen cookie. Alice gets suspicious and changes her password.

  • Naive: the attacker's old session still loaded Alice's account. Changing the password did nothing to them.
  • Hardened: the old session returned 401, "Not signed in". Alice's current session stayed signed in.

7. A stolen session after Alice resets her password

Same setup, but Alice uses "forgot password" instead.

  • Naive: the attacker stayed signed in.
  • Hardened: every session for the account was revoked when the reset went through.

This is the one founders are most surprised by. "I reset my password" feels like "I kicked everyone out". It only does that if your code does it. OWASP's guidance is to invalidate existing sessions after a reset, and in recovery from a suspected compromise, to invalidate outstanding reset links too.

If your app uses Supabase Auth, read the signOut docs closely. The global scope invalidates all of a user's sessions and others keeps the current one. The same page also says an access token (JWT) that's already been issued can't be revoked until it expires, and recommends a shorter expiry for that reason. So "revoke sessions" stops refreshes, while a short JWT lifetime limits how long an already-issued token keeps working. Firebase has the same idea with revoking refresh tokens for a user.

8. A stolen session changes the account email

This is how a short visit becomes a permanent takeover.

  • Naive: with only the stolen session, the attacker changed the email to attacker@evil.example. No password asked, nothing sent to Alice. From then on, "forgot password" helps the attacker, not Alice.
  • Hardened: 401, "Re-enter your password to change your email". When the owner does change it, the old address gets a notice with a way to report that it wasn't them.

Supabase documents a "Secure email change" setting that, when on, sends a confirmation link to both the current and the new address. Settings and defaults move over time, so don't trust the docs alone. Test it with two real inboxes you control (see the checklist below).

9. The admin password leaks

The admin reused a password that appears in some other site's breach.

  • Naive: password only, so a session was issued. The attacker now has the admin panel.
  • Hardened: "Enter the 6-digit code from your authenticator app". With a valid code from the real authenticator, the admin got in normally.

Supabase Auth supports authenticator-app MFA and exposes the assurance level (aal1 or aal2) in the user's token, so you can require aal2 for admin pages and even in database policies. Clerk, Auth0 and Firebase all offer MFA too. You don't need to force MFA on every customer on day one, but every account that can see other people's data should have it.

The final score

  • Naive build: the attacker succeeded on 9 of 9 probes.
  • Hardened build: the attacker succeeded on 0 of 9 probes.

Both builds look the same in the browser. Sign-up works, sign-in works, the reset email arrives. Clicking around your own app can't show you any of these differences. You have to try to misuse it.

What this test doesn't cover: password guessing (we tested login lockout in our Cloudflare WAF exploit test), social sign-in, phishing pages, or one user reading another user's data through the database, which is a separate question covered in our two-account test. It's a demo app, not your app. Your stack may already do some of this for you, and your code may undo it.

The 15-minute account takeover check you can run yourself

You need two email inboxes you control, two browsers (or a normal and a private window) and your live app. Don't run this against anyone else's account or app.

Step 1: account enumeration

  • ☐ Try to sign in with an email that has no account. Then with a real account and a wrong password. The messages should be identical.
  • ☐ Request a password reset for both. The on-screen message should be identical.
  • ☐ Request a reset. Check the link in the email: is it your real domain, over https?
  • ☐ Use the link. Then click the same link again. The second time should fail.
  • ☐ Request a reset, wait past your stated expiry (or the next day), then click it. It should fail.
  • ☐ Request two resets in a row and use the second. The first link should no longer work.
  • ☐ Ask your developer or AI tool: "How is the reset token generated and stored?" Look for a secure random generator and a stored hash or a managed auth provider.

Step 3: sessions

  • ☐ Sign in as the same user in browser A and browser B.
  • ☐ In browser A, change the password. Refresh browser B. It should be signed out, right away or within your token lifetime.
  • ☐ Repeat with "forgot password" instead of change password.
  • ☐ Check that "sign out of all devices" exists somewhere a user can find it.

Step 4: email changes

  • ☐ While signed in, try to change the account email. Does it ask for your current password, or confirm from both inboxes?
  • ☐ Does the old inbox get a notice that the email changed?

Step 5: admins and staff

  • ☐ Every admin, staff or support account has an authenticator-app second factor turned on.
  • ☐ Admin-only pages and data check for the second factor on the server, not just in the menu.
  • ☐ Reset emails, password changes and email changes are written to a log you can read later.

If any box stays empty, that's your fix list. Most items are small changes once you know they're missing. For a broader scan of auth and session code in your repo, our open-source blitzhash-security-review flags common problems like routes that change data with no auth check and session cookies without httpOnly.

How to ask your AI tool to fix it

If you build with Lovable, Bolt, Cursor, Replit or v0, paste a prompt like this, then re-run the checklist. Don't trust the tool's "done" message on its own.

Harden account recovery and sessions in this app:
1. Login and forgot-password must return the same message whether or not the email exists.
2. Build password reset links from a fixed APP_URL setting, never from the request Host header.
3. Reset tokens: cryptographically random, at least 32 bytes, stored only as a hash, expire after 30 minutes, single use; using one invalidates all other reset tokens for that user.
4. On password change or reset, revoke every other session for that user.
5. Changing the account email requires the current password and sends a notice to the old email.
6. Admin and staff accounts require an authenticator-app (TOTP) second factor, checked on the server.
Show me the exact files you changed and how to test each item.

If you're on Supabase Auth, Clerk, Auth0 or Firebase, a lot of this is a setting rather than code. Ask the tool to point to the setting it relied on, then still run the test.

FAQ

Does using Supabase Auth or Clerk mean I'm already protected from account takeover?

Partly. Managed auth providers generate reset tokens safely and offer MFA, session revocation and secure email change. But your app decides whether to call session revocation after a password change, which redirect URLs are allowed, how long tokens live, and whether admin pages actually require the second factor. Run the checklist on your live app either way.

Should I force MFA on all my users?

Not always. For a consumer app it can cost signups. Make it available to everyone and required for anyone who can see other people's data: admins, staff, support and team owners.

Short. OWASP says reset tokens should expire "after an appropriate period" and be single use. We used 30 minutes in our test. Pick a window that fits your users, and make sure it actually expires.

What should I do if I think an account was already taken over?

Lock the account, revoke all its sessions and outstanding reset links, and check whether the email, phone or MFA settings were changed recently. OWASP warns not to trust recovery details the attacker may have added. Restore access through details that existed before the incident, and tell the owner through their original address.

Want us to test your login before customers do?

Account takeover is one of the checks in our Launch-Ready Check. We run tests like these against your live app, read your auth and session code, and give you a plain-English fix list. If you're not sure where to start, take the free self-check first or book a free technical assessment. And if you'd rather watch the story than read it, our Stack Stories episode on how every login evolves after the first account takeover covers the same never-expiring reset link problem in under two minutes.

Sources

Related posts

Next step

Book a free 15-min launch review.

A short video call. We look at your AI-built app, flag the biggest risks in security, launch readiness, speed and cost, and you leave with next steps. No obligation.

Every price is a custom quote after we look at the app. No work starts until you accept the proposal.