mbedtls/tests
Hanno Becker ce516ff449 Fix heap corruption in ssl_decrypt_buf
Previously, MAC validation for an incoming record proceeded as follows:

1) Make a copy of the MAC contained in the record;
2) Compute the expected MAC in place, overwriting the presented one;
3) Compare both.

This resulted in a record buffer overflow if truncated MAC was used, as in this
case the record buffer only reserved 10 bytes for the MAC, but the MAC
computation routine in 2) always wrote a full digest.

For specially crafted records, this could be used to perform a controlled write of
up to 6 bytes past the boundary of the heap buffer holding the record, thereby
corrupting the heap structures and potentially leading to a crash or remote code
execution.

This commit fixes this by making the following change:
1) Compute the expected MAC in a temporary buffer that has the size of the
   underlying message digest.
2) Compare to this to the MAC contained in the record, potentially
   restricting to the first 10 bytes if truncated HMAC is used.

A similar fix is applied to the encryption routine `ssl_encrypt_buf`.
2017-11-20 10:16:17 +00:00
..
data_files Fix typo 2017-07-28 12:20:48 +01:00
scripts Merge remote-tracking branch 'gilles/iotssl-1223/mbedtls-2.1' into mbedtls-2.1 2017-06-06 20:12:51 +02:00
suites Improve leap year test names in x509parse.data 2017-10-12 21:03:15 +01:00
.gitignore Move some ignore patterns to subdirectories 2015-01-28 15:33:23 +00:00
CMakeLists.txt Remove need for elevated command line in Windows 2017-02-20 21:47:29 +00:00
compat.sh Fix bug in backport from SHA-1 blacklisting 2017-06-06 19:35:34 +02:00
Descriptions.txt Add selftest program to the list of tests 2014-04-04 16:33:01 +02:00
Makefile Cosmetics in Makefiles 2015-07-08 22:12:06 +01:00
ssl-opt.sh Fix heap corruption in ssl_decrypt_buf 2017-11-20 10:16:17 +00:00