scanrub
Use of Hard-coded Credentialslow prioritypartial coverage

Hard-coded Credentials

3 min read 12 reports analyzed ScanRub Research
Share

Summary

This is CWE-798: an authentication credential, a username/password pair, an API key, a service-account token, is written directly into source code or compiled into a shipped binary rather than being read from a secrets manager or injected at deploy time. The practical consequence is that the credential is identical across every single deployment of that code, and permanent: anyone who can read the source repository, decompile the binary, or inspect a shipped mobile app or JavaScript bundle can extract it, and rotating it means shipping a whole new build rather than just changing a value in a config store. It's distinct from a password sitting in a separately deployed configuration file (which at least varies per deployment and can be rotated independently): here, the credential and the code are the same artifact.

◈ flow diagram
Source Code …Hard-Coded S…Direct Authe…Protected Sy…
◈ chart
Critical
1
High
3
Medium
5
Low
3

Top Affected Components / Targets

  • Mobile app binaries with an embedded API key or backend service credential
  • Client-side JavaScript bundles containing a key that was meant to stay server-side
  • Backend source code (public or accidentally exposed repositories) with a database or internal-service credential written directly into a constant

Common Attack Vectors

  • Decompile or unpack a mobile app binary and search the extracted strings for credential-shaped values, connection strings, or API key patterns
  • Search public source repositories, including forks and old commits, for credential-shaped strings that may have been committed once and never fully scrubbed from history
  • Scan client-side JavaScript bundles for embedded keys, since a key meant for server-side use only sometimes ends up bundled into frontend code by mistake

Common Payloads

  • No injected payload; this is a discovery-and-extraction exercise against shipped artifacts (binaries, JS bundles, public repositories) rather than a live probe against a running server

Detection Strategy

Scan every JavaScript bundle, mobile app binary, and publicly reachable source artifact discovered during recon for credential-shaped strings using the same structured and generic secret-detection patterns used elsewhere, since the underlying signal, a string that looks like a real API key or connection string, is identical regardless of where it was found. Where source history is available (a public repository), check prior commits too, since a credential removed from the current version but present in history is still exposed and still often valid.

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 credential-shaped string found in a test fixture, example file, or documentation, clearly not meant to be a real production secret, shouldn't be scored the same as one found in production application code; context around where the string was found matters as much as the string's shape.

How to Test

Manual Testing Methodology

Here is a systematic approach to identifying Hard-coded Credentials vulnerabilities in a target application.

Step 1: Reconnaissance and Surface Mapping

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.

Step 2: Baseline Request

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.

Step 3: Payload Injection

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 Credentials 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.

Step 4: Response Analysis

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.

Step 5: Confirmation

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 Credentials, 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 Credentials 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.

Frequently Asked Questions

What is Hard-coded Credentials?
This is CWE-798: an authentication credential, a username/password pair, an API key, a service-account token, is written directly into source code or compiled into a shipped binary rather than being read from a secrets manager or injected at deploy time.
How common is Hard-coded Credentials in bug bounty reports?
Scanrub's research corpus for this playbook is built from 12 disclosed HackerOne reports in this category, synthesized for detection and prevention guidance rather than reproduced verbatim.
How do I test for Hard-coded Credentials?
Map every input vector, record a baseline response, then inject targeted test payloads one field at a time and compare the response for timing, length, error, or reflection differences from that baseline. The "How to Test" section above walks through the full methodology for this specific vulnerability class.
What is the single most effective fix for Hard-coded Credentials?
Store every credential and key in a dedicated secrets manager injected at runtime, never in source control or a shipped default — and rotate anything that was ever committed.
Weekly security research

New vulnerability playbooks, tool updates, and bug bounty insights - delivered to your inbox. No spam.

Unsubscribe anytime. We respect your inbox.
Press ⌘K to search×