Demo login, auto-login or hard-coded test credentials left in your live app
Published
Weakness type: CWE-798 (Use of Hard-coded Credentials), CWE-489 (Active Debug Code)
The error
Anyone can open my live app and is already signed in (often as admin) / the login form comes prefilled with admin@test.com or a demo password / a 'Skip login', 'Demo mode' or 'Continue as test user' button still shows in production / a security scan reports 'Hard-coded credentials (CWE-798)' or 'Active debug code (CWE-489)' / I found the test password in the JavaScript bundle or in my GitHub repo
Why it happens
While you build, a login screen gets in the way of every test, so AI builders often add a shortcut: a demo or test account with a simple password, credentials typed straight into the login form or a seed script, a 'skip login' or 'demo mode' button, or code that signs in automatically when the app runs in preview. The shortcut is meant to be temporary, but nothing removes it when you publish. OWASP's testing guide lists this exact root cause: programmers who leave back doors to easily access and test their application and later forget to remove them. Anything in front-end code reaches every visitor's browser: Vite and Next.js copy VITE_ and NEXT_PUBLIC_ variables into the JavaScript bundle at build time, so a test password stored there is public. Only code inside if (import.meta.env.DEV) is removed from Vite production builds; a custom flag such as VITE_DEMO_MODE=true, a hostname check or a localStorage switch ships in the bundle and can be turned on by anyone. Even when the code is gone, the test account usually still exists in Supabase Auth or your users table with its known password, and often with an admin role. OWASP Top 10 2025 (A07 Authentication Failures) says not to ship or deploy with any default credentials, particularly for admin users, and lists CWE-798 Use of Hard-coded Credentials.
How to fix it
- Check it from the outside first. Open your live URL in a private window. If you land inside the app without logging in, or the login form is already filled in, or a demo or skip button appears, you have this problem. Then open DevTools > Sources (or view the JavaScript files under Network) and search the bundle for words like password, demo, test@, admin@, autoLogin, skipAuth, bypass and signInWithPassword.
- Search the code. In your project (or ask your AI builder to list them), search every file for the same words plus the actual test email and password, seed scripts, .env files, README notes and comments. Look for signInWithPassword or signIn calls with fixed values, a fake user object such as { id: 'demo', role: 'admin' } set when there is no session, and route guards that return true when a flag is set.
- Remove the shortcut instead of hiding it. Delete auto-login code, prefilled credentials, demo buttons and fake-session fallbacks. If you truly need a dev-only helper, keep it inside if (import.meta.env.DEV) in Vite (that code is tree-shaken from production builds) or behind process.env.NODE_ENV checks on the server, never behind a VITE_ or NEXT_PUBLIC_ flag that ships in the bundle. Never put a password in a VITE_ or NEXT_PUBLIC_ variable.
- Make every protected page and API check a real session on the server. If the app 'worked' because the guard was bypassed, the fix is not a better bypass: the database and every API route must reject requests without a valid user (Row Level Security in Supabase, a session check in each route or Server Action). See the related admin page fix.
- Deal with the test accounts. In Supabase go to Authentication > Users and delete demo, test and admin accounts you do not need (or call auth.admin.deleteUser() from the server). Supabase notes that deleting a user removes their sessions, but an access token already issued stays valid until it expires. If you need to keep an account, give it a long unique password and no admin role. Check your own users or roles table for leftover admin rows too.
- Rotate anything that was exposed. If the test password is also used anywhere else, change it there. If API keys, a service role key or database passwords sat next to the demo login in the code or repo, rotate them now: GitHub's guidance is that revoking or rotating a leaked secret comes first, and rewriting git history alone does not make it safe (forks and clones keep the old commits).
- Close preview doors too. Preview and staging deployments are public URLs unless protected. On Vercel, Standard Protection (Vercel Authentication) is available on every plan and keeps preview URLs private. Do not share a preview link that has auto-login turned on.
- Verify and keep it out. Rebuild, redeploy and repeat step 1 in a private window: you should see the normal login page, no prefilled fields, and no demo credentials in the bundle. Try the old test email and password: it should fail. Add the search words from step 1 to your pre-publish checklist and ask your AI builder to never add login shortcuts without a dev-only guard.
Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)
My live app still contains a login shortcut from development (auto-login, a demo or test account, prefilled credentials, a skip-login or demo-mode button, or a fake user when there is no session). Do not disable Row Level Security, do not use the service role key in the browser and do not add any new bypass. 1) Search the whole project, including .env files, seed scripts and comments, for hard-coded emails, passwords, autoLogin, skipAuth, demo mode flags, signInWithPassword calls with fixed values and fake session objects, and list each one with its file and line. 2) Remove every shortcut from production code; if a dev helper is truly needed, wrap it in if (import.meta.env.DEV) (or the server-side NODE_ENV check) and never in a VITE_ or NEXT_PUBLIC_ flag. 3) Make every protected route, API route and Server Action check a real session on the server, and keep RLS policies on every table. 4) Tell me which test accounts exist so I can delete them in Supabase Authentication > Users, and which keys or passwords were exposed so I can rotate them. 5) Show me how to confirm in a private window and in the built JavaScript that no credentials or auto-login remain.
Error codes this fixes
Hard-coded credentials (CWE-798)(Code scanner / security review)Active debug code (CWE-489)(Code scanner / security review)
FAQ
Is a demo account in my app always a problem?
A demo account is fine if it has no admin rights, can only see demo data, and its password is not a secret anyone relies on. The problem is a test or admin account with a known password, or code that signs visitors in automatically, in the live app.
I removed the code. Is the test account still a risk?
Yes. The account still exists in Supabase Auth or your users table with the same password. Delete it in Authentication > Users or change it to a long unique password and remove any admin role. Supabase notes an access token already issued stays valid until it expires.
Does if (import.meta.env.DEV) keep my dev login out of production?
In Vite, yes: the docs say code inside if (import.meta.env.DEV) is tree-shaken in production builds. A custom flag like VITE_DEMO_MODE is different: its value and the code it guards are bundled, so anyone can read it and often switch it on.
Can people really see passwords in my front-end code?
Yes. Vite and Next.js copy VITE_ and NEXT_PUBLIC_ values into the JavaScript sent to the browser, and any string typed into front-end code is there too. Open DevTools > Sources on your live site and search: if you can find it, so can anyone.
Is it enough to delete the password from my GitHub repo?
No. Change or rotate the password or key first. GitHub's guide says revoking or rotating the secret is the first step, and old commits can still exist in forks and clones after you rewrite history.
Sources
Based on the official documentation:
- OWASP Top 10:2025 A07 Authentication Failures (no default credentials)
- OWASP WSTG: Testing for Default Credentials (back doors left for testing)
- CWE-798: Use of Hard-coded Credentials
- CWE-489: Active Debug Code
- Vite: Env Variables and Modes (import.meta.env.DEV, VITE_ prefix)
- Next.js: Environment Variables (NEXT_PUBLIC_ inlined at build)
- Supabase: User Management (deleting users, sessions)
- GitHub: Removing sensitive data from a repository (rotate first)
- Vercel: Deployment Protection (Standard Protection for previews)
Related fixes
- Admin page is hidden but not protected (anyone can open /admin or call admin APIs)
- OpenAI / Stripe secret key leaked in the browser
- Your API keys may have leaked: how to rotate every key without breaking your app
- Someone reported a security hole in my vibe-coded app: what to do first
- .env file committed to GitHub
- Is my Lovable app leaking data without login? A Supabase RLS audit checklist after the Crissy Field study
- Login rate limit only counts per email: credential stuffing gets through
Get one new fix a week
Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.
We only use your email to send the newsletter. Unsubscribe any time. See privacy.