-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/internal/fips140/nistec: p256NegCond is variable time on ppc64le #71383
Comments
Change https://go.dev/cl/643735 mentions this issue: |
Related Code Changes (Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
@rolandshoemaker Thank you so much for the observation and quick fix. |
@rolandshoemaker @jkrishmys I see that the relevant code in the CL643735 is also present in Go 1.22, Go 1.23, and other versions. Does this vulnerability affect the lower versions? Does it need to be patched? Thanks. |
Hi @qinlonglong123. Indeed you are right, thanks. It is tagged under PUBLIC track of Go Security Policy. I am little new to it. If @rolandshoemaker can advice, that will be great. |
We'll backport this to the next minor releases. @gopherbot please open backport issues, this is a minor security issue. |
Backport issue(s) opened: #71422 (for 1.22), #71423 (for 1.23). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
@jkrishmys Thanks for your reply,I noticed a slight difference in the implementation of the related function |
@rolandshoemaker @jkrishmys For Go 1.18, can the following commit change resolve this vulnerability? |
In Go 1.19, the declaration of
However, in Go 1.18, the declaration is as follows:
In Go 1.19, the first parameter is a pointer to an array, while in Go 1.18, the first parameter is a slice. So I'm not quite sure if what I’m seeing is:
Is this fetching the second parameter |
@qinlonglong123, thank you so much, as observed, one of the difference is the need for a byte-swap vector (SWAP) and VPERM instruction (used in Go 1.18) being replaced with the more direct XXPERMDI instruction (in Go 1.22), which is more efficient for the use-case. Further, the conditional branching in Go 1.18 version, makes the function |
The changes seem to eliminate the conditional branch and ensure constant-time execution. The parameter
(qinlonglong123@9e017ff) Some of our products are still using Go 1.18, which is very important to us. I look forward to your response. Thank you. We can wait for the comments of @rolandshoemaker about the patch proposed[qinlonglong123/go@9e017ff].
According to PowerPC64 ELFv2ABI, R1 points to the current stack frame. |
@jkrishmys Thank you very much for your reply. Regarding the changes in this CL https://go-review.googlesource.com/c/go/+/643735, I don't fully understand why the second parameter cond can be accessed with an offset of 40 from R1. The comment states "cond is R1 + 8 (cond offset) + 32." I guess that 8 is the offset for the first pointer parameter, but what exactly does the 32 refer to? |
Hi @qinlonglong123, according to PowerPC64 ABI document, The Parameter Save Area is a reserved region in the stack frame where the values of parameters passed in registers are shadowed. This ensures that the parameters can be accessed consistently throughout the function, even if the registers are repurposed for other tasks. In the use case,
I hope you can now visualise the comment "cond is R1 + 8 (cond offset) + 32." |
Change https://go.dev/cl/645515 mentions this issue: |
Change https://go.dev/cl/645535 mentions this issue: |
…ond constant time on ppc64le Remove the branching instruction from p256NegCond which made it variable time. The technique used matches that used in p256MovCond. Fixes #71383 Fixes #71423 Fixes CVE-2025-22866 Change-Id: Ibc2a46814d856cbbdaf6cc0c5a415ed5d42ca793 Reviewed-on: https://go-review.googlesource.com/c/go/+/643735 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Paul Murphy <murp@ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> (cherry picked from commit 6fc23a3) Reviewed-on: https://go-review.googlesource.com/c/go/+/645515 Reviewed-by: Carlos Amedee <carlos@golang.org>
…ond constant time on ppc64le Remove the branching instruction from p256NegCond which made it variable time. The technique used matches that used in p256MovCond. Fixes #71383 Fixes #71422 Fixes CVE-2025-22866 Change-Id: Ibc2a46814d856cbbdaf6cc0c5a415ed5d42ca793 Reviewed-on: https://go-review.googlesource.com/c/go/+/643735 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Paul Murphy <murp@ibm.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> (cherry picked from commit 6fc23a3) Reviewed-on: https://go-review.googlesource.com/c/go/+/645535 Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Bypass: Carlos Amedee <carlos@golang.org>
Hi @qinlonglong123, if my understanding is right,
|
Hi @qinlonglong123 i investigated this code further in my local repository and it appears that the val parameter is being treated as a pointer internally in this case which means cond is still accessible at 8+FP which 8+32 = 40 (R1) |
Thanks @archanaravindar , for clarifying it further. |
Due to usage of a conditional branching instruction in the ppc64le implementation of p256NegCond, the function is variable time rather than constant time.
This is a security issue, as it leaks a very small number of bits, but we're treating it as PUBLIC track per the Go Security policy, as it affects a rather niche architecture, and because we're unaware of any protocols this directly affects.
The text was updated successfully, but these errors were encountered: