-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: error parsing large ASN.1 identifiers #49678
Comments
Bug is inside golang.org/x/crypto/cryptobyte/asn1.go |
Change https://golang.org/cl/365674 mentions this issue: |
Hi, i have the same problem when i try to pull image from our internal docker repository:
Our private CA certificate’s are added to system. And wget/curl connects to https://private_repo/v2/ without problems. |
@heschi How long can an investigation take? |
@gopherbot please open a backport issue to Go 1.17. This is a regression due to Go 1.17 changes without workaround that makes it impossible to parse some valid (if a little weird) certificates. |
Backport issue(s) opened: #50165 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/372274 mentions this issue: |
…1 OIDs Updates golang/go#49678 For golang/go#50165 Change-Id: If8a40e25edd810a66165ab78dd68d9b7fc2699f8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/365674 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Trust: Alex Rakoczy <alex@golang.org> Trust: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit e495a2d) Reviewed-on: https://go-review.googlesource.com/c/crypto/+/372274 Trust: Filippo Valsorda <filippo@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
Nice work @umlublin for the report and for the fix too! Thank you @FiloSottile for the cherry picks. @FiloSottile given that we've merged the fix into both master and go1.17-vendor branches, what else is left for us to do to close this issue for Go1.18? |
Change https://golang.org/cl/373360 mentions this issue: |
Change https://golang.org/cl/373361 mentions this issue: |
…cryptobyte fix Updates #49678 Fixes #50165 Change-Id: I47dd959a787180a67856e60dfa6eba3ddd045972 Reviewed-on: https://go-review.googlesource.com/c/go/+/373361 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Julie Qiu <julie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
@FiloSottile This seems to impact Go 1.16 as well. I haven't tested myself, but we have a bug report in Vault (hashicorp/vault#14122) suggesting as much, and looking at https://github.com/golang/go/blob/release-branch.go1.16/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go#L394 I see the comparison to 4 (instead of 5). Any chance of a 1.16 backport? |
There is another certificate parser in 1.16, "golang.org/x/crypto/cryptobyte/asn1.go" is not used to parse them. |
If this was not a change in behavior in Go 1.17, I wonder why it only started coming up now. |
I presume @umlublin (and you) are correct and I was just looking at the wrong file. We'll followup with the bug reporter and get more details. |
Fixes golang/go#49678 Change-Id: If8a40e25edd810a66165ab78dd68d9b7fc2699f8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/365674 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Trust: Alex Rakoczy <alex@golang.org> Trust: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Fixes golang/go#49678 Change-Id: If8a40e25edd810a66165ab78dd68d9b7fc2699f8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/365674 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Trust: Alex Rakoczy <alex@golang.org> Trust: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Fixes golang/go#49678 Change-Id: If8a40e25edd810a66165ab78dd68d9b7fc2699f8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/365674 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Trust: Alex Rakoczy <alex@golang.org> Trust: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Hi, I hit the same issue with even larger ID https://oidref.com/1.2.36.20151795998 Tested it with the same program (https://play.golang.org/p/WI9bl64Z6wU) , the test does not pass. It looks like if any part in the ID is larger than // decode(encode([]int{1, 2, 36, 20151795998, 3, 1, 1, 1})) // not pass
// decode(encode([]int{1, 2, 36, 2147483647, 3, 1, 1, 1})) // (2^31 - 1) pass
decode(encode([]int{1, 2, 36, 2147483648, 3, 1, 1, 1})) // 2^31 not pass I'm using the latest Is there anything we can do to get it work? func (s *String) readBase128Int(out *int) bool {
ret := 0
for i := 0; len(*s) > 0; i++ {
if i == 5 {
return false
}
// Avoid overflowing int on a 32-bit platform.
// We don't want different behavior based on the architecture.
if ret >= 1<<(31-7) {
return false <= failed
}
ret <<= 7
b := s.read(1)[0]
ret |= int(b & 0x7f)
if b&0x80 == 0 {
*out = ret
return true
}
}
return false // truncated
} |
Fixes golang/go#49678 Change-Id: If8a40e25edd810a66165ab78dd68d9b7fc2699f8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/365674 Reviewed-by: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Trust: Alex Rakoczy <alex@golang.org> Trust: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Issue observed while connecting to LDAPS serwer with certificate generated by Microsoft Active Directory with Microsoft's specific X509v3 Certificate Policies
error message is "x509: invalid certificate policies"
it comes from parseCertificatePoliciesExtension in x509 parser
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/WI9bl64Z6wU
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: