Skip to content

Go: Fix handling of default version in go/insecure-tls - #23080

Draft
owen-mc wants to merge 2 commits into
github:mainfrom
owen-mc:go/insecure-tls-fp
Draft

owen-mc wants to merge 2 commits into
github:mainfrom
owen-mc:go/insecure-tls-fp

Conversation

@owen-mc

@owen-mc owen-mc commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

go/insecure-tls stated that MinVersion = 0 for tls.Config means "lowest supported version". This is wrong: it means the minimum acceptable version. This PR fixes the way that 0 is treated.

I ran variant analysis on 1000 go repos. The version on main had 55 alerts and the version in this PR had 52. I confirmed the 3 lost alerts were FPs of the type intended.

Fixes #23058.

owen-mc and others added 2 commits November 10, 2026 14:29
Stop treating 0 as an insecure or tracked TLS version in go/insecure-tls, since 0 selects Go's default TLS version (TLS 1.2 for MinVersion in modern Go). Update the query help, examples, change note, and regression tests.

Fixes github#23058

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove fieldName from isInsecureTlsVersion and the unused Field parameters from secureTlsVersionFlow and secureTlsVersionFlowsToSink. Update callers and simplify the alert message binding without changing query results.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

QHelp previews:

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

Insecure TLS configuration

The TLS (Transport Layer Security) protocol secures communications over the Internet. The protocol allows client/server applications to communicate in a way that is designed to prevent eavesdropping, tampering, or message forgery.

The current latest version is 1.3 (with the 1.2 version still being considered secure). Older versions are not deemed to be secure anymore because of various security vulnerabilities, and tht makes them unfit for use in securing your applications.

Unfortunately, many applications and websites still support deprecated SSL/TLS versions and cipher suites.

Recommendation

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)

A zero MinVersion, whether explicit or omitted, selects Go's default minimum TLS version. This is TLS 1.2 for clients since Go 1.18 and servers since Go 1.22. When using older Go versions or compatibility settings that allow older TLS versions, set MinVersion to tls.VersionTLS12 or higher explicitly.

Example

The following example shows a few ways how an insecure TLS configuration can be created:

package main

import (
	"crypto/tls"
)

func main() {}

func insecureMinMaxTlsVersion() {
	{
		config := &tls.Config{}
		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{}
		config.MinVersion = tls.VersionSSL30 // BAD: SSL 3.0 is a non-secure version of the protocol; it's not safe to use it as MinVersion.
	}
	{
		config := &tls.Config{}
		config.MaxVersion = tls.VersionSSL30 // BAD: SSL 3.0 is a non-secure version of the protocol; it's not safe to use it as MaxVersion.
	}
}

func insecureCipherSuites() {
	config := &tls.Config{
		CipherSuites: []uint16{
			tls.TLS_RSA_WITH_RC4_128_SHA, // BAD: TLS_RSA_WITH_RC4_128_SHA is one of the non-secure cipher suites; it's not safe to be used.
		},
	}
	_ = config
}

The following example shows how to create a safer TLS configuration:

package main

import "crypto/tls"

func saferTLSConfig() {
	config := &tls.Config{}
	config.MinVersion = tls.VersionTLS12
	config.MaxVersion = tls.VersionTLS13
	// OR
	config.MaxVersion = 0 // GOOD: Setting MaxVersion to 0 means that the highest version available in the package will be used.
}

References

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive: go/insecure-tls is partially wrong

1 participant