Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit cce3a70

Browse files
committed
Insecure-TLS: restrict sources to potentially interesting integers.
1 parent e89cd16 commit cce3a70

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ql/src/Security/CWE-327/InsecureTLS.ql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ predicate isInsecureTlsVersion(int val, string name, string fieldName) {
3535
)
3636
}
3737

38+
/**
39+
* Returns integers that may represent a TLS version.
40+
*
41+
* Integer values corresponding to versions are defined at https://golang.org/pkg/crypto/tls/#pkg-constants
42+
* Zero means the default version; at the time of writing, TLS 1.0.
43+
*/
44+
int getATlsVersion() { result in [768, 769, 770, 771, 772, 0] }
45+
3846
/**
3947
* Holds if `node` refers to a value returned alongside a non-nil error value.
4048
*
@@ -60,6 +68,7 @@ class TlsVersionFlowConfig extends TaintTracking::Configuration {
6068
*/
6169
predicate isSource(DataFlow::Node source, int val) {
6270
val = source.getIntValue() and
71+
val = getATlsVersion() and
6372
not isReturnedWithError(source)
6473
}
6574

0 commit comments

Comments
 (0)