| CWE-259: Use of Hard-coded Password
 View customized information: For users who are interested in more notional aspects of a weakness. Example: educators, technical writers, and project/program managers.
	
	
		
        	For users who are concerned with the practical application and details about the nature of a weakness and how to prevent it from happening. Example: tool developers, security researchers, pen-testers, incident response analysts.
	
	
		
        	For users who are mapping an issue to CWE/CAPEC IDs, i.e., finding the most appropriate CWE for a specific issue (e.g., a CVE record).  Example: tool developers, security researchers.
	
	
			
        	For users who wish to see all available information for the CWE/CAPEC entry.
	
	
		
        	For users who want to customize what details are displayed. 
    ×
     Edit Custom FilterThere are two main variations of a hard-coded password: Inbound: the product contains an authentication mechanism that checks for a hard-coded password. Outbound: the product connects to another system or component, and it contains a hard-coded password for connecting to that component.  This table specifies different individual consequences
                        associated with the weakness. The Scope identifies the application security area that is
                        violated, while the Impact describes the negative technical impact that arises if an
                        adversary succeeds in exploiting this weakness. The Likelihood provides information about
                        how likely the specific consequence is expected to be seen relative to the other
                        consequences in the list. For example, there may be high likelihood that a weakness will be
                        exploited to achieve a certain impact, but a low likelihood that it will be exploited to
                        achieve a different impact. 
 
  This table shows the weaknesses and high level categories that are related to this
                            weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to
                            similar items that may exist at higher and lower levels of abstraction. In addition,
                            relationships such as PeerOf and CanAlsoBe are defined to show similar weaknesses that the user
                            may want to explore.  Relevant to the view "Research Concepts" (View-1000) 
  Relevant to the view "Architectural Concepts" (View-1008) 
  Relevant to the view "CISQ Quality Measures (2020)" (View-1305) 
  Relevant to the view "CISQ Data Protection Measures" (View-1340) 
  The different Modes of Introduction provide information
                        about how and when this
                        weakness may be introduced. The Phase identifies a point in the life cycle at which
                        introduction
                        may occur, while the Note provides a typical scenario related to introduction during the
                        given
                        phase. 
  This listing shows possible areas for which the given
                        weakness could appear. These
                        may be for specific named Languages, Operating Systems, Architectures, Paradigms,
                        Technologies,
                        or a class of such platforms. The platform is listed along with how frequently the given
                        weakness appears for that instance. 
 Example 1 The following code uses a hard-coded password to connect to a database: (bad code) 
                                    
                                    Example Language: Java 
                                    
                                 ... DriverManager.getConnection(url, "scott", "tiger"); ... This is an example of an external hard-coded password on the client-side of a connection. This code will run successfully, but anyone who has access to it will have access to the password. Once the program has shipped, there is no going back from the database user "scott" with a password of "tiger" unless the program is patched. A devious employee with access to this information can use it to break into the system. Even worse, if attackers have access to the bytecode for application, they can use the javap -c command to access the disassembled code, which will contain the values of the passwords used. The result of this operation might look something like the following for the example above: (attack code) javap -c ConnMngr.class 22: ldc #36; //String jdbc:mysql://ixne.com/rxsql 24: ldc #38; //String scott 26: ldc #17; //String tiger Example 2 The following code is an example of an internal hard-coded password in the back-end: (bad code) 
                                    
                                    Example Language: C 
                                    
                                 int VerifyAdmin(char *password) { if (strcmp(password, "Mew!")) { 
                                 printf("Incorrect Password!\n"); return(0); printf("Entering Diagnostic Mode...\n"); return(1); (bad code) 
                                    
                                    Example Language: Java 
                                    
                                 int VerifyAdmin(String password) { if (!password.equals("Mew!")) {} return(0);} //Diagnostic Mode return(1); Every instance of this program can be placed into diagnostic mode with the same password. Even worse is the fact that if this program is distributed as a binary-only distribution, it is very difficult to change that password or disable this "functionality." Example 3 The following examples show a portion of properties and configuration files for Java and ASP.NET applications. The files include username and password information but they are stored in cleartext. This Java example shows a properties file with a cleartext username / password pair. (bad code) 
                                    
                                    Example Language: Java 
                                    
                                 # Java Web App ResourceBundle properties file ... webapp.ldap.username=secretUsername webapp.ldap.password=secretPassword ... The following example shows a portion of a configuration file for an ASP.Net application. This configuration file includes username and password information for a connection to a database but the pair is stored in cleartext. (bad code) 
                                    
                                    Example Language: ASP.NET 
                                    
                                 ... <connectionStrings> <add name="ud_DEV" connectionString="connectDB=uDB; uid=db2admin; pwd=password; dbalias=uDB;" providerName="System.Data.Odbc" /></connectionStrings> ... Username and password information should not be included in a configuration file or a properties file in cleartext as this will allow anyone who can read the file access to the resource. If possible, encrypt this information. Example 4 In 2022, the OT:ICEFALL study examined products by 10 different Operational Technology (OT) vendors. The researchers reported 56 vulnerabilities and said that the products were "insecure by design" [REF-1283]. If exploited, these vulnerabilities often allowed adversaries to change how the products operated, ranging from denial of service to changing the code that the products executed. Since these products were often used in industries such as power, electrical, water, and others, there could even be safety implications. Multiple vendors used hard-coded credentials in their OT products. Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry. 
 
 
  This MemberOf Relationships table shows additional CWE Categories and Views that
                                reference this weakness as a member. This information is often useful in understanding where a
                                weakness fits within the context of external information sources. 
 
 Other In the Inbound variant, a default administration account may be 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. 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. The Outbound variant can apply to front-end systems that authenticate with a back-end service. The back-end service may require a fixed password that can be discovered easily. The programmer may simply hard-code those back-end credentials into the front-end product. Any user of that program 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. Maintenance 
                                It might be appropriate to split this entry into an inbound variant and an outbound variant. These variants are likely to have different consequences, detectability, etc., although such differences are not suitable for a split. More importantly, from a vulnerability theory perspective, they might be characterized as different behaviors. The difference is in where the hard-coded password is stored - on the component performing the authentication, or the component that is connecting to the external component that requires authentication.  However, as with many weaknesses, the "vulnerability topology" should not be regarded as important enough for splits.  For example, separate weaknesses do not exist for client-to-server buffer overflows versus server-to-client buffer overflows.
                             
 
 More information is available — Please edit the custom filter or select a different filter. | 
| Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2025, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. | ||
 
	                