2022-04-13 10:10:31 +02:00
|
|
|
include::./description.adoc[]
|
2020-06-30 12:48:07 +02:00
|
|
|
|
2022-04-13 10:10:31 +02:00
|
|
|
include::./ask-yourself.adoc[]
|
2020-06-30 12:48:07 +02:00
|
|
|
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
|
|
|
|
== Sensitive Code Example
|
|
|
|
|
|
|
|
----
|
|
|
|
Connection conn = null;
|
|
|
|
try {
|
|
|
|
conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" +
|
|
|
|
"user=steve&password=blue"); // Sensitive
|
|
|
|
String uname = "steve";
|
|
|
|
String password = "blue";
|
|
|
|
conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" +
|
|
|
|
"user=" + uname + "&password=" + password); // Sensitive
|
|
|
|
|
|
|
|
java.net.PasswordAuthentication pa = new java.net.PasswordAuthentication("userName", "1234".toCharArray()); // Sensitive
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,java]
|
2020-06-30 12:48:07 +02:00
|
|
|
----
|
|
|
|
Connection conn = null;
|
|
|
|
try {
|
|
|
|
String uname = getEncryptedUser();
|
|
|
|
String password = getEncryptedPass();
|
|
|
|
conn = DriverManager.getConnection("jdbc:mysql://localhost/test?" +
|
|
|
|
"user=" + uname + "&password=" + password);
|
|
|
|
----
|
|
|
|
|
2021-09-21 15:40:35 +02:00
|
|
|
== See
|
|
|
|
|
2021-11-01 15:00:32 +01:00
|
|
|
* https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/[OWASP Top 10 2021 Category A7] - Identification and Authentication Failures
|
2021-09-21 15:40:35 +02:00
|
|
|
* https://www.owasp.org/index.php/Top_10-2017_A2-Broken_Authentication[OWASP Top 10 2017 Category A2] - Broken Authentication
|
2022-04-07 08:53:59 -05:00
|
|
|
* https://cwe.mitre.org/data/definitions/798[MITRE, CWE-798] - Use of Hard-coded Credentials
|
|
|
|
* https://cwe.mitre.org/data/definitions/259[MITRE, CWE-259] - Use of Hard-coded Password
|
2021-09-21 15:40:35 +02:00
|
|
|
* https://wiki.sei.cmu.edu/confluence/x/OjdGBQ[CERT, MSC03-J.] - Never hard code sensitive information
|
|
|
|
* Derived from FindSecBugs rule https://h3xstream.github.io/find-sec-bugs/bugs.htm#HARD_CODE_PASSWORD[Hard Coded Password]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
include::../parameters.adoc[]
|
|
|
|
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-02 20:44:38 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::comments-and-links.adoc[]
|
2021-06-03 09:05:38 +02:00
|
|
|
endif::env-github,rspecator-view[]
|