-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fernet fails to encrypt/decrypt large data #5615
Comments
Here is some more information to aid with debugging the issue. I have verified these results on two different computers, so I am quite certain this is not in any way related to the RAM issues I have mentioned. # _MAX_CHUNK_SIZE = 2 ** 31 - 1 (unmodified):
data_size = 2**32 - 1024**2 # OK
data_size = 2**32 - 1024 # OK
data_size = 2**32 - 512 # OK
data_size = 2**32 - 128 # OK
data_size = 2**32 - 64 # OK
data_size = 2**32 - 48 # OK
data_size = 2**32 - 33 # OK
data_size = 2**32 - 32 # FAIL (ValueError: The length of the provided data is not a multiple of the block length)
data_size = 2**32 - 31 # FAIL (ValueError: The length of the provided data is not a multiple of the block length)
data_size = 2**32 - 17 # FAIL (ValueError: The length of the provided data is not a multiple of the block length)
data_size = 2**32 - 16 # FAIL (SIGABRT: munmap_chunk(): invalid pointer)
data_size = 2**32 - 1 # FAIL (SIGABRT: munmap_chunk(): invalid pointer)
data_size = 2**32 # FAIL (SIGABRT: munmap_chunk(): invalid pointer or SIGSEGV)
data_size = 3*2**32 # FAIL (SIGSEGV) Traceback from the cases that fail with a ValueError:
|
This is likely to be our bug since we chunk items specifically to work around OpenSSL's integer size limits. We will investigate. Update: This isn't our bug but we have worked around it by altering our chunking rules. |
frustratingly, there is no test for this -- that's because testing this requires allocating more memory than is available in CI. fixes pyca#5615.
* correct buffer overflows cause by integer overflow in openssl frustratingly, there is no test for this -- that's because testing this requires allocating more memory than is available in CI. fixes #5615. * backport CI fixes * another CI backport
CVE-2020-36242 got assigned to this issue. |
Vulnerable versions: >= 3.1, < 3.3.2 Patched version: 3.3.2 Impact: When certain sequences of update() calls with large values (multiple GBs) for symetric encryption or decryption occur, it's possible for an integer overflow to happen, leading to mishandling of buffers. References: - pyca/cryptography#5615 For Py3.5 requirements we dropped `cryptography` to version 3.0 which is not vulnerable to the CVE in question. This decision was made consciously because the Salt Project creates packages for the supported distributions which still use Py3.5 and those even rely on an even older version of `cryptography`. Upgrading to the latest version was not possible because the `cryptography` project dropped Py3.5 support.
Vulnerable versions: >= 3.1, < 3.3.2 Patched version: 3.3.2 Impact: When certain sequences of update() calls with large values (multiple GBs) for symetric encryption or decryption occur, it's possible for an integer overflow to happen, leading to mishandling of buffers. References: - pyca/cryptography#5615 For Py3.5 requirements we dropped `cryptography` to version 3.0 which is not vulnerable to the CVE in question. This decision was made consciously because the Salt Project creates packages for the supported distributions which still use Py3.5 and those even rely on an even older version of `cryptography`. Upgrading to the latest version was not possible because the `cryptography` project dropped Py3.5 support.
This comment has been minimized.
This comment has been minimized.
A |
|
Hello,
Thank you for this fine library.
I've been having some issues when encrypting large data (>2GiB) using the Fernet class. There seems to be several failure modes, I've seen everything from a segfault, SIGABRT to the decrypted plaintext differing from the original plaintext. Please note that I've had some issues with the RAM on my computer (so that could potentially be the source of some of the failures), but I've verified at least the SIGABRT failures on three different computers.
It seems to me that the issue seems to be an integer overflow in OpenSSL, but I'm not sure if Cryptography is at fault for passing an integer that is too large, or OpenSSL is at fault for not checking the integer, or a combination. If you think this should be fixed in OpenSSL, please let me know so I can report the issue to them.
Please see the attached script for more detailed information, as I think it speaks for itself.
To reproduce:
The text was updated successfully, but these errors were encountered: