-
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/ecdsa: buffers are too small, can cause panic on s390x #34927
Comments
@gopherbot, please consider backport to 1.13.2 |
Backport issue(s) opened: #34928 (for 1.13). 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/201317 mentions this issue: |
Change https://golang.org/cl/201337 mentions this issue: |
Perhaps I merged the fix a bit too quickly, as I didn't notice the issue here at very little detail or discussion. Got a repro? Can this be a security issue? Remote DoS with certain client certs? |
/cc @FiloSottile |
Yeah, reopening.
|
If we don't get adequate test coverage & confidence of certain assembly, the fallback of course is to just revert that assembly to use the pure Go implementation. That's an option here if it comes to it. |
Running the
Potentially every time the KDSA instruction is executed, which will be the case when signing or verifying using P-256, P-384 or P-521.
Yes, my understanding is that the assembly is reading and writing to memory out of bounds because the buffer is smaller than the instruction assumes it to be. If a different thread writes to this memory area then we could see the result of the KDSA call change. Overwriting the stack could modify variables in other functions in the call chain. We must therefore assume that it is possible that this could affect the result of a sign or verify call.
It was introduced in CL 174437 prior to the Go 1.13 release. Go 1.13 and Go 1.13.1 are affected. The instruction was added based on a draft of the specification for the KDSA instruction which used a smaller size for the params buffer. We did not notice that this change had occurred.
They do, but only when run on a z15. Unfortunately we were not regularly testing on z15 hardware until now. The buildbot is a z13. In general I don't think we have a good story around testing whether assembly in Go is reading or writing memory out of bounds. Unfortunately if the buffer resides on the heap (or even on the stack) I don't think it will necessarily trigger any sort of panic or error.
These are taken directly from the final specification for the instruction. Yes, it should probably be a named type or constant.
Yes, I think it does. The hardware (z15) that is a pre-requisite for exposing this bug in Go is very new and has not been widely deployed yet which limits the likelihood that this is affecting a production application somewhat, but it is still a very nasty bug. |
I think that this is the best idea for Go 1.13.2. Apologies for all of this. In future we will avoid adding assembly for unreleased hardware. |
Ok, thanks for elaborating. We are definitely reverting CL 174437 for Go 1.13. Can you make the CL? The next version of the assembly policy (which is long overdue, and that's my fault) will explicitly require builders coverage for all assembly paths. We should not have merged that. We have a security release tomorrow but it's very late to add another change to it. Does this ever work on affected machines? If not, it sounds like no one will be blindsided in production, and we can put the fix in a regular minor release. |
Change https://golang.org/cl/201360 mentions this issue: |
This a revert of CL 174437 and follow up fix CL 201317. The s390x assembly in this package makes use of an instruction (specifically KDSA) which is not supported by the current build machine. Remove this assembly for now, we can revisit this functionality once we have a newer build machine and can ensure that this assembly is well tested. Updates #34927. Change-Id: I779286fa7d9530a254b53a515ee76b1218821f2f Reviewed-on: https://go-review.googlesource.com/c/go/+/201360 Run-TryBot: Michael Munday <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
Done, see CL 201360 for the removal in master and CL 201361 for the equivalent backport to Go 1.13.
Understood.
I am not 100% certain. The |
The backport into release-branch.go1.13 already landed, so it will be in the next non-securiry minor release, which should happen on the same day as the security one. |
Thanks Filippo. |
This is fixed by removing the assembly. Thanks for the quick CL, which shipped as a backport in Go 1.13.3. Let's use a new tracking issue for reintroducing it. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
clean run
What did you see instead?
panic
The text was updated successfully, but these errors were encountered: