-
Notifications
You must be signed in to change notification settings - Fork 2.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
Padding-only Application Data frames seem to be decoded incorrectly in CBC ciphers #1632
Comments
Hi @kFYatek, thank you very much for your report! You are entirely right, this is a known bug in Mbed TLS that we are aware of for a while and are tracking it internally; another customer also reported it recently in the Mbed TLS forum. Also, your analysis of the source of the problem matches ours. A fix for this bug will hopefully be available soon, although I cannot make any promises on when exactly we will be able to schedule time for this. Thank you very much for your interest and help - good catch! 👍 |
Internal Reference: IOTSSL-1920. |
Hi @hanno-arm , what's the status of the bug?Is it solved? |
There's a possible fix for this in the commit linked above. Currently waiting for signed corporate CLA (for Espressif Systems) to come through, then I'll make a dedicated bugfix branch and send this in a PR for consideration. |
ARM Internal Ref: IOTSSL-2396 |
Description
Bug
OS
linux
mbed TLS build:
Version:
cdd97fd63282779907a37b6a785bfbcf1b8fa964
(currentdevelopment
), also reproduced at least on 2.8.0OS version: Ubuntu 18.04
Configuration: default (
cmake .
)Compiler and options: gcc 7.3.0
Peer device TLS stack and version
OpenSSL 1.1.0g (from Ubuntu 18.04 default repo); also reproduced on OpenSSL 1.1.0h from Arch Linux' default repo
Steps to reproduce
Easiest way to reproduce consistently is to use a Docker VM:
Note that:
ssl_client1
's output so that non-printable characters are immediately visible; they otherwise are usually invisible in common terminal emulators-tls1
option to OpenSSL's server) - it causes theECDHE-RSA-AES256-SHA
ciphersuite to be used in CBC mode; with TLS 1.2 the ciphersuite is negotiated toECDHE-RSA-AES256-GCM-SHA384
, which does not cause this problemAfter running the above commands, you can see something like this:
The client receives 16
\x0f
bytes before the actual content. Examining the packets in e.g. Wireshark shows that the OpenSSL-based server in this configuration sends an additional Application Data frame which is 36 bytes long, that, after decryption, contains just these 16 bytes of padding. However, mbed TLS does not treat it as padding-only (i.e. effectively 0-byte long) data frame, but passes this padding to the application.The problem seems to be caused by the way padding is handled in
ssl_decrypt_buf()
;ssl_tls.c:1915
is:And in this case both
in_msglen
andpadlen
are 16, so padding is treated as incorrect by this code. I couldn't find any information in the TLS 1.0 (or TLS 1.2 for that matter) RFC that would prohibit such padding-only frame, so I think that it is a bug on mbed TLS side rather than in OpenSSL.Another issue is: why padding that is considered incorrect is passed to the application layer instead of e.g. causing an error code to be returned from
mbedtls_ssl_read()
?Disclaimer: I don't consider myself an expert in TLS or cryptography in general by any means; my analysis is based on a humble programmer's common sense, and I do realize that it does not always work in the field of security. It might be the case that it is OpenSSL where the actual bug is.
The text was updated successfully, but these errors were encountered: