]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.25] crypto/x509: improve domain name verification
authorNeal Patel <nealpatel@google.com>
Mon, 15 Sep 2025 20:31:22 +0000 (16:31 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 7 Oct 2025 18:02:15 +0000 (11:02 -0700)
commitf0c69db15aae2eb10bddd8b6745dff5c2932e8f5
tree9e25715cd88ecefeb94be5e53796ecb07cc9d5ab
parent9fd3ac8a10272afd90312fef5d379de7d688a58e
[release-branch.go1.25] crypto/x509: improve domain name verification

Don't use domainToReverseLabels to check if domain names are valid,
since it is not particularly performant, and can contribute to DoS
vectors. Instead just iterate over the name and enforce the properties
we care about.

This also enforces that DNS names, both in SANs and name constraints,
are valid. We previously allowed invalid SANs, because some
intermediates had these weird names (see #23995), but there are
currently no trusted intermediates that have this property, and since we
target the web PKI, supporting this particular case is not a high
priority.

Thank you to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-58187
For #75681
Fixes #75715

Change-Id: I6ebce847dcbe5fc63ef2f9a74f53f11c4c56d3d1
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2820
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2981
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709848
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
src/crypto/x509/name_constraints_test.go
src/crypto/x509/parser.go
src/crypto/x509/parser_test.go
src/crypto/x509/verify.go