-
Notifications
You must be signed in to change notification settings - Fork 2.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
mbedtls_ssl_write_real: buffer overflow if MBEDTLS_SSL_MAX_FRAGMENT_LENGTH not defined #707
Labels
Comments
... link to " |
Thanks for raising the issue. We'll take a look. |
ARM Internal Ref: IOTSSL-1131 |
Thanks for reporting this issue! I believe it is fixed by #1094, which is now merged to development, therefore I am closing this issue. |
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote a simple client based on the client1 example, combined with a rather minimal config (similar to config-mini-tls1_1.h). I noticed that i got segfaults if i tried to send more than a few kb of data with
mbedtls_ssl_write()
.The documentation for this function states:
However, it appears that the length passed to
mbedtls_ssl_write()
is only checked ifMBEDTLS_SSL_MAX_FRAGMENT_LENGTH
is defined in the config file. The length frommbedtls_ssl_write()
is passed tossl_write_real()
, which does the following check:If
MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
is not defined, the user-specified length is passed straight tomemcpy( ssl->out_msg, buf, len );
a few lines below that, whilessl->out_msg
may not be large enough.Apart from the default config, almost none of the example configs define this
MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
option. Therefore i did not have this option in my config. This results in a segfault if callingmbedtls_ssl_write()
with a buffer larger than the mbedtls library has allocated.I think the length should always be checked, at least to ensure that the
ssl->out_msg
buffer does not overflow. Or the documentation + examples could be updated to make it very clear that the caller should check the length. I am not sure about the security implications, but i could imagine this may be problematic. In my case the certificates were overwritten by thessl->out_msg
.The text was updated successfully, but these errors were encountered: