Skip to content

Commit 12c5b46

Browse files
committed
Reduce FPs
* Restrict allowed types in the flow step * Discard more non-crypto-related TLS APIs
1 parent 05b487e commit 12c5b46

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

go/ql/lib/semmle/go/security/InsecureRandomness.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ module InsecureRandomness {
4949

5050
predicate isAdditionalFlowStep(DataFlow::Node n1, DataFlow::Node n2) {
5151
// Allow flow from tainted indexes to the base expression.
52-
// Randomly selecting a character/substring from a predefined set
52+
// Randomly selecting a character/substring/integer from a predefined set
5353
// with a weak RNG is also a security risk if the result is used in
5454
// a sensitive function.
55-
n1.asExpr() = n2.asExpr().(IndexExpr).getIndex()
55+
n1.asExpr() = n2.asExpr().(IndexExpr).getIndex() and
56+
(
57+
n2.getType() instanceof StringType or
58+
n2.getType() instanceof IntegerType
59+
)
5660
}
5761
}
5862

go/ql/lib/semmle/go/security/InsecureRandomnessCustomizations.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module InsecureRandomness {
5959
not (pkg = "crypto/rand" and name = "Read") and
6060
// `crypto/cipher` APIs for reading/writing encrypted streams
6161
not (pkg = "crypto/cipher" and name = ["Read", "Write"]) and
62+
not (pkg = "crypto/tls" and name = ["Client", "Dial", "DialWithDialer"]) and
6263
// Some interfaces in the `crypto` package are the same as interfaces
6364
// elsewhere, e.g. tls.listener is the same as net.Listener
6465
not fn.hasQualifiedName(nonCryptoInterface(), _) and

0 commit comments

Comments
 (0)