Skip to content

Commit 19ff00b

Browse files
committed
Enhance the additional step flow and update qldoc
1 parent ce2db21 commit 19ff00b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

java/ql/src/experimental/Security/CWE/CWE-759/HashWithoutSalt.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<qhelp>
33

44
<overview>
5-
<p>In cryptography, "salt" is random data that are used as an additional input to a one-way function that hashes a password or pass-phrase. It makes dictionary attacks more difficult.</p>
5+
<p>In cryptography, a salt is some random data used as an additional input to a one-way function that hashes a password or pass-phrase. It makes dictionary attacks more difficult.</p>
66

77
<p>Without a salt, it is much easier for attackers to pre-compute the hash value using dictionary attack techniques such as rainbow tables to crack passwords.</p>
88
</overview>

java/ql/src/experimental/Security/CWE/CWE-759/HashWithoutSalt.ql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @id java/hash-without-salt
3-
* @name Use of a One-Way Hash without a Salt
2+
* @name Use of a hash function without a salt
43
* @description Hashed passwords without a salt are vulnerable to dictionary attacks.
54
* @kind path-problem
5+
* @id java/hash-without-salt
66
* @tags security
77
* external/cwe-759
88
*/
@@ -11,30 +11,28 @@ import java
1111
import semmle.code.java.dataflow.TaintTracking
1212
import DataFlow::PathGraph
1313

14-
/** The Java class `java.security.MessageDigest` */
14+
/** The Java class `java.security.MessageDigest`. */
1515
class MessageDigest extends RefType {
1616
MessageDigest() { this.hasQualifiedName("java.security", "MessageDigest") }
1717
}
1818

1919
/** The method `digest()` declared in `java.security.MessageDigest`. */
2020
class MDDigestMethod extends Method {
2121
MDDigestMethod() {
22-
getDeclaringType() instanceof MessageDigest and
23-
hasName("digest")
22+
this.getDeclaringType() instanceof MessageDigest and
23+
this.hasName("digest")
2424
}
2525
}
2626

2727
/** The method `update()` declared in `java.security.MessageDigest`. */
2828
class MDUpdateMethod extends Method {
2929
MDUpdateMethod() {
30-
getDeclaringType() instanceof MessageDigest and
31-
hasName("update")
30+
this.getDeclaringType() instanceof MessageDigest and
31+
this.hasName("update")
3232
}
3333
}
3434

35-
/**
36-
* Gets a regular expression for matching common names of variables that indicate the value being held is a password.
37-
*/
35+
/** Gets a regular expression for matching common names of variables that indicate the value being held is a password. */
3836
string getPasswordRegex() { result = "(?i).*pass(wd|word|code|phrase).*" }
3937

4038
/** Finds variables that hold password information judging by their names. */
@@ -78,9 +76,11 @@ class HashWithoutSaltConfiguration extends TaintTracking::Configuration {
7876
)
7977
}
8078

81-
/** Holds for additional steps such as `passwordStr.getBytes()` */
79+
/** Holds for additional steps that flow to a method call of `update` or `digest` declared in `java.security.MessageDigest`. */
8280
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
8381
exists(MethodAccess ma |
82+
ma.getMethod().getDeclaringType() instanceof MessageDigest and
83+
ma.getMethod().hasName(["digest", "update"]) and
8484
pred.asExpr() = ma.getAnArgument() and
8585
(succ.asExpr() = ma or succ.asExpr() = ma.getQualifier())
8686
)

0 commit comments

Comments
 (0)