-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
TLS 1.3 generates invalidly large TLS records #7918
Comments
Thanks for your report. I can see in the code that we have a maximum size for data contained in a record of MBEDTLS_SSL_OUT_CONTENT_LEN which is equal to 16384 = 2^14 by default. I have to check in the TLS 1.3 spec what exactly should be less then 2^14, the length of the encrypted/non-encrypted data, this with some additional headers? |
|
Hold on, I may be misreading the spec. |
I think there still some problem with size of record: Just reproduced error with @ 3c22366:
Then use any browser to access https://localhost:4433/ will result a SSL error And TLS 1.2 : |
@ronald-cron-arm Apologies, earlier I was referring to the wrong RFC section. The problem is that MbedTLS generates too much padding. I've updated the issue description. |
No worries and thanks for these detailed investigations. Looking at the code you point to (ssl_build_inner_plaintext() and ssl_compute_padding_length()) I agree with your findings and it seems that only the size 16384 is problematic. |
This is now fixed in development after the record size limit changes I tested with: |
Summary
RFC 8446 §5.4 specifies:
However, MbedTLS will send records with a length exceeding this limit if you call mbedtls_ssl_write with a large enough buffer.
System information
Mbed TLS version (number or commit id): 3c22366
Operating system and version: Ubuntu 20.04
Configuration (if not default, please attach
mbedtls_config.h
):scripts/config.py set MBEDTLS_SSL_PROTO_TLS1_3
Expected behavior
MbedTLS should not generate TLS records that are too large.
Actual behavior
Here's a PCAP that shows the too long record (length = 16416, if you decrypt it you will see 15 padding bytes). If you break on
ssl_build_inner_plaintext
you can see it is called with*content_size == 16384
andpad == 15
, but according to the spec,*content_size + pad
should be at most 16384. Conforming peers will terminate the connection with a "record_overflow" alert, so this is pretty problematic.Steps to reproduce
You can run the code from ssl_pthread_server.c.txt to see this behavior. This is maybe a little bit verbose, it was adapted from
programs/ssl/ssl_client1.c
andprograms/ssl/ssl_server.c
The text was updated successfully, but these errors were encountered: