Skip to content

CWE-798: Use of Hard-coded Credentials

BaseLikelihood of exploit: High

The product contains hard-coded credentials, such as a password or cryptographic key.

There are two main variations: Inbound: the product contains an authentication mechanism that checks the input credentials against a hard-coded set of credentials. In this variant, a default administration account is created, and a simple password is hard-coded into the product and associated with that account. This hard-coded password is the same for each installation of the product, and it usually cannot be changed or disabled by system administrators without manually modifying the program, or otherwise patching the product. It can also be difficult for the administrator to detect. Outbound: the product connects to another system or component, and it contains hard-coded credentials for connecting to that component. This variant applies to front-end systems that authenticate with a back-end service. The back-end service may require a fixed password that can be easily discovered. The programmer may simply hard-code those back-end credentials into the front-end product.

Consequences

  • Access Control: Bypass Protection Mechanism
  • Integrity, Confidentiality, Availability, Access Control, Other: Read Application Data, Gain Privileges or Assume Identity, Execute Unauthorized Code or Commands, Other

How to prevent it

  • Architecture and Design: For outbound authentication: store passwords, keys, and other credentials outside of the code in a strongly-protected, encrypted configuration file or database that is protected from access by all outsiders, including other local users on the same system. Properly protect the key (CWE-320). If you cannot use encryption to protect the file, then make sure that the permissions are as restrictive as possible [REF-7]. In Windows environments, the Encrypted File System (EFS) may provide some protection.
  • Architecture and Design: For inbound authentication: Rather than hard-code a default username and password, key, or other authentication credentials for first time logins, utilize a "first login" mode that requires the user to enter a unique strong password or key.
  • Architecture and Design: If the product must contain hard-coded credentials or they cannot be removed, perform access control checks and limit which entities can access the feature that requires the hard-coded credentials. For example, a feature might only be enabled through the system console instead of through a network connection.
  • Architecture and Design: For inbound authentication using passwords: apply strong one-way hashes to passwords and store those hashes in a configuration file or database with appropriate access control. That way, theft of the file/database still requires the attacker to try to crack the password. When handling an incoming password during authentication, take the hash of the password and compare it to the saved hash. Use randomly assigned salts for each separate hash that is generated. This increases the amount of computation that an attacker needs to conduct a brute-force attack, possibly limiting the effectiveness of the rainbow table method.
  • Architecture and Design: For front-end to back-end connections: Three solutions are possible, although none are complete. The first suggestion involves the use of generated passwords or keys that are changed automatically and must be entered at given time intervals by a system administrator. These passwords will be held in memory and only be valid for the time intervals. Next, the passwords or keys should be limited at the back end to only performing actions valid for the front end, as opposed to having full access. Finally, the messages sent should be tagged and checksummed with time sensitive values so as to prevent replay-style attacks.

Recent advisories

  • PYSEC-2026-3768 — openssl_encrypt versions before 1.4.0 contain hardcoded default JWT signing secrets in config.py that pass validation checks.
  • PYSEC-2026-3746 — openssl_encrypt versions before 1.4.0 contain a hardcoded default secret key in the standalone telemetry server configuration that is used for API key hashing.
  • PYSEC-2026-3767 — openssl_encrypt versions before 1.4.0 contain hardcoded database credentials in standalone server configuration files.
  • GHSA-jphh-m39h-6gwx — 9router's Hardcoded Default fallback JWT Secret Allows Authentication Bypass
  • GHSA-cwj8-7gp2-ggcw — praisonai-platform: default JWT signing secret 'dev-secret-change-me' enables token forgery
  • GHSA-f38v-77qj-h4jq — praisonai-platform 0.1.4 still boots on the hardcoded JWT secret dev-secret-change-me (default-open production guard)
  • GHSA-qhr7-h655-pw6r — Apache Solr has hardcoded credentials in the Basic Authentication setup tool
  • GHSA-3qg8-5g3r-79v5 — praisonai-platform: JWT signing key defaults to hardcoded "dev-secret-change-me", allowing token forgery for any user when PLATFORM_ENV is unset
  • GHSA-m7mq-85xj-9x33 — Flowise: Weak Default Token Hash Secret
  • GHSA-2qqc-p94c-hxwh — Flowise: Weak Default Express Session Secret
  • GHSA-hj7x-hmf2-hc2p — Harbor allows the use of the default password for web UI login
  • GHSA-h3h8-3v2v-rg7m — Gradio: Mocked OAuth Login Exposes Server Credentials and Uses Hardcoded Session Secret
  • GHSA-gq3w-7jj3-x7gr — MLflow Use of Default Password Authentication Bypass Vulnerability
  • CVE-2026-22769 — Dell RecoverPoint for Virtual Machines, versions prior to 6.0.3.1 HF1, contain a hardcoded credential vulnerability.
  • GHSA-h956-rh7x-ppgj — RustFS has a gRPC Hardcoded Token Authentication Bypass

All advisories for CWE-798

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor