CWE-798 / WEAKNESS
Use of Hard-coded Credentials
The product contains hard-coded credentials, such as a password or cryptographic key.
- Category
- CWE weaknesses
- Version / scope
- CWE 4.20; release 2026-04-30; publisher status Draft
- Affected / relevant technologies
- Mobile / ICS/OT / Not Language-Specific
- Evidence
- Documentation: pinned-source excerpt checked. Execution: not tested. Editorial: curated reference.
Defensive analysis and explicitly authorized assessment only. This website performs no scans, exploitation, model calls or infrastructure changes. Indicators below are investigation opportunities, not proof of compromise or guaranteed detectors.
Mechanism and prerequisites
No separate exploit prerequisites are asserted here; the publisher's weakness/pattern context must be matched to the implementation.
Potential impact
Access Control Bypass Protection Mechanism If hard-coded passwords are used, it is almost certain that malicious users will gain access to the account in question. Any user of the product that hard-codes passwords may be able to extract the password. Client-side systems with hard-coded passwords pose even more of a threat, since the extraction of a password from a binary is usually very simple. Integrity Confidentiality Availability Access Control Other Read Application Data Gain Privileges or Assume Identity Execute Unauthorized Code or Commands Other This weakness can lead to the exposure of resources or functionality to unintended actors, possibly providing attackers with sensitive information or even execute arbitrary code. If the password is ever discovered or published (a common occurrence on the Internet), then anybody with knowledge of this password can access the product. Finally, since all installations of the product will have the same password, even across different organizations, this enables massive attacks such as worms to take place.
Versioned source scope
This record contains normalized, sometimes shortened source excerpts with editorial safety context. Markup and executable example blocks are omitted. Source-field verification does not establish device testing, a working detector or local applicability.
Publisher: MITRE. Release: CWE 4.20; release 2026-04-30; publisher status Draft. Source checked: 2026-11-18.
Source object: CWE-798. Object modified: 2025-12-11.
Attribution and source terms (© The MITRE Corporation; reproduced with permission)Detection and investigation
- Black Box Credential storage in configuration files is findable using black box methods, but the use of hard-coded credentials for an incoming authentication routine typically involves an account that is not visible outside of the code. Moderate
- Automated Static Analysis Automated white box techniques have been published for detecting hard-coded credentials for incoming authentication, but there is some expert disagreement regarding their effectiveness and applicability to a broad range of methods.
- Manual Static Analysis This weakness may be detectable using manual code analysis. Unless authentication is decentralized and applied throughout the product, there can be sufficient time for the analyst to find incoming authentication routines and examine the program logic looking for usage of hard-coded credentials. Configuration files could also be analyzed. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.
- Manual Dynamic Analysis For hard-coded credentials in incoming authentication: use monitoring tools that examine the product's process as it interacts with the operating system and the network. This technique is useful in cases when source code is unavailable, if the product was not developed by you, or if you want to verify that the build phase did not introduce any new weaknesses. Examples include debuggers that directly attach to the running process; system-call tracing utilities such as truss (Solaris) and strace (Linux); system activity monitors such as FileMon, RegMon, Process Monitor, and other Sysinternals utilities (Windows); and sniffers and protocol analyzers that monitor network traffic. Attach the monitor to the process and perform a login. Using call trees or similar artifacts from the output, examine the associated behaviors and see if any of them appear to be comparing the input to a fixed string or value.
Preserve source timestamps, asset identity and collection context. Correlate independent evidence before attributing malicious intent. In OT, review passive evidence with the process owner; do not induce failures, replay commands or write to controllers to test a hypothesis.
Mitigation and response
- 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.
Apply changes through the asset owner's approved change and recovery process. Documentation review is separate from successful testing or verified production protection.
Related technical context
No protocol-specific mapping is asserted for this entry.
Related security reading
Continue directly to another reference. Editorial reading connections do not assert official CWE/CAPEC/ATT&CK/OWASP equivalence or mappings.
Publisher-defined relationships
These directed relationships come from the pinned publisher data. They describe framework context, not guaranteed prevention, detection coverage or equivalence between entities.
Publisher weakness and attack-pattern relationships
These relationships retain the publisher's source attributes and view context; they do not establish that an attack or weakness applies to a particular system.
- CAPEC-191 → Related_Weakness → CWE-798 Open related reference
- CAPEC-70 → Related_Weakness → CWE-798 Open related reference
- CWE-259 → ChildOf → CWE-798 Open related reference
- CWE-259 → ChildOf → CWE-798 Open related reference
- CWE-259 → ChildOf → CWE-798 Open related reference
- CWE-321 → ChildOf → CWE-798 Open related reference
- CWE-321 → ChildOf → CWE-798 Open related reference
- CWE-321 → ChildOf → CWE-798 Open related reference
- CWE-798 → Related_Attack_Pattern → CAPEC-191 Open related reference
- CWE-798 → Related_Attack_Pattern → CAPEC-70 Open related reference
- CWE-798 → ChildOf → CWE-1391 Open related reference
- CWE-798 → PeerOf → CWE-257 Open related reference
- CWE-798 → ChildOf → CWE-287 Open related reference
- CWE-798 → ChildOf → CWE-344 Open related reference
- CWE-798 → ChildOf → CWE-671 Open related reference
Authoritative sources and attribution
Identifiers and source titles belong to OWASP, MITRE, the CVE Program, CISA, NIST or the cited vendor. Source excerpts are attributed and adapted under the linked publisher license; editorial context is separate. This is not an official framework mirror. Review baseline: 2026-11-18. Live documents can change; check exact current applicability.
- Publisher reference: CWE-798 — source accessed 2026-11-18
- cwe — source accessed 2026-11-18
Source review supports bounded reference text. It is not execution evidence, a completeness claim, a CVSS assessment, a compliance certification or verification of production security.
