Home / patterns

Hard-coded credentials left in vibe-coded apps

A developer looking concerned at a laptop code editor with a password line masked by asterisks and a sticky note that says rotate secrets
Quick answer: AI coding tools often paste a default admin password, API key or database password straight into source files so the demo “just works.” MITRE calls that CWE-798 (Use of Hard-coded Credentials). Anyone who can read the repo, a client bundle or a leaked .env can reuse the same secret across every install. Move secrets out of code, rotate anything that was committed, and require a unique password on first login.

Last updated November 14, 2026

Steps

  1. Search the generated project for password, apiKey, api_key, secret, token, Bearer, PRIVATE_KEY, connectionString and similar names in source, config, Dockerfiles and CI files.
  2. Treat any credential that appears as a string literal in code, or that is the same for every deploy, as compromised. Rotate it at the provider (database, Stripe, OpenAI, admin account) before you ship a fix.
  3. For inbound logins: remove hard-coded admin users. Use a first-login flow that forces a unique strong password, or create accounts only through your auth provider.
  4. For outbound connections (DB, APIs): load credentials from environment variables or a secrets manager at runtime. Do not commit .env files with real values.
  5. Confirm .env, credentials.json and key files are listed in .gitignore and are not present in git history for the current branch. If they were committed, rotate and scrub per your host’s docs.
  6. Add a pre-commit or CI secret scan so new hard-coded keys fail the build.
  7. Retest: with the old hard-coded value, login or API calls should fail; with the rotated secret from the environment, they should succeed only for authorized callers.

Why it matters

MITRE CWE-798 describes products that contain hard-coded passwords or cryptographic keys for inbound authentication or outbound connections. Consequences include bypassing access control and large-scale compromise when the same default password ships in every install. CWE maps this weakness into OWASP Top Ten 2021 category A07 (Identification and Authentication Failures). OWASP’s Secrets Management Cheat Sheet says organizations commonly hard-code API keys and database credentials in source and config, and recommends centralizing secrets, least-privilege access, rotation and keeping secrets out of code.

Sources

MITRE CWE-798: Use of Hard-coded Credentials — https://cwe.mitre.org/data/definitions/798.html

OWASP Cheat Sheet: Secrets Management — https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html

Checked at the source on November 4, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.