Skip to content

Commit 39103af

Browse files
committed
Remove additional taint step
1 parent b56fe2b commit 39103af

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ class HashWithoutSaltConfiguration extends TaintTracking::Configuration {
5050

5151
override predicate isSink(DataFlow::Node sink) {
5252
exists(
53-
MethodAccess mda, MethodAccess mua // invoke `md.digest()` with only one call of `md.update(password)`, that is, without the call of `md.update(digest)`
53+
MethodAccess mua, MethodAccess mda // invoke `md.digest()` with only one call of `md.update(password)`, that is, without the call of `md.update(digest)`
5454
|
55-
sink.asExpr() = mda.getQualifier() and
55+
sink.asExpr() = mua.getArgument(0) and
56+
mua.getMethod() instanceof MDUpdateMethod and // md.update(password)
5657
mda.getMethod() instanceof MDDigestMethod and
5758
mda.getNumArgument() = 0 and // md.digest()
58-
mua.getMethod() instanceof MDUpdateMethod and // md.update(password)
59-
mua.getQualifier() = mda.getQualifier().(VarAccess).getVariable().getAnAccess() and
59+
mda.getQualifier() = mua.getQualifier().(VarAccess).getVariable().getAnAccess() and
6060
not exists(MethodAccess mua2 |
6161
mua2.getMethod() instanceof MDUpdateMethod and // md.update(salt)
6262
mua2.getQualifier() = mua.getQualifier().(VarAccess).getVariable().getAnAccess() and
@@ -66,7 +66,7 @@ class HashWithoutSaltConfiguration extends TaintTracking::Configuration {
6666
or
6767
// invoke `md.digest(password)` without another call of `md.update(salt)`
6868
exists(MethodAccess mda |
69-
sink.asExpr() = mda and
69+
sink.asExpr() = mda.getArgument(0) and
7070
mda.getMethod() instanceof MDDigestMethod and // md.digest(password)
7171
mda.getNumArgument() = 1 and
7272
not exists(MethodAccess mua |
@@ -75,15 +75,6 @@ class HashWithoutSaltConfiguration extends TaintTracking::Configuration {
7575
)
7676
)
7777
}
78-
79-
/** Holds for additional steps that flow to additional method calls of the type `java.security.MessageDigest`. */
80-
override predicate isAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
81-
exists(MethodAccess ma |
82-
ma.getMethod().getDeclaringType() instanceof MessageDigest and
83-
pred.asExpr() = ma.getAnArgument() and
84-
(succ.asExpr() = ma or succ.asExpr() = ma.getQualifier())
85-
)
86-
}
8778
}
8879

8980
from DataFlow::PathNode source, DataFlow::PathNode sink, HashWithoutSaltConfiguration c
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
edges
2-
| HashWithoutSalt.java:9:36:9:43 | password : String | HashWithoutSalt.java:9:26:9:55 | digest(...) |
3-
| HashWithoutSalt.java:15:13:15:20 | password : String | HashWithoutSalt.java:16:26:16:27 | md |
2+
| HashWithoutSalt.java:9:36:9:43 | password : String | HashWithoutSalt.java:9:36:9:54 | getBytes(...) |
3+
| HashWithoutSalt.java:15:13:15:20 | password : String | HashWithoutSalt.java:15:13:15:31 | getBytes(...) |
44
nodes
5-
| HashWithoutSalt.java:9:26:9:55 | digest(...) | semmle.label | digest(...) |
65
| HashWithoutSalt.java:9:36:9:43 | password : String | semmle.label | password : String |
6+
| HashWithoutSalt.java:9:36:9:54 | getBytes(...) | semmle.label | getBytes(...) |
77
| HashWithoutSalt.java:15:13:15:20 | password : String | semmle.label | password : String |
8-
| HashWithoutSalt.java:16:26:16:27 | md | semmle.label | md |
8+
| HashWithoutSalt.java:15:13:15:31 | getBytes(...) | semmle.label | getBytes(...) |
99
#select
10-
| HashWithoutSalt.java:9:26:9:55 | digest(...) | HashWithoutSalt.java:9:36:9:43 | password : String | HashWithoutSalt.java:9:26:9:55 | digest(...) | $@ is hashed without a salt. | HashWithoutSalt.java:9:36:9:43 | password | The password |
11-
| HashWithoutSalt.java:16:26:16:27 | md | HashWithoutSalt.java:15:13:15:20 | password : String | HashWithoutSalt.java:16:26:16:27 | md | $@ is hashed without a salt. | HashWithoutSalt.java:15:13:15:20 | password | The password |
10+
| HashWithoutSalt.java:9:36:9:54 | getBytes(...) | HashWithoutSalt.java:9:36:9:43 | password : String | HashWithoutSalt.java:9:36:9:54 | getBytes(...) | $@ is hashed without a salt. | HashWithoutSalt.java:9:36:9:43 | password | The password |
11+
| HashWithoutSalt.java:15:13:15:31 | getBytes(...) | HashWithoutSalt.java:15:13:15:20 | password : String | HashWithoutSalt.java:15:13:15:31 | getBytes(...) | $@ is hashed without a salt. | HashWithoutSalt.java:15:13:15:20 | password | The password |

0 commit comments

Comments
 (0)