Buffer overflow in hmac setup on known unsupported algorithm, with long input #254

Closed
opened 2019-09-11 06:48:29 -05:00 by RonEld · 1 comment
RonEld commented 2019-09-11 06:48:29 -05:00 (Migrated from github.com)

Description

When calling psa_mac_sign_setup() for HMAC with a known but unsupported algorithm and a key that's longer than the block size, a buffer overflow occurs.
This happens in psa_hmac_setup_internal(), if psa_hash_setup() or psa_hash_update()fail, and thekey_length` is larger than PSA_HMAC_MAX_HASH_BLOCK_SIZE, because at the cleanup we do the following:

mbedtls_platform_zeroize( ipad, key_length );

Issue request type

[ ] Question
[ ] Enhancement
[x ] Bug
<!-- ************************************** WARNING ************************************** The ciarcom bot parses this header automatically. Any deviation from the template may cause the bot to automatically correct this header or may result in a warning message, requesting updates. Please ensure that nothing follows the Issue request type section, all issue details are within the Description section and no changes are made to the template format (as detailed below). ************************************************************************************* --> ### Description <!-- Required Add detailed description of what you are reporting. Good example: https://os.mbed.com/docs/latest/reference/workflow.html Things to consider sharing: - What target does this relate to? - What toolchain (name + version) are you using? - What tools (name + version - is it mbed-cli, online compiler or IDE) are you using? - What is the SHA of Mbed OS (git log -n1 --oneline)? - Steps to reproduce. (Did you publish code or a test case that exhibits the problem?) --> When calling `psa_mac_sign_setup()` for HMAC with a known but unsupported algorithm and a key that's longer than the block size, a buffer overflow occurs. This happens in `psa_hmac_setup_internal()`, if `psa_hash_setup() or `psa_hash_update()` fail, and the `key_length` is larger than PSA_HMAC_MAX_HASH_BLOCK_SIZE, because at the cleanup we do the following: ~~~ mbedtls_platform_zeroize( ipad, key_length ); ~~~ ### Issue request type <!-- Required Please add only one X to one of the following types. Do not fill multiple types (split the issue otherwise.) Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front of them would change the meaning incorrectly. The only changes to be made are to add a description text under the description heading and to add a 'x' to the correct box. --> [ ] Question [ ] Enhancement [x ] Bug
ciarmcom commented 2019-09-11 07:25:05 -05:00 (Migrated from github.com)

Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-894

*Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-894*
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-ARMmbed/mbed-crypto#254
No description provided.