← All posts
password strength validationvibe codingAI coding securityauthenticationweb security

How to Fix Missing Password Strength Validation in Vibe-Coded Apps

O

OverMCP Team

Quick answer

Password strength validation is often missing in vibe-coded apps because AI tools generate authentication code that prioritizes functionality over security. To fix it, you need to enforce a minimum password policy (length, complexity, common password checks) both on the client and server side. Use a library like zxcvbn for realistic strength estimation and validate the password against your policy before hashing and storing it.

Why vibe-coded apps skip password strength

AI coding assistants like Cursor, Bolt.new, and Lovable are great at shipping fast, but they rarely include security features like password strength validation. The generated authentication code often looks like this:

app.post('/signup', async (req, res) => {
  const { email, password } = req.body;
  // No password strength check!
  const hashedPassword = await bcrypt.hash(password, 10);
  await db.user.create({ data: { email, password: hashedPassword } });
  // ...
});

This is a common pattern in AI-generated apps: the password is accepted as-is, no matter how weak. Attackers can easily brute-force such accounts, and users inadvertently use "password123" or "qwerty".

What to check first

Before writing any code, verify if your app currently has any password validation:

  • [ ] Check the registration endpoint (e.g., /api/signup) for any password validation logic.
  • [ ] Look for any client-side JavaScript that checks password strength (e.g., a password meter).
  • [ ] Search your codebase for keywords like minLength, passwordStrength, zxcvbn, or Validator.
  • [ ] Check if your database schema enforces a minimum password length (it shouldn't – validation should be in app logic).
  • [ ] Test with a weak password like "123456" – does it get accepted?
  • If you answered "no" to any of these, your app likely has missing password strength validation.

    Step-by-step fix

    1. Define a password policy

    Decide on a clear policy. A good starting point:

  • Minimum 8 characters (12+ is better)
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one digit
  • At least one special character (e.g., !@#$%^&*)
  • Not a common password (e.g., from the Have I Been Pwned list)
  • 2. Add server-side validation

    AI-generated apps often skip server-side validation because the AI focuses on the happy path. Add a validation function in your backend:

    const passwordValidator = require('password-validator');
    const schema = new passwordValidator();
    
    schema
      .is().min(8)
      .is().max(100)
      .has().uppercase()
      .has().lowercase()
      .has().digits()
      .has().not().spaces()
      .is().not().oneOf(['Passw0rd', 'Password123', '12345678']); // common weak passwords
    
    app.post('/signup', async (req, res) => {
      const { email, password } = req.body;
      
      if (!schema.validate(password)) {
        return res.status(400).json({ 
          error: 'Password must be 8-100 characters, include uppercase, lowercase, digit, and no spaces.' 
        });
      }
      
      // Now hash and store
      const hashedPassword = await bcrypt.hash(password, 10);
      await db.user.create({ data: { email, password: hashedPassword } });
      // ...
    });

    3. Use zxcvbn for realistic strength estimation

    For a better user experience, use zxcvbn (from Dropbox) which estimates password strength based on real-world cracking techniques:

    npm install zxcvbn
    const zxcvbn = require('zxcvbn');
    
    app.post('/signup', async (req, res) => {
      const { email, password } = req.body;
      const result = zxcvbn(password);
      
      // score: 0 (very weak) to 4 (very strong)
      if (result.score < 3) {
        return res.status(400).json({ 
          error: 'Password is too weak. Try a longer password with a mix of characters.',
          feedback: result.feedback.suggestions
        });
      }
      
      // ...
    });

    4. Add client-side feedback (password meter)

    Vibe-coded apps often have no real-time feedback. Add a simple password strength meter using zxcvbn on the frontend:

    import zxcvbn from 'zxcvbn';
    
    function PasswordInput({ value, onChange }) {
      const strength = value ? zxcvbn(value) : { score: 0 };
      const strengthLabel = ['Weak', 'Fair', 'Good', 'Strong', 'Very Strong'];
      
      return (
        <div>
          <input type="password" value={value} onChange={onChange} />
          <progress value={strength.score} max="4" />
          <p>{strengthLabel[strength.score]}</p>
        </div>
      );
    }

    5. Check against breached passwords

    Prevent users from using passwords that appear in data breaches. Use the Have I Been Pwned API (k-anonymity model):

    async function isPasswordPwned(password) {
      const sha1 = crypto.createHash('sha1').update(password).digest('hex').toUpperCase();
      const prefix = sha1.substring(0, 5);
      const suffix = sha1.substring(5);
      const response = await fetch(`https://api.pwnedpasswords.com/range/${prefix}`);
      const hashes = await response.text();
      return hashes.includes(suffix);
    }
    
    // In signup endpoint:
    if (await isPasswordPwned(password)) {
      return res.status(400).json({ error: 'This password has been exposed in a data breach. Choose another.' });
    }

    6. Test your fix

    Run through these test cases:

  • short (too short)
  • password (common word)
  • P@ssw0rd (common pattern)
  • CorrectHorseBatteryStaple (strong)
  • 12345678 (pwned)
  • Common mistakes

    Even after adding validation, vibe-coded apps often make these errors:

    Client-only validation

    AI-generated code may check password strength only in the browser. An attacker can bypass client-side checks by sending a direct POST request to your API. Always validate server-side.

    Overly restrictive policies

    Some generated validators reject passwords that are actually strong (e.g., a long passphrase without uppercase). Use zxcvbn instead of arbitrary character class requirements.

    Ignoring common password lists

    AI code rarely checks against the top 10,000 passwords. A password like "Password1!" may pass length and complexity checks but is still weak. Use a deny list or the Have I Been Pwned API.

    Not providing user feedback

    Vibe-coded signup forms often just say "Password invalid" without guidance. Show specific requirements or strength meter to help users create strong passwords.

    Storing plain text passwords

    Even if you add strength validation, ensure you're hashing passwords with bcrypt or Argon2. AI-generated code sometimes forgets this step.

    How OverMCP can help

    Vibe-coded apps often have multiple security gaps beyond password strength. Use OverMCP's free AI app security scanner to check your app for common vulnerabilities like exposed secrets, missing security headers, and weak authentication. It's built for indie developers who ship fast – scan your app in minutes without setting up complex tooling.

    You can also use the secret leak scanner to check if any API keys or credentials are accidentally exposed in your codebase.

    FAQ

    What is password strength validation in vibe coding?

    Password strength validation ensures that users choose passwords that are resistant to brute-force and guessing attacks. In vibe coding, AI-generated apps often skip this step, leaving user accounts vulnerable.

    Why do AI coding tools skip password strength checks?

    AI assistants prioritize functional completion over security. They generate the minimum code to make authentication work, often omitting validation rules, strength meters, and breach checks.

    Can I add password strength validation to an existing vibe-coded app without rewriting everything?

    Yes. You can add server-side validation to your existing signup endpoint and integrate a client-side password meter. Use libraries like password-validator or zxcvbn to add strong validation with minimal code changes.

    Is your app secure?

    Free scan in 30 seconds. No signup needed.

    Scan My App Free