Hard-coded Password
Summary
This is CWE-259, a specific sub-instance of hard-coded credentials with a particular twist: rather than a key for some external service, the hard-coded value is a password baked directly into the application's own authentication check. In its most common, relatively benign form, it's a shared default password left over from development that nobody removed before shipping. In its more serious form, it's an intentional but undocumented backdoor: a developer leaves themselves a permanent way into every deployment of the software, whether for legitimate support access or something less defensible, and because the check is baked into the code itself rather than tied to a per-deployment secret, that backdoor password works identically on every installation, including ones the original developer has no legitimate business accessing.
Top Affected Components / Targets
- Embedded devices and IoT firmware, where hard-coded support or debug passwords are a long-standing, well-documented pattern
- Admin or support accounts in web applications with a password comparison written directly into the authentication logic rather than checked against a stored, per-deployment hash
- Vendor software with an undocumented "maintenance" or "support" account left in shipped code
Common Attack Vectors
- Decompile a binary or review source code for a direct string comparison against a login credential, rather than a lookup against a stored password hash, which is a strong signal of a hard-coded check
- Try commonly leaked or previously disclosed vendor default/backdoor passwords against login forms for known device and software families, since these values are frequently reused across product lines and disclosed publicly once found once
Common Payloads
- Known, previously disclosed default or backdoor credentials for the specific fingerprinted software or device family
- No generic payload applies broadly here; effective testing requires knowing the specific product and checking against its documented or leaked default credentials
Detection Strategy
Where source code or a binary is available, review authentication logic specifically for a direct comparison against a literal string rather than a lookup against a stored, salted hash, since that pattern is the structural signature of this bug regardless of what the specific password value turns out to be. Where only the running application is available, fingerprint the exact product and version and check it against known, previously disclosed default or backdoor credentials for that specific software or device family.
Tip: Testing tools that run these checks in parallel across every discovered endpoint can cut the time required substantially compared to fully manual testing, as long as they confirm findings with more than one signal to keep the false-positive rate down.
False-Positive Notes
A default password that's clearly meant to be changed on first login, and is actually enforced to be changed before the account becomes usable, is a different and much lower-severity issue than a hard-coded password with no forced-rotation mechanism at all; confirm whether the application actually requires the default to be changed before treating this as a full-severity finding.
How to Test
Manual Testing Methodology
Here is a systematic approach to identifying Hard-coded Password vulnerabilities in a target application.
Before testing, map all input vectors that could be affected. Identify parameters, headers, cookies, and request bodies that interact with the vulnerable component. A proxy such as Burp Suite or OWASP ZAP, paired with normal browsing of the target, is usually enough to build this list.
Send a legitimate request and record the normal response: status code, content length, response time, and any identifying tokens. This baseline matters because it's what you'll compare later responses against once payloads are involved.
Inject test payloads into each identified input vector one at a time. Start with benign detection payloads before escalating to anything that could actually trigger the vulnerability. For Hard-coded Password specifically, search publicly reachable source (client-side JS bundles, mobile app binaries, public repositories, exposed .git directories) for API keys, connection strings, and hard-coded passwords, and separately try any vendor-published default credentials against the target's login and admin interfaces.
Compare the response against your baseline, looking specifically for a live credential or key found in source that successfully authenticates against the corresponding service, or a default credential pair that logs in without being changed.
Once a potential vulnerability is detected, confirm it with at least a few independent test cases to rule out coincidence. Document the exact request and response as proof. For Hard-coded Password, a confirmed finding typically means showing that attacker-controlled input changes the application's behavior in a way that matters for security, not just that a payload was reflected somewhere harmless.
Real-World Impact
Real-World Impact
Hard-coded and weakly-protected credentials give an attacker a direct path to whatever the credential guards — a database, an internal API, a cloud account, or the application itself — without needing to find or exploit a code-level bug at all. A secret committed to source control remains exploitable even after it's later removed, since it persists in git history indefinitely unless the repository is actively scrubbed and the credential rotated.
Default credentials left in place after deployment are a perennial finding for exactly the same reason: they require no discovery beyond checking the vendor's published defaults, and they're routinely still valid in production.
Weakly hashed or reversibly "encrypted" passwords compound the damage of any other breach — a database dump that would otherwise only expose hashes needing significant offline cracking effort instead hands over plaintext-equivalent credentials immediately, and because of password reuse, that damage extends well beyond the breached application itself.
Prevention & Remediation
Prevention and Secure Coding
Preventing Hard-coded Password takes a defense-in-depth approach — no single control below is sufficient alone, but together they close off both the primary path and the most common bypasses.
Secrets manager, not source control. Store credentials, API keys, and cryptographic keys in a dedicated secrets manager (Vault, cloud KMS, or equivalent) and inject them at runtime — never commit them to a repository, config file, or container image.
Rotate anything ever exposed. A credential that was ever committed, even briefly, should be treated as compromised and rotated — removing it from the latest commit does not remove it from history.
No shipped default credentials. Force a credential-setup step on first run rather than shipping a default username/password that some deployments will never change.
Modern password hashing, always. Hash passwords with bcrypt, scrypt, or Argon2 with a per-user salt — never store them in plaintext or with reversible encryption, and never with an unsalted or fast general-purpose hash like unsalted SHA-256.
Automated secret-scanning in CI. A pre-commit or CI secret-scanner catches an accidental credential commit before it reaches a shared branch, which is far cheaper than a post-hoc rotation.