-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
ECP::ScalarMultiply() may seemingly miscompute for small scalars when using Ubuntu 20.04.6 LTS on 64-bit Intel CPUs #1269
Comments
Thank you @ekera 🙏 I have filed Launchpad Bug against the With fresh amd64 VMs using the latest Ubuntu point releases, I was able to reproduce your report on Ubuntu Focal 20.04.06 ( Also on Ubuntu Focal 20.04.04, I installed Debian's So, the issue is only known to affect packages based on Debian |
Debian According to a post in 2019 , #869, the CVE-2019-14318 patch for 5.6.4 was incomplete. A comment in a later 2020 issue mentions that the 2019 8.3 patch was broken: #994 (comment) Debian's 5.6.4-9 uses the 2019 patch which likely contains a regression. It does not appear that a fully working fix for CVE-2019-14318 in 5.6.4 was made. |
On Debian's side, only unstable (Sid) was affected as far as I am aware. Buster received 5.6.4-8, which is the version immediately prior to applying the incomplete patch. https://security-tracker.debian.org/tracker/CVE-2019-14318 |
@ekera I will request a SRU for @weidai1 could you please comment on if a backport security patch will be released. It seems more than reasonable that a complicated backport fix would not be supported. |
A regression fix was proposed last week. I'll shepherd it through and report back when the fix is live. https://bugs.launchpad.net/ubuntu/+source/libcrypto++/+bug/2064751 |
I typically never use Crypto++, but I had to yesterday, and I then experienced a strange behavior that I felt I had to somehow report. Having read your security policy, I decided that the appropriate course of action was to open an issue here.
Background
I used the default Crypto++ package provided by Ubuntu 20.04.6 LTS (Focal Fossa) running on a computer with a 64-bit Intel CPU.
More specifically, Crypto++ was installed on the machine via
apt
as follows:The package version 5.6.4 leads me to think that it installs the (old) v5.6.4 release of Crypto++ from this GitHub repository, although it is not entirely clear from the metadata for the package.
The issue
When using Crypto++ as provided by the above package, it seems
ECP::ScalarMultiply()
may miscompute. Specifically, it seems to miscompute if the scalar is on [2, 32), i.e. of bit length less than or equal to 5. This would appear to be related to the difference in behavior induced by the branching on this line in the source code for Crypto++.To exemplify, I obtain the below result:
The source code in
main.cpp
is as follows:To confirm that there was no issue with the specific Ubuntu installation, I setup a clean virtual Ubuntu 20.04.6 LTS machine and repeated the above steps. I was thus able to reproduce the erroneous behavior.
To check whether this issue extends to other releases and architectures, I furthermore compiled
main.cpp
and ran the resulting executable under Ubuntu 22.04 LTS for ARM64 in a virtual machine. The correct expected output was then produced:To better try to understand what is going on, I downloaded Crypto++ releases from this GitHub repository, and proceeded to compile and link against them manually. I did this on the Ubuntu 20.04.6 LTS machine that produced the erroneous output, in the hope of thus being able to reproduce the error. But as it turned out, I could not reproduce the error in this way. Instead, the correct expected output was produced for all of the GitHub releases that I have tried thus far (namely v5.6.3, v5.6.4, v5.6.5, v6.0.0, v6.1.0, v7.0.0, v8.0.0, v8.2.0, v8.3.0, v8.4.0 and v8.9.0) — but not for Crypto++ as provided by the Ubuntu package repository.
I did expect to be able to reproduce the error at least for v5.6.4, if this is the version from which the Ubuntu package was built. When I could not, I computed a diff between the header files installed by the Ubuntu package and the header files for the v5.6.4 release from this GitHub repository, and there appears to be some differences.
So in conclusion, I am not entirely sure which version of Crypto++ is in the Ubuntu repository, and how it was compiled, tested, etc. But it seems that it is not working properly? I find this all a bit surprising. Could someone else please confirm this? Or let me know if I am making some mistake in my code, given that I usually never use Crypto++. Assuming I did not make a mistake and that this really is an issue, further actions may then of course be necessary.
(On a side note, I would expect there to be unit tests that cover the small scalar case, since the code branches depending on the bit length of the scalar. Assuming that this is the case, and that these tests were run, it seems strange to me that this issue would not have been detected when the Ubuntu package was built.)
The text was updated successfully, but these errors were encountered: