mbedtls/tests
Hanno Becker 251bab5ceb 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:31:23 +00:00
..
data_files Fix typo 2017-07-28 13:15:57 +01:00
scripts More tests of FALLBACK_SCSV 2017-05-17 14:50:38 +02:00
suites Improve leap year test names in x509parse.data 2017-10-12 21:18:21 +01:00
.gitignore Move some ignore patterns to subdirectories 2015-01-28 15:33:23 +00:00
CMakeLists.txt Add tests for the bug IOTSSL-619. 2016-05-18 19:58:40 +01:00
compat.sh Update default configuration 2016-04-09 00:16:40 +01:00
Descriptions.txt Add selftest program to the list of tests 2014-04-04 16:33:01 +02:00
Makefile Adds test_suite_pkcs1_v15 to tests/Makefile 2016-05-18 20:08:16 +01:00
ssl-opt.sh Fix heap corruption in ssl_decrypt_buf 2017-11-20 10:31:23 +00:00