Skip to content
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

Add fix for Go x/crypto/ocsp failure case #20181

Merged
merged 3 commits into from
Apr 17, 2023

Conversation

cipherboy
Copy link
Contributor

When calling ocsp.ParseRequest(req, issue) with a non-nil issuer on a ocsp request which unknowingly contains an entry in the BasicOCSPResponse's certs field, Go incorrectly assumes that the issuer is a direct parent of the first certificate in the certs field, discarding the rest.

As documented in the Go issue, this is not a valid assumption and thus causes OCSP verification to fail in Vault with an error like:

bad OCSP signature: crypto/rsa: verification error

which ultimately leads to a cert auth login error of:

no chain matching all constraints could be found for this login certificate

We address this by using the unsafe issuer=nil argument, taking on the task of validating the OCSP response's signature as best we can in the absence of full chain information on either side (both the trusted certificate whose OCSP response we're verifying and the lack of any additional certs the OCSP responder may have sent).

See also: golang/go#59641

@cipherboy cipherboy added bug Used to indicate a potential bug auth/cert Authentication - certificates backport/1.13.x labels Apr 14, 2023
@cipherboy cipherboy added this to the 1.14 milestone Apr 14, 2023
When calling ocsp.ParseRequest(req, issue) with a non-nil issuer on a
ocsp request which _unknowingly_ contains an entry in the
BasicOCSPResponse's certs field, Go incorrectly assumes that the issuer
is a direct parent of the _first_ certificate in the certs field,
discarding the rest.

As documented in the Go issue, this is not a valid assumption and thus
causes OCSP verification to fail in Vault with an error like:

> bad OCSP signature: crypto/rsa: verification error

which ultimately leads to a cert auth login error of:

> no chain matching all constraints could be found for this login certificate

We address this by using the unsafe issuer=nil argument, taking on the
task of validating the OCSP response's signature as best we can in the
absence of full chain information on either side (both the trusted
certificate whose OCSP response we're verifying and the lack of any
additional certs the OCSP responder may have sent).

See also: golang/go#59641

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
@cipherboy cipherboy marked this pull request as ready for review April 17, 2023 14:52
@cipherboy cipherboy requested a review from a team April 17, 2023 14:52
@cipherboy cipherboy force-pushed the cipherboy-fix-ocsp-query-handling branch from ab1a2c4 to 1865054 Compare April 17, 2023 14:52
@cipherboy cipherboy merged commit 17a2827 into main Apr 17, 2023
@cipherboy
Copy link
Contributor Author

Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth/cert Authentication - certificates bug Used to indicate a potential bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants