psa_generate_key for a symmetric key of ≥1025 bytes causes a double free #207
Labels
No labels
api-spec
bug
CLA requested
CLA valid
compliance
DO NOT MERGE
duplicate
enhancement
feature branch
good first issue
HEADER FORMATTING ISSUE
help wanted
Information
invalid
Jira status: AWAITING REVIEW
Jira status: CLOSED
Jira status: DONE
Jira status: IN PROGRESS
Jira status: IN REVIEW
Jira status: OPEN
Jira status: REOPENED
Jira status: RESOLVED
mirrored
mirror internally
needs: backports
needs: ci
needs: design review
needs: preceding PR
needs: review
needs: work
notabug
open for community contribution
Product Backlog
question
ready for merge
security
stale
type: bug
type: enhancement
type: question
web pages
wontfix
writing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-ARMmbed/mbed-crypto#207
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Steps to reproduce: on the psa-api-1.0-beta branch, call
psa_generate_key()with any symmetric key type that allows large key sizes (e.g.PSA_KEY_TYPE_RAW,PSA_KEY_TYPE_HMAC,PSA_KEY_TYPE_DERIVE) and a size of 8200 bits or more (>1024 bytes). This causes a doublefreeinsidepsa_generate_key.Impacted product: This only affects the psa-api-1.0-branch, the offending code has never been merged to the Mbed Crypto
developmentbranch and thus this does not affect any Mbed Crypto release. The bug was introduced in #263, merged on 2019-05-03, earliest tag psa-api-1.0-beta3.Impact: this is a double free(), so it can lead to arbitrary code execution. However, the exploitability is low, possibly nonexistent in single-threaded applications with many free() implementations, because there is only a very short window of time between the two free() calls, with no other call to
mallocorfreein between in the same thread.Affected applications: The bug is triggered by a failure of
psa_generate_randomduring key generation for a symmetric key (e.g. HMAC or derive, but not asymmetric keys such as RSA). This can happen in two ways:Issue request type
Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-855
Fixed — https://github.com/ARMmbed/mbed-crypto/pull/197 fixes this and is now merged to psa-api-1.0-beta, which is the sole medium-term branch that had this bug,