Skip to content

Commit 3469ad7

Browse files
authored
Merge pull request #3600 from luchua-bc/java-sensitive-log4j2-logging
Add Log4J 2 and a new search string secret
2 parents 8891ae7 + d6e9b07 commit 3469ad7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

java/ql/src/experimental/CWE-532/SensitiveInfoLog.ql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import PathGraph
1717
*/
1818
private string getACredentialRegex() {
1919
result = "(?i).*challenge|pass(wd|word|code|phrase)(?!.*question).*" or
20-
result = "(?i)(.*username|url).*"
20+
result = "(?i)(.*username|.*secret|url).*"
2121
}
2222

2323
/** Variable keeps sensitive information judging by its name * */
@@ -31,8 +31,12 @@ class CredentialExpr extends Expr {
3131
class LoggerType extends RefType {
3232
LoggerType() {
3333
this.hasQualifiedName("org.apache.log4j", "Category") or //Log4J
34+
this.hasQualifiedName("org.apache.logging.log4j", "Logger") or //Log4J 2
3435
this.hasQualifiedName("org.slf4j", "Logger") or //SLF4j and Gradle Logging
35-
this.hasQualifiedName("org.jboss.logging", "BasicLogger") //JBoss Logging
36+
this.hasQualifiedName("org.jboss.logging", "BasicLogger") or //JBoss Logging
37+
this.hasQualifiedName("org.jboss.logging", "Logger") or //JBoss Logging (`org.jboss.logging.Logger` in some implementations like JBoss Application Server 4.0.4 did not implement `BasicLogger`)
38+
this.hasQualifiedName("org.apache.commons.logging", "Log") or //Apache Commons Logging
39+
this.hasQualifiedName("org.scijava.log", "Logger") //SciJava Logging
3640
}
3741
}
3842

@@ -42,7 +46,8 @@ predicate isSensitiveLoggingSink(DataFlow::Node sink) {
4246
(
4347
ma.getMethod().hasName("debug") or
4448
ma.getMethod().hasName("trace") or
45-
ma.getMethod().hasName("debugf")
49+
ma.getMethod().hasName("debugf") or
50+
ma.getMethod().hasName("debugv")
4651
) and //Check low priority log levels which are more likely to be real issues to reduce false positives
4752
sink.asExpr() = ma.getAnArgument()
4853
)

0 commit comments

Comments
 (0)