|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CWE-261: Weak Cryptography for Passwords
Description Summary Obscuring a password with a trivial encoding does not protect the password.
Example 1 The following code reads a password from a properties file and uses the password to connect to a database. (Bad Code) Example
Language: Java ... Properties prop = new Properties(); prop.load(new FileInputStream("config.properties")); String password =
Base64.decode(prop.getProperty("password")); DriverManager.getConnection(url, usr, password); ... This code will run successfully, but anyone with access to config.properties can read the value of password and easily determine that the value has been base 64 encoded. If a devious employee has access to this information, they can use it to break into the system. Example 2 The following code reads a password from the registry and uses the password to create a new network credential. (Bad Code) Example
Language: Java ... string value = regKey.GetValue(passKey).ToString(); byte[] decVal = Convert.FromBase64String(value); NetworkCredential netCred =
newNetworkCredential(username,decVal.toString(),domain); ... This code will run successfully, but anyone who has access to the registry key used to store the password can read the value of password. If a devious employee has access to this information, they can use it to break into the system.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Page Last Updated:
February 20, 2013
|
|
CWE is co-sponsored by the office of Cybersecurity and Communications at the U.S. Department of Homeland Security. This Web site is sponsored and managed by The MITRE Corporation to enable stakeholder collaboration. Copyright © 2006-2013, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. Contact cwe@mitre.org for more information. |
|||



