Change information
Commit message:
crypto/x509: fix signature checking limit
We added the "is this cert already in the chain" check (alreadyInChain)
to considerCandidates before the signature limit. considerCandidates
bails out when we exceed the signature check, but buildChains keeps
calling considerCandidates until it exhausts all potential parents. In
the case where a large number of certificates look to have signed each
other (e.g. all have subject==issuerSubject and the same key),
alreadyInChain is not particularly cheap, meaning even though we hit our
"this is too much work" limit, we still do a lot of work.
Move alreadyInChain after the signature limit, and also return a
sentinel error, and check it in buildChains so we can break out of the
loop early if we aren't actually going to do any more work.
Thanks to Jakub Ciolek for reporting this issue.
Fixes #78282
Fixes CVE-2026-32280
Change-Id: Ie6f05c6ba3b0a40c21f64f7c4f846e74fae3b10e
Files:
- M src/crypto/x509/verify.go
- M src/crypto/x509/verify_test.go
Change size: M
Delta: 2 files changed, 96 insertions(+), 85 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +2 by Damien Neil, +1 by Jakub Ciolek, +2 by Neal Patel
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI