New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto/x509: Insufficient verification of ServerName when certificate is wildcard #27591

Open
int-tt opened this Issue Sep 10, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@int-tt

int-tt commented Sep 10, 2018

What version of Go are you using (go version)?

go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build454871894=/tmp/go-build -gno-record-gcc-switches"

What did you do?

see https://play.golang.org/p/VeX1YzLJKk1
Since it seems that network request can not be done in the play environment, try it locally

As in the sample code above, if the certificate used in the host name of the communication destination is a wild card, since the verification of ServerName specified by tls.Config{ServerName: u} is insufficient, including URLScheme etc. Even though it can pass.

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

Should not display error as hostname incorrect

What did you see instead?

HTTPS request succeed

@FiloSottile FiloSottile added this to the Go1.12 milestone Sep 10, 2018

@FiloSottile FiloSottile self-assigned this Sep 10, 2018

@FiloSottile

This comment has been minimized.

Member

FiloSottile commented Sep 10, 2018

Hmm, yeah that should not succeed, but we can't just apply verifyHostname, as there are a bunch of non-PKI users that put all sorts of things in the SAN (like the CloudSQL foo:bar:name).

However, we can probably make it a requirement for wildcard matching, as wildcards are only meaningfully defined over hostnames.

@gopherbot

This comment has been minimized.

gopherbot commented Sep 10, 2018

Change https://golang.org/cl/131575 mentions this issue: crypto/x509: validate HostName with VerifyHostname function

@int-tt

This comment has been minimized.

int-tt commented Sep 21, 2018

there are a bunch of non-PKI users that put all sorts of things in the SAN (like the CloudSQL foo:bar:name).

oh i didn't know that. thx you for teaching me.

I tried to verify the hostname only when wildcards are used.
https://go-review.googlesource.com/c/go/+/131575

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