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

crypto/x509: reconsider the expansion of CertificateRequest #43477

Closed
AGWA opened this issue Jan 3, 2021 · 7 comments
Closed

crypto/x509: reconsider the expansion of CertificateRequest #43477

AGWA opened this issue Jan 3, 2021 · 7 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@AGWA
Copy link

AGWA commented Jan 3, 2021

Go 1.16 adds a number of additional convenience fields to CertificateRequest. I think these fields are a bad idea and should be removed before Go 1.16 is released and these fields have to be supported forever.

Go's Cryptography Principles state that the Go crypto library should be easy to use securely. Unfortunately, there are numerous examples of CAs accidentally copying unverified data from CSR fields into final certificates:

Ingesting CSRs is so error-prone that a prudent CA should be discarding everything in a CSR except the public key. Of course, the library can't prevent people from copying raw extensions out of Extensions, but it could try to avoid nudging people in the wrong direction, and making CSR fields more conveniently accessible seems like a nudge in the wrong direction.

The Cryptography Principles also state that the library should focus on "common use cases." However, the bug which proposed this change (#37172) doesn't explain the use case for taking these fields from CSRs, and received only one positive reaction from a non-Go-teammember. I don't think there's any reason to believe that this is a common use case, particularly in the WebPKI, which crypto/x509 is aimed towards.

I'm particularly alarmed by the addition of the BasicConstraints fields (e.g. IsCA). In a robust PKI, the process for issuing a CA certificate should be distinct from the process for issuing an end-entity certificate. It's not something that should ever be based on the contents of the CSR.

@ALTree ALTree added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 3, 2021
@ALTree
Copy link
Member

ALTree commented Jan 3, 2021

cc @FiloSottile

@FiloSottile
Copy link
Contributor

I admit I did not consider the use case at length when recommending that proposal be approved. My bad.

I agree that applications should not be encouraged to extract any of these values from CSRs. Moreover, if they really need to, they can parse the extensions themselves, which presumably is what they've been doing so far.

I'm in favour of rolling back these new APIs. In practice this would look like removing some code rather than rolling back a commit because the commit also did some refactoring that I tink would be more risky to remove than leave in place.

I assume this needs to be speed-tracked to make the RC?

/cc @golang/proposal-review @golang/release

@rsc
Copy link
Contributor

rsc commented Jan 5, 2021

Please prepare the CL so we can see the change, and make it as small as possible. Thanks.

@rsc rsc added this to the Go1.16 milestone Jan 5, 2021
@gopherbot
Copy link

Change https://golang.org/cl/281235 mentions this issue: crypto/x509: rollback new CertificateRequest fields

@rsc
Copy link
Contributor

rsc commented Jan 6, 2021

I discussed this with proposal review and everyone agrees with rolling this back and using the CL you sent.
No need for more approvals.

@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 6, 2021
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jan 6, 2021
@gopherbot
Copy link

Change https://golang.org/cl/287392 mentions this issue: crypto/x509: remove leftover CertificateRequest field

gopherbot pushed a commit that referenced this issue Jan 27, 2021
Removes the KeyUsage field that was missed in the rollback in
CL 281235.
Also updates CreateCertificateRequest to reflect that these fields
were removed.

For #43407.
Updates #43477.
Updates #37172.

Change-Id: I6244aed4a3ef3c2460c38af5511e5c2e82546179
Reviewed-on: https://go-review.googlesource.com/c/go/+/287392
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/287432 mentions this issue: crypto/x509: rollback new CertificateRequest.KeyUsage field

@golang golang locked and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants