Skip to content
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

Null pointer dereference in mbedtls_mpi_mod_exp #4641

Closed
gilles-peskine-arm opened this issue Jun 10, 2021 · 0 comments · Fixed by #4703
Closed

Null pointer dereference in mbedtls_mpi_mod_exp #4641

gilles-peskine-arm opened this issue Jun 10, 2021 · 0 comments · Fixed by #4703
Labels
bug component-crypto Crypto primitives and low-level interfaces size-m Estimated task size: medium (~1w)

Comments

@gilles-peskine-arm
Copy link
Contributor

In Mbed TLS 2.26.0, mbedtls_mpi_mod_exp(X, A, E, N, _) with A having zero limbs crashes with a null pointer dereference. The code works fine when A has the value 0 but is represented with at least one limb.

In Mbed TLS 2.26.0, this bug is hard to reach since most functions that construct an MPI value (including mbedtls_mpi_lset and mbedtls_mpi_read_xxx, as well as most arithmetic operation) result in 0 being represented with at least 1 limb. In the development branch, a side effect of a change to mbedtls_mpi_read_binary{,_le} made in #4276 caused these functions to allocate 0 limbs when the input is an empty string, which made the bug reachable from TLS, where it was found by OSS-Fuzz.

@gilles-peskine-arm gilles-peskine-arm added bug component-crypto Crypto primitives and low-level interfaces Product Backlog size-m Estimated task size: medium (~1w) labels Jun 10, 2021
gilles-peskine-arm added a commit to gilles-peskine-arm/mbedtls that referenced this issue Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-crypto Crypto primitives and low-level interfaces size-m Estimated task size: medium (~1w)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant