mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
@@ -28,6 +28,9 @@ where
|
||||
not (
|
||||
sink.getNode().(Sink).(DefaultCredentialsSink).getKind() = "password" and
|
||||
PasswordHeuristics::isDummyPassword(val)
|
||||
or
|
||||
sink.getNode().(Sink).getKind() = "authorization header" and
|
||||
PasswordHeuristics::isDummyAuthHeader(val)
|
||||
) and
|
||||
value = "The hard-coded value \"" + val + "\""
|
||||
)
|
||||
|
||||
@@ -188,4 +188,31 @@ module PasswordHeuristics {
|
||||
normalized.regexpMatch(".*(pass|test|sample|example|secret|root|admin|user|change|auth).*")
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `header` looks like a deliberately weak authentication header.
|
||||
*/
|
||||
bindingset[header]
|
||||
predicate isDummyAuthHeader(string header) {
|
||||
isDummyPassword(header)
|
||||
or
|
||||
exists(string prefix, string suffix | prefix = getAnHTTPAuthenticationScheme() |
|
||||
header.toLowerCase() = prefix + " " + suffix and
|
||||
isDummyPassword(suffix)
|
||||
)
|
||||
or
|
||||
header.trim().toLowerCase() = getAnHTTPAuthenticationScheme()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a HTTP authentication scheme normalized to lowercase.
|
||||
* From this list: https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml
|
||||
*/
|
||||
private string getAnHTTPAuthenticationScheme() {
|
||||
result =
|
||||
[
|
||||
"Basic", "Bearer", "Digest", "HOBA", "Mutual", "Negotiate", "OAuth", "SCRAM-SHA-1",
|
||||
"SCRAM-SHA-256", "vapid"
|
||||
].toLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user