Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
crypto/x509: Wildcard Cerficate Validation Weakness #4658
Taking a look at the code for certificate verification, the hostname matching function appears to allow wildcards in IP addresses. I previously reported this issue against FF, Chrome etc. back in 2010. The code that appears vulnerable can be seen at: http://code.google.com/p/go/source/browse/src/pkg/crypto/x509/verify.go#237 http://www.westpoint.ltd.uk/advisories/wp-10-0001.txt
The Go code ignores IP address SANs, so the '*.2.3.4' form would have to appear in the CN or as a DNSName SAN. If the user sets the `hostname' of a TLS connection to the string form of an IP address, then we will match it against such a wildcard. However, setting the hostname to an IP address isn't supported. So I think this bug boils down to "we should try parsing the hostname that the user asked us to verify as an IP address and fail immediately if it looks like one". Do you agree? If, in the future, we support IP addresses like that, we would need to be careful to match only against IP address SANs, but we don't currently support that at all.
Status changed to WaitingForReply.
Note that https://golang.org/cl/7277051/ is effectively a Go 1 API regression, since it breaks anybody using net/http/httptest's NewTLSServer and trying to test against it with httptest.(*Server).URL. Could we keep CL 7277051 but white-list certs using "127.0.0.1" or "[::1]" as subjects? That would keep Go 1 users' tests still working. Is that a security problem for any reason?
Subject Alternative Names in X.509 certificates may include IP addresses. This change adds support for marshaling, unmarshaling and verifying this form of SAN. It also causes IP addresses to only be checked against IP SANs, rather than against hostnames as was previously the case. This reflects RFC 6125. Fixes golang#4658. R=golang-dev, mikioh.mikioh, bradfitz CC=golang-dev https://golang.org/cl/7336046