Java: Password in Java EE configuration files#4814
Conversation
|
I note from the code scanning warnings (which come from the C# analysis) that this is a near-copy of https://github.com/github/codeql/blob/main/csharp/ql/src/Configuration/PasswordInConfigurationFile.ql -- @github/codeql-csharp, what do you make of the differences (stronger |
Looks like this query also has that disjunct: https://github.com/github/codeql/pull/4814/files#diff-a072f910060223db1a33816cd6374601e46f0bb2759b46e60edd0e83e3c90636R36. Not sure why |
|
Doh yeah. @luchua-bc can we usefully use |
|
Thanks @hvitved for reviewing this PR. I copied the third disjunct from the C# query. Typically .NET applications have a database configuration like the following: This is the reason for this disjunct. While Java EE applications have a more structured configuration like: I did a quick search on Java GitHub repositories and cannot find any repository with the .NET style configuration of connection strings. Will it be a good idea to simply delete this disjunct since it won't be useful to most Java projects? Or I can apply the same Please advise. Thanks, |
|
I've modified the query to apply the same check (blank, placeholder and encrypted) to embedded passwords. As method parameters cannot be Please let me know if this is not what we want. |
|
They can be See also https://codeql.github.com/docs/ql-language-reference/predicates/#binding-sets |
|
Great. Thanks a lot @smowton. I've revamped the functions to take a string parameter, which helps to remove the duplicate code and make the query more clear. |
smowton
left a comment
There was a problem hiding this comment.
Looks good, will get a code-owner review
|
|
||
| import java | ||
|
|
||
| /* Holds if the attribute value is not a cleartext password */ |
There was a problem hiding this comment.
Regular comments should be /** doc comments (here and below)
Storing a plaintext password in a configuration file allows anyone who can read the file to access the password-protected resources. Therefore it is a common attack vector.
This is a common issue with many GitHub repositories. The query detects cleartext passwords stored in XML configuration files.
Please consider to merge the PR. Thanks.