How to fix: Hardcoded Credential in Authentication Logic
A hardcoded credential comparison was detected in the response body. Patterns like password === 'admin', password === 'password', or token === '12345' indicate placeholder authentication logic that was never replaced with real credential verification.
Why it matters
Anyone who reads the source (bundle, source map, or JS file) gets the master credential. This is a complete authentication bypass: the hardcoded value works for every account with no brute force needed.
AI tools generate placeholder authentication for scaffolding and examples: 'if (password === "secret") { ... }'. These are intended to be replaced before deployment but frequently are not. They show up in both backend routes and frontend code.
How to fix it
- 1Remove all hardcoded credential comparisons immediately.
- 2Use proper password hashing (bcrypt, argon2) and comparison against stored hashes.
- 3For API tokens, use constant-time comparison: crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b)).
- 4Rotate any credentials that were ever hardcoded, assuming they are compromised.
Code examples
Secure password verification
import bcrypt from 'bcryptjs';
// Bad (AI-generated placeholder)
if (password === 'admin') { ... }
// Good
const user = await db.getUserByEmail(email);
if (!user || !(await bcrypt.compare(password, user.passwordHash))) {
return Response.json({ error: 'Invalid credentials' }, { status: 401 });
}References
Detected automatically by VulnRadar. The check id is vibe-placeholder-auth, stable across every scan so you can filter or diff on it.
More ai code checks
- LowGeneric Error Messages Leak No Context
- MediumTODO/FIXME Security Note in Response
- Higheval() Usage in Page Scripts
- HighSSL Certificate Verification Disabled
- HighMath.random() Used for Security Tokens
- CriticalJWT 'none' Algorithm Accepted
- CriticalSQL String Concatenation Pattern Detected
- MediumStack Trace Exposed in Response
Questions
- How severe is Hardcoded Credential in Authentication Logic?
- VulnRadar rates this critical severity in the ai code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id vibe-placeholder-auth, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Hardcoded Credential in Authentication Logic map to?
- It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.