CVE-2026-59010 AI-generated analysis
platform/system/keymint, KeyMint reference implementation, legacy keyblob parsing (common crate, tag::legacy)
Adds a bounds check in the legacy keyblob tag deserializer (system/keymint common/src/tag/legacy.rs, deserialize) so that a blob_data_size read from the keyblob that is larger than the remaining input returns InvalidKeyBlob instead of causing an out-of-range slice (Rust panic).
Root cause
In common/src/tag/legacy.rs, deserialize() reads a 32-bit blob_data_size from the legacy keyblob and then slices the input as &data[..blob_data_size] and &data[blob_data_size..] without first checking that blob_data_size does not exceed data.len(). Other lengths are checked: param_size is compared against data.len(), and consume_blob checks data_offset + data_len against blob_data.len(). blob_data_size was not. In Rust an out-of-range slice index panics, so a keyblob whose blob_data_size exceeds the remaining bytes makes the deserializer panic.
How the fix works
- common/src/tag/legacy.rs:deserialize: after consume_u32 reads blob_data_size, the fix adds `if blob_data_size > data.len() { return Err(km_err!(InvalidKeyBlob, "failed to find {blob_data_size} bytes")); }` before the slices &data[..blob_data_size] and &data[blob_data_size..] are formed.
- common/src/keyblob/legacy/tests.rs: adds test_deserialize_encrypted_keyblob_overrun. It builds an EncryptedKeyBlob whose second params section declares a blob data size (bytes 00000001, which is 0x01000000 little-endian) larger than the remaining bytes, and asserts that EncryptedKeyBlob::deserialize(&data).is_err().
Completeness
- Covers the unchecked blob_data_size against the remaining data in deserialize(). In the visible code, param_size was already checked against data.len(), and consume_blob already checks data_offset/data_len against blob_data.len(). The rest of the parameter loop is not shown in the material.
- The check comes before any slicing, so it protects both &data[..blob_data_size] and &data[blob_data_size..].
- The fix only touches the legacy tag format parser in tag/legacy.rs. Nothing else in the keyblob code changes, and the material does not show other parsers.
Behavior changes
- Legacy keyblobs whose blob_data_size exceeds the remaining input now fail with ErrorCode InvalidKeyBlob (message "failed to find N bytes") instead of panicking.
- No change for well-formed keyblobs.
- The Android 14 version also includes a formatting-only reflow of two match arms in serialize() (RsaPublicExponent, UserSecureId). It has no behavioral effect.
Per major
- Android 14: adapted fix: platform/system/keymint beff70465555 in android-security-14.0.0_r31. Same bounds check and test, plus a formatting-only reflow of two serialize() match arms (8/8 lines of patched region present).
- Android 15: same fix: platform/system/keymint 2e375cf84268 in android-security-15.0.0_r19 (5/5 lines present).
- Android 16: same fix: platform/system/keymint c9f980ac9c12 in android-security-16.0.0_r10 (5/5 lines present).
- Android 17: not listed by the bulletin for 17. The patched region (5/5 lines) is already present at android-security-17.0.0_r3.
Unknowns
- The material does not show which production callers (e.g. KeyMint TA or software implementation) pass untrusted keyblobs to EncryptedKeyBlob::deserialize / tag::legacy::deserialize.
- The material does not describe the exact runtime consequence of the panic in the deployed environment (process abort vs TA crash) beyond the bulletin's DoS classification.
- The remainder of deserialize() after the parameter loop starts (beyond line 326) is not shown.