diff --git a/go/ql/src/Security/CWE-327/InsecureTLS.go b/go/ql/src/Security/CWE-327/InsecureTLS.go
index 41235c8b4eec..9542a362a48c 100644
--- a/go/ql/src/Security/CWE-327/InsecureTLS.go
+++ b/go/ql/src/Security/CWE-327/InsecureTLS.go
@@ -9,7 +9,7 @@ func main() {}
func insecureMinMaxTlsVersion() {
{
config := &tls.Config{}
- config.MinVersion = 0 // BAD: Setting the MinVersion to 0 equals to choosing the lowest supported version (i.e. SSL3.0)
+ config.MinVersion = tls.VersionTLS10 // BAD: TLS 1.0 is a non-secure version of the protocol; it's not safe to use it as MinVersion.
}
{
config := &tls.Config{}
diff --git a/go/ql/src/Security/CWE-327/InsecureTLS.qhelp b/go/ql/src/Security/CWE-327/InsecureTLS.qhelp
index 43b95ccfca4b..123b7ddd918b 100644
--- a/go/ql/src/Security/CWE-327/InsecureTLS.qhelp
+++ b/go/ql/src/Security/CWE-327/InsecureTLS.qhelp
@@ -23,6 +23,12 @@
Only use secure TLS versions (1.3 and 1.2) and avoid using insecure cipher suites
(you can see a list here: https://golang.org/src/crypto/tls/cipher_suites.go#L81)
+
diff --git a/go/ql/src/Security/CWE-327/InsecureTLS.ql b/go/ql/src/Security/CWE-327/InsecureTLS.ql
index 559af3060c1d..764ec6d093a8 100644
--- a/go/ql/src/Security/CWE-327/InsecureTLS.ql
+++ b/go/ql/src/Security/CWE-327/InsecureTLS.ql
@@ -16,24 +16,17 @@ import semmle.go.security.InsecureFeatureFlag::InsecureFeatureFlag
private import semmle.go.controlflow.Guards
/**
- * Holds if it is insecure to assign TLS version `val` named `name` to `tls.Config` field `fieldName`.
+ * Holds if `val` is the integer value of an insecure TLS version constant named `name`.
*/
-predicate isInsecureTlsVersion(int val, string name, string fieldName) {
- (fieldName = "MinVersion" or fieldName = "MaxVersion") and
- (
- // tls.VersionSSL30
- val = 768 and name = "VersionSSL30"
- or
- // tls.VersionTLS10
- val = 769 and name = "VersionTLS10"
- or
- // tls.VersionTLS11
- val = 770 and name = "VersionTLS11"
- or
- // Zero indicates the lowest available version setting for MinVersion,
- // or the highest available version setting for MaxVersion.
- val = 0 and name = "" and fieldName = "MinVersion"
- )
+predicate isInsecureTlsVersion(int val, string name) {
+ // tls.VersionSSL30
+ val = 768 and name = "VersionSSL30"
+ or
+ // tls.VersionTLS10
+ val = 769 and name = "VersionTLS10"
+ or
+ // tls.VersionTLS11
+ val = 770 and name = "VersionTLS11"
}
/**
@@ -47,9 +40,9 @@ int getASecureTlsVersion() {
* Returns integers that may represent a TLS version.
*
* Integer values corresponding to versions are defined at https://golang.org/pkg/crypto/tls/#pkg-constants
- * Zero means the default version; at the time of writing, TLS 1.0.
+ * Zero selects the default version for the relevant field and is not tracked.
*/
-int getATlsVersion() { result = getASecureTlsVersion() or isInsecureTlsVersion(result, _, _) }
+int getATlsVersion() { result = getASecureTlsVersion() or isInsecureTlsVersion(result, _) }
module TlsVersionFlowConfig implements DataFlow::ConfigSig {
/**
@@ -81,29 +74,27 @@ module TlsVersionFlowConfig implements DataFlow::ConfigSig {
module TlsVersionFlow = TaintTracking::Global;
/**
- * Holds if `config` exhibits a secure TLS version flowing from `source` to `sink`, which flows into `fld`.
+ * Holds if a secure TLS version flows from `source` to `sink`.
*/
-predicate secureTlsVersionFlow(DataFlow::Node source, DataFlow::Node sink, Field fld) {
+predicate secureTlsVersionFlow(DataFlow::Node source, DataFlow::Node sink) {
exists(int version |
TlsVersionFlow::flow(source, sink) and
TlsVersionFlowConfig::intIsSource(source, version) and
- not isInsecureTlsVersion(version, _, fld.getName())
+ not isInsecureTlsVersion(version, _)
)
}
/**
- * Holds if a secure TLS version reaches `sink`, which flows into `fld`.
+ * Holds if a secure TLS version reaches `sink`.
*/
-predicate secureTlsVersionFlowsToSink(DataFlow::Node sink, Field fld) {
- secureTlsVersionFlow(_, sink, fld)
-}
+predicate secureTlsVersionFlowsToSink(DataFlow::Node sink) { secureTlsVersionFlow(_, sink) }
/**
* Holds if a secure TLS version may reach `accessPath`.`fld`
*/
predicate secureTlsVersionFlowsToField(SsaWithFields accessPath, Field fld) {
exists(DataFlow::Node sink, DataFlow::Node base |
- secureTlsVersionFlow(_, sink, fld) and
+ secureTlsVersionFlow(_, sink) and
TlsVersionFlowConfig::isSink(sink, fld, base, _) and
accessPath.getAUse() = base
)
@@ -125,29 +116,22 @@ predicate isInsecureTlsVersionFlow(
TlsVersionFlow::PathNode source, TlsVersionFlow::PathNode sink, string message,
DataFlow::Node base
) {
- exists(int version, Field fld |
+ exists(int version, string name, Field fld |
TlsVersionFlow::flowPath(source, sink) and
TlsVersionFlowConfig::intIsSource(source.getNode(), version) and
TlsVersionFlowConfig::isSink(sink.getNode(), fld, base, _) and
- isInsecureTlsVersion(version, _, fld.getName()) and
+ isInsecureTlsVersion(version, name) and
// Exclude cases where a secure TLS version can also flow to the same
// sink, or to different sinks that refer to the same base and field,
// which suggests a configurable security mode.
- not secureTlsVersionFlowsToSink(sink.getNode(), fld) and
+ not secureTlsVersionFlowsToSink(sink.getNode()) and
not exists(SsaWithFields insecureAccessPath, SsaWithFields secureAccessPath |
nodeOrDeref(insecureAccessPath.getAUse()) = base and
secureAccessPath = insecureAccessPath.similar()
|
secureTlsVersionFlowsToField(secureAccessPath, fld)
- )
- |
- version = 0 and
- message = "Using lowest TLS version for " + fld + "."
- or
- version != 0 and
- exists(string name | isInsecureTlsVersion(version, name, _) |
- message = "Using insecure TLS version " + name + " for " + fld + "."
- )
+ ) and
+ message = "Using insecure TLS version " + name + " for " + fld + "."
)
}
diff --git a/go/ql/src/change-notes/2026-11-10-insecure-tls-default.md b/go/ql/src/change-notes/2026-11-10-insecure-tls-default.md
new file mode 100644
index 000000000000..fce8e2a8e646
--- /dev/null
+++ b/go/ql/src/change-notes/2026-11-10-insecure-tls-default.md
@@ -0,0 +1,4 @@
+---
+category: minorAnalysis
+---
+* The query `go/insecure-tls` ("Insecure TLS configuration") no longer flags a zero `tls.Config.MinVersion`, which selects Go's default minimum TLS version rather than an explicitly insecure version. Insecure `tls.Config.MaxVersion` values are also now reported even when `0` may also flow to `MaxVersion`.
diff --git a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.expected b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.expected
index 539e1070af88..c888a5a829cd 100644
--- a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.expected
+++ b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.expected
@@ -1,6 +1,4 @@
#select
-| UnsafeTLS.go:21:23:21:23 | 0 | UnsafeTLS.go:21:23:21:23 | 0 | UnsafeTLS.go:21:23:21:23 | 0 | Using lowest TLS version for MinVersion. |
-| UnsafeTLS.go:30:16:30:16 | 0 | UnsafeTLS.go:30:16:30:16 | 0 | UnsafeTLS.go:30:16:30:16 | 0 | Using lowest TLS version for MinVersion. |
| UnsafeTLS.go:43:23:43:38 | selection of VersionSSL30 | UnsafeTLS.go:43:23:43:38 | selection of VersionSSL30 | UnsafeTLS.go:43:23:43:38 | selection of VersionSSL30 | Using insecure TLS version VersionSSL30 for MinVersion. |
| UnsafeTLS.go:47:23:47:38 | selection of VersionSSL30 | UnsafeTLS.go:47:23:47:38 | selection of VersionSSL30 | UnsafeTLS.go:47:23:47:38 | selection of VersionSSL30 | Using insecure TLS version VersionSSL30 for MaxVersion. |
| UnsafeTLS.go:52:23:52:38 | selection of VersionTLS10 | UnsafeTLS.go:52:23:52:38 | selection of VersionTLS10 | UnsafeTLS.go:52:23:52:38 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
@@ -11,9 +9,9 @@
| UnsafeTLS.go:76:16:76:31 | selection of VersionTLS11 | UnsafeTLS.go:76:16:76:31 | selection of VersionTLS11 | UnsafeTLS.go:76:16:76:31 | selection of VersionTLS11 | Using insecure TLS version VersionTLS11 for MaxVersion. |
| UnsafeTLS.go:95:16:95:21 | 0x0300 | UnsafeTLS.go:95:16:95:21 | 0x0300 | UnsafeTLS.go:95:16:95:21 | 0x0300 | Using insecure TLS version VersionSSL30 for MinVersion. |
| UnsafeTLS.go:101:16:101:21 | 0x0301 | UnsafeTLS.go:101:16:101:21 | 0x0301 | UnsafeTLS.go:101:16:101:21 | 0x0301 | Using insecure TLS version VersionTLS10 for MaxVersion. |
-| UnsafeTLS.go:111:16:111:16 | 0 | UnsafeTLS.go:111:16:111:16 | 0 | UnsafeTLS.go:111:16:111:16 | 0 | Using lowest TLS version for MinVersion. |
-| UnsafeTLS.go:201:17:201:17 | 0 | UnsafeTLS.go:201:17:201:17 | 0 | UnsafeTLS.go:201:17:201:17 | 0 | Using lowest TLS version for MinVersion. |
-| UnsafeTLS.go:219:17:219:17 | 0 | UnsafeTLS.go:219:17:219:17 | 0 | UnsafeTLS.go:219:17:219:17 | 0 | Using lowest TLS version for MinVersion. |
+| UnsafeTLS.go:111:16:111:31 | selection of VersionTLS10 | UnsafeTLS.go:111:16:111:31 | selection of VersionTLS10 | UnsafeTLS.go:111:16:111:31 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:201:17:201:32 | selection of VersionTLS10 | UnsafeTLS.go:201:17:201:32 | selection of VersionTLS10 | UnsafeTLS.go:201:17:201:32 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:219:17:219:32 | selection of VersionTLS10 | UnsafeTLS.go:219:17:219:32 | selection of VersionTLS10 | UnsafeTLS.go:219:17:219:32 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
| UnsafeTLS.go:259:18:266:4 | slice literal | UnsafeTLS.go:260:5:260:32 | selection of TLS_RSA_WITH_RC4_128_SHA | UnsafeTLS.go:259:18:266:4 | slice literal | Use of an insecure cipher suite: TLS_RSA_WITH_RC4_128_SHA. |
| UnsafeTLS.go:259:18:266:4 | slice literal | UnsafeTLS.go:261:5:261:39 | selection of TLS_RSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:259:18:266:4 | slice literal | Use of an insecure cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256. |
| UnsafeTLS.go:259:18:266:4 | slice literal | UnsafeTLS.go:262:5:262:40 | selection of TLS_ECDHE_ECDSA_WITH_RC4_128_SHA | UnsafeTLS.go:259:18:266:4 | slice literal | Use of an insecure cipher suite: TLS_ECDHE_ECDSA_WITH_RC4_128_SHA. |
@@ -33,6 +31,20 @@
| UnsafeTLS.go:362:18:364:4 | slice literal | UnsafeTLS.go:363:5:363:47 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:362:18:364:4 | slice literal | Use of an insecure cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256. |
| UnsafeTLS.go:432:19:434:5 | slice literal | UnsafeTLS.go:433:6:433:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:432:19:434:5 | slice literal | Use of an insecure cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256. |
| UnsafeTLS.go:456:19:458:5 | slice literal | UnsafeTLS.go:457:6:457:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:456:19:458:5 | slice literal | Use of an insecure cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256. |
+| UnsafeTLS.go:490:16:490:22 | version | UnsafeTLS.go:487:14:487:29 | selection of VersionTLS10 | UnsafeTLS.go:490:16:490:22 | version | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:499:24:499:39 | selection of VersionTLS10 | UnsafeTLS.go:499:24:499:39 | selection of VersionTLS10 | UnsafeTLS.go:499:24:499:39 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:509:16:509:22 | version | UnsafeTLS.go:506:14:506:29 | selection of VersionTLS10 | UnsafeTLS.go:509:16:509:22 | version | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:522:16:522:22 | version | UnsafeTLS.go:517:14:517:29 | selection of VersionSSL30 | UnsafeTLS.go:522:16:522:22 | version | Using insecure TLS version VersionSSL30 for MinVersion. |
+| UnsafeTLS.go:522:16:522:22 | version | UnsafeTLS.go:519:14:519:29 | selection of VersionTLS10 | UnsafeTLS.go:522:16:522:22 | version | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:528:23:528:38 | selection of VersionTLS10 | UnsafeTLS.go:528:23:528:38 | selection of VersionTLS10 | UnsafeTLS.go:528:23:528:38 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:533:23:533:38 | selection of VersionTLS10 | UnsafeTLS.go:533:23:533:38 | selection of VersionTLS10 | UnsafeTLS.go:533:23:533:38 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MinVersion. |
+| UnsafeTLS.go:543:16:543:22 | version | UnsafeTLS.go:540:14:540:29 | selection of VersionTLS10 | UnsafeTLS.go:543:16:543:22 | version | Using insecure TLS version VersionTLS10 for MaxVersion. |
+| UnsafeTLS.go:552:24:552:39 | selection of VersionTLS10 | UnsafeTLS.go:552:24:552:39 | selection of VersionTLS10 | UnsafeTLS.go:552:24:552:39 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MaxVersion. |
+| UnsafeTLS.go:562:16:562:22 | version | UnsafeTLS.go:559:14:559:29 | selection of VersionTLS10 | UnsafeTLS.go:562:16:562:22 | version | Using insecure TLS version VersionTLS10 for MaxVersion. |
+| UnsafeTLS.go:575:16:575:22 | version | UnsafeTLS.go:570:14:570:29 | selection of VersionSSL30 | UnsafeTLS.go:575:16:575:22 | version | Using insecure TLS version VersionSSL30 for MaxVersion. |
+| UnsafeTLS.go:575:16:575:22 | version | UnsafeTLS.go:572:14:572:29 | selection of VersionTLS10 | UnsafeTLS.go:575:16:575:22 | version | Using insecure TLS version VersionTLS10 for MaxVersion. |
+| UnsafeTLS.go:581:23:581:38 | selection of VersionTLS10 | UnsafeTLS.go:581:23:581:38 | selection of VersionTLS10 | UnsafeTLS.go:581:23:581:38 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MaxVersion. |
+| UnsafeTLS.go:586:23:586:38 | selection of VersionTLS10 | UnsafeTLS.go:586:23:586:38 | selection of VersionTLS10 | UnsafeTLS.go:586:23:586:38 | selection of VersionTLS10 | Using insecure TLS version VersionTLS10 for MaxVersion. |
edges
| UnsafeTLS.go:131:14:131:29 | selection of VersionTLS13 | UnsafeTLS.go:136:16:136:22 | version | provenance | |
| UnsafeTLS.go:133:14:133:29 | selection of VersionSSL30 | UnsafeTLS.go:136:16:136:22 | version | provenance | |
@@ -86,15 +98,21 @@ edges
| UnsafeTLS.go:443:6:443:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:442:19:444:5 | slice literal | provenance | |
| UnsafeTLS.go:450:6:450:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:449:19:451:5 | slice literal | provenance | |
| UnsafeTLS.go:457:6:457:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | UnsafeTLS.go:456:19:458:5 | slice literal | provenance | |
+| UnsafeTLS.go:487:14:487:29 | selection of VersionTLS10 | UnsafeTLS.go:490:16:490:22 | version | provenance | |
+| UnsafeTLS.go:506:14:506:29 | selection of VersionTLS10 | UnsafeTLS.go:509:16:509:22 | version | provenance | |
+| UnsafeTLS.go:517:14:517:29 | selection of VersionSSL30 | UnsafeTLS.go:522:16:522:22 | version | provenance | |
+| UnsafeTLS.go:519:14:519:29 | selection of VersionTLS10 | UnsafeTLS.go:522:16:522:22 | version | provenance | |
+| UnsafeTLS.go:540:14:540:29 | selection of VersionTLS10 | UnsafeTLS.go:543:16:543:22 | version | provenance | |
+| UnsafeTLS.go:559:14:559:29 | selection of VersionTLS10 | UnsafeTLS.go:562:16:562:22 | version | provenance | |
+| UnsafeTLS.go:570:14:570:29 | selection of VersionSSL30 | UnsafeTLS.go:575:16:575:22 | version | provenance | |
+| UnsafeTLS.go:572:14:572:29 | selection of VersionTLS10 | UnsafeTLS.go:575:16:575:22 | version | provenance | |
+| UnsafeTLS.go:591:14:591:29 | selection of VersionTLS13 | UnsafeTLS.go:596:16:596:22 | version | provenance | |
+| UnsafeTLS.go:593:14:593:29 | selection of VersionTLS10 | UnsafeTLS.go:596:16:596:22 | version | provenance | |
models
| 1 | Summary: ; ; false; append; ; ; Argument[0].ArrayElement; ReturnValue.ArrayElement; value; manual |
| 2 | Summary: ; ; false; append; ; ; Argument[0]; ReturnValue; taint; manual |
| 3 | Summary: ; ; false; append; ; ; Argument[1].ArrayElement; ReturnValue.ArrayElement; value; manual |
nodes
-| UnsafeTLS.go:21:23:21:23 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:25:23:25:23 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:30:16:30:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:36:16:36:16 | 0 | semmle.label | 0 |
| UnsafeTLS.go:43:23:43:38 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
| UnsafeTLS.go:47:23:47:38 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
| UnsafeTLS.go:52:23:52:38 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
@@ -107,9 +125,9 @@ nodes
| UnsafeTLS.go:88:16:88:31 | selection of VersionTLS13 | semmle.label | selection of VersionTLS13 |
| UnsafeTLS.go:95:16:95:21 | 0x0300 | semmle.label | 0x0300 |
| UnsafeTLS.go:101:16:101:21 | 0x0301 | semmle.label | 0x0301 |
-| UnsafeTLS.go:111:16:111:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:117:16:117:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:123:16:123:16 | 0 | semmle.label | 0 |
+| UnsafeTLS.go:111:16:111:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:117:16:117:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:123:16:123:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
| UnsafeTLS.go:131:14:131:29 | selection of VersionTLS13 | semmle.label | selection of VersionTLS13 |
| UnsafeTLS.go:133:14:133:29 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
| UnsafeTLS.go:136:16:136:22 | version | semmle.label | version |
@@ -117,20 +135,20 @@ nodes
| UnsafeTLS.go:146:24:146:39 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
| UnsafeTLS.go:154:24:154:39 | selection of VersionTLS13 | semmle.label | selection of VersionTLS13 |
| UnsafeTLS.go:156:24:156:39 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
-| UnsafeTLS.go:163:16:163:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:170:16:170:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:177:31:177:31 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:183:29:183:29 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:191:17:191:17 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:196:17:196:17 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:201:17:201:17 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:209:17:209:17 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:214:17:214:17 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:219:17:219:17 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:227:16:227:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:236:16:236:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:243:16:243:16 | 0 | semmle.label | 0 |
-| UnsafeTLS.go:250:16:250:16 | 0 | semmle.label | 0 |
+| UnsafeTLS.go:163:16:163:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:170:16:170:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:177:31:177:46 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:183:29:183:44 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:191:17:191:32 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:196:17:196:32 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:201:17:201:32 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:209:17:209:32 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:214:17:214:32 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:219:17:219:32 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:227:16:227:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:236:16:236:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:243:16:243:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:250:16:250:31 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
| UnsafeTLS.go:259:18:266:4 | slice literal | semmle.label | slice literal |
| UnsafeTLS.go:260:5:260:32 | selection of TLS_RSA_WITH_RC4_128_SHA | semmle.label | selection of TLS_RSA_WITH_RC4_128_SHA |
| UnsafeTLS.go:261:5:261:39 | selection of TLS_RSA_WITH_AES_128_CBC_SHA256 | semmle.label | selection of TLS_RSA_WITH_AES_128_CBC_SHA256 |
@@ -199,4 +217,27 @@ nodes
| UnsafeTLS.go:450:6:450:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | semmle.label | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 |
| UnsafeTLS.go:456:19:458:5 | slice literal | semmle.label | slice literal |
| UnsafeTLS.go:457:6:457:48 | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 | semmle.label | selection of TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 |
+| UnsafeTLS.go:487:14:487:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:490:16:490:22 | version | semmle.label | version |
+| UnsafeTLS.go:499:24:499:39 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:506:14:506:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:509:16:509:22 | version | semmle.label | version |
+| UnsafeTLS.go:517:14:517:29 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
+| UnsafeTLS.go:519:14:519:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:522:16:522:22 | version | semmle.label | version |
+| UnsafeTLS.go:528:23:528:38 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:533:23:533:38 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:540:14:540:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:543:16:543:22 | version | semmle.label | version |
+| UnsafeTLS.go:552:24:552:39 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:559:14:559:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:562:16:562:22 | version | semmle.label | version |
+| UnsafeTLS.go:570:14:570:29 | selection of VersionSSL30 | semmle.label | selection of VersionSSL30 |
+| UnsafeTLS.go:572:14:572:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:575:16:575:22 | version | semmle.label | version |
+| UnsafeTLS.go:581:23:581:38 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:586:23:586:38 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:591:14:591:29 | selection of VersionTLS13 | semmle.label | selection of VersionTLS13 |
+| UnsafeTLS.go:593:14:593:29 | selection of VersionTLS10 | semmle.label | selection of VersionTLS10 |
+| UnsafeTLS.go:596:16:596:22 | version | semmle.label | version |
subpaths
diff --git a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go
index 5a91077e5559..4f4220e59713 100644
--- a/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go
+++ b/go/ql/test/query-tests/Security/CWE-327/UnsafeTLS.go
@@ -18,7 +18,7 @@ func oldVersionFunc() bool {
func minMaxTlsVersion() {
{
config := &tls.Config{}
- config.MinVersion = 0 // $ Alert[go/insecure-tls] // BAD
+ config.MinVersion = 0 // GOOD (uses the default minimum version)
}
{
config := &tls.Config{}
@@ -27,7 +27,7 @@ func minMaxTlsVersion() {
///
{
config := &tls.Config{
- MinVersion: 0, // $ Alert[go/insecure-tls] // BAD
+ MinVersion: 0, // GOOD (uses the default minimum version)
}
_ = config
}
@@ -108,19 +108,19 @@ func minMaxTlsVersion() {
oldVersionFlag := len(os.Args) > 3
if unknown {
config := &tls.Config{
- MinVersion: 0, // $ Alert[go/insecure-tls] // BAD
+ MinVersion: tls.VersionTLS10, // $ Alert[go/insecure-tls] // BAD
}
_ = config
}
if insecureFlag {
config := &tls.Config{
- MinVersion: 0, // OK (guarded by a flag suggesting deliberate insecurity)
+ MinVersion: tls.VersionTLS10, // OK (guarded by a flag suggesting deliberate insecurity)
}
_ = config
}
if oldVersionFlag {
config := &tls.Config{
- MinVersion: 0, // OK (guarded by a flag suggesting deliberate legacy support)
+ MinVersion: tls.VersionTLS10, // OK (guarded by a flag suggesting deliberate legacy support)
}
_ = config
}
@@ -160,27 +160,27 @@ func minMaxTlsVersion() {
///
{
insecureConfig := &tls.Config{
- MinVersion: 0, // OK (var name suggests deliberate insecurity)
+ MinVersion: tls.VersionTLS10, // OK (var name suggests deliberate insecurity)
}
_ = insecureConfig
}
///
{
legacyConfig := &tls.Config{
- MinVersion: 0, // OK (var name suggests deliberate legacy support)
+ MinVersion: tls.VersionTLS10, // OK (var name suggests deliberate legacy support)
}
_ = legacyConfig
}
///
{
var insecureConfig tls.Config
- insecureConfig.MinVersion = 0 // OK (var name suggests deliberate insecurity)
+ insecureConfig.MinVersion = tls.VersionTLS10 // OK (var name suggests deliberate insecurity)
_ = insecureConfig
}
///
{
var legacyConfig tls.Config
- legacyConfig.MinVersion = 0 // OK (var name suggests deliberate legacy support)
+ legacyConfig.MinVersion = tls.VersionTLS10 // OK (var name suggests deliberate legacy support)
_ = legacyConfig
}
///
@@ -188,17 +188,17 @@ func minMaxTlsVersion() {
switch unknown {
case oldVersionFlag:
config := &tls.Config{
- MinVersion: 0, // OK (switch-case name suggests legacy support)
+ MinVersion: tls.VersionTLS10, // OK (switch-case name suggests legacy support)
}
_ = config
case insecureFlag:
config := &tls.Config{
- MinVersion: 0, // OK (switch-case name suggests insecurity)
+ MinVersion: tls.VersionTLS10, // OK (switch-case name suggests insecurity)
}
_ = config
default:
config := &tls.Config{
- MinVersion: 0, // $ Alert[go/insecure-tls] // BAD
+ MinVersion: tls.VersionTLS10, // $ Alert[go/insecure-tls] // BAD
}
_ = config
}
@@ -206,17 +206,17 @@ func minMaxTlsVersion() {
switch os.Args[0] {
case "oldVersionFlag":
config := &tls.Config{
- MinVersion: 0, // OK (switch-case name suggests legacy support)
+ MinVersion: tls.VersionTLS10, // OK (switch-case name suggests legacy support)
}
_ = config
case "insecureFlag":
config := &tls.Config{
- MinVersion: 0, // OK (switch-case name suggests insecurity)
+ MinVersion: tls.VersionTLS10, // OK (switch-case name suggests insecurity)
}
_ = config
default:
config := &tls.Config{
- MinVersion: 0, // $ Alert[go/insecure-tls] // BAD
+ MinVersion: tls.VersionTLS10, // $ Alert[go/insecure-tls] // BAD
}
_ = config
}
@@ -224,7 +224,7 @@ func minMaxTlsVersion() {
///
if insecureFunc() {
config := &tls.Config{
- MinVersion: 0, // OK (guarded by function call suggesting deliberate insecurity)
+ MinVersion: tls.VersionTLS10, // OK (guarded by function call suggesting deliberate insecurity)
}
_ = config
}
@@ -233,21 +233,21 @@ func minMaxTlsVersion() {
isInsecurePtr := &isInsecure
if *isInsecurePtr {
config := &tls.Config{
- MinVersion: 0, // OK (guarded by pointer deref suggesting deliberate insecurity)
+ MinVersion: tls.VersionTLS10, // OK (guarded by pointer deref suggesting deliberate insecurity)
}
_ = config
}
///
if os.Getenv("DISABLE_TLS_VERIFICATION") == "true" {
config := &tls.Config{
- MinVersion: 0, // OK (guarded by environment variable)
+ MinVersion: tls.VersionTLS10, // OK (guarded by environment variable)
}
_ = config
}
///
if isInsecure == true {
config := &tls.Config{
- MinVersion: 0, // OK (guarded by comparison)
+ MinVersion: tls.VersionTLS10, // OK (guarded by comparison)
}
_ = config
}
@@ -461,3 +461,140 @@ func cipherSuites() {
}
}
}
+
+func defaultTlsVersion() {
+ {
+ config := &tls.Config{} // GOOD (omitted versions use the defaults)
+ _ = config
+ }
+ {
+ var config tls.Config // GOOD (zero-valued versions use the defaults)
+ _ = config
+ }
+ {
+ version := uint16(0)
+ config := &tls.Config{
+ MinVersion: version, // GOOD (uses the default minimum version)
+ MaxVersion: version, // GOOD (uses the default maximum version)
+ }
+ _ = config
+ }
+ {
+ var version uint16
+ if len(os.Args) > 1 {
+ version = 0
+ } else {
+ version = tls.VersionTLS10 // $ Source[go/insecure-tls] // BAD
+ }
+ config := &tls.Config{
+ MinVersion: version, // $ Alert[go/insecure-tls]
+ }
+ _ = config
+ }
+ {
+ config := &tls.Config{}
+ if len(os.Args) > 1 {
+ config.MinVersion = 0
+ } else {
+ config.MinVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD
+ }
+ _ = config
+ }
+ {
+ var version uint16
+ if len(os.Args) > 1 {
+ version = tls.VersionTLS10 // $ Source[go/insecure-tls] // BAD
+ }
+ config := &tls.Config{
+ MinVersion: version, // $ Alert[go/insecure-tls]
+ }
+ _ = config
+ }
+ {
+ var version uint16
+ switch os.Args[0] {
+ case "ssl3":
+ version = tls.VersionSSL30 // $ Source[go/insecure-tls] // BAD
+ case "tls10":
+ version = tls.VersionTLS10 // $ Source[go/insecure-tls] // BAD
+ }
+ config := &tls.Config{
+ MinVersion: version, // $ Alert[go/insecure-tls]
+ }
+ _ = config
+ }
+ {
+ config := &tls.Config{MinVersion: 0}
+ config.MinVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD
+ }
+ {
+ config := &tls.Config{}
+ config.MinVersion = 0
+ config.MinVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD
+ }
+ {
+ var version uint16
+ if len(os.Args) > 1 {
+ version = 0
+ } else {
+ version = tls.VersionTLS10 // $ Source[go/insecure-tls] // BAD
+ }
+ config := &tls.Config{
+ MaxVersion: version, // $ Alert[go/insecure-tls]
+ }
+ _ = config
+ }
+ {
+ config := &tls.Config{}
+ if len(os.Args) > 1 {
+ config.MaxVersion = 0
+ } else {
+ config.MaxVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD
+ }
+ _ = config
+ }
+ {
+ var version uint16
+ if len(os.Args) > 1 {
+ version = tls.VersionTLS10 // $ Source[go/insecure-tls] // BAD
+ }
+ config := &tls.Config{
+ MaxVersion: version, // $ Alert[go/insecure-tls]
+ }
+ _ = config
+ }
+ {
+ var version uint16
+ switch os.Args[0] {
+ case "ssl3":
+ version = tls.VersionSSL30 // $ Source[go/insecure-tls] // BAD
+ case "tls10":
+ version = tls.VersionTLS10 // $ Source[go/insecure-tls] // BAD
+ }
+ config := &tls.Config{
+ MaxVersion: version, // $ Alert[go/insecure-tls]
+ }
+ _ = config
+ }
+ {
+ config := &tls.Config{MaxVersion: 0}
+ config.MaxVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD
+ }
+ {
+ config := &tls.Config{}
+ config.MaxVersion = 0
+ config.MaxVersion = tls.VersionTLS10 // $ Alert[go/insecure-tls] // BAD
+ }
+ {
+ var version uint16
+ if len(os.Args) > 1 {
+ version = tls.VersionTLS13
+ } else {
+ version = tls.VersionTLS10 // OK (flows together with a modern version, suggesting configurable security)
+ }
+ config := &tls.Config{
+ MaxVersion: version,
+ }
+ _ = config
+ }
+}