CVE-2026-58879 AI-generated analysis
platform/hardware/interfaces, CAS HAL default implementation (hal_cas_default): DescramblerImpl in cas/1.0, cas/1.1, cas/1.2 and cas/aidl
Adds an early range check in all four default CAS HAL DescramblerImpl::descramble implementations (HIDL 1.0/1.1/1.2 and AIDL). It rejects srcOffset, dstOffset and srcBuffer.offset values that do not fit in int32 before they reach the DescramblerPlugin ABI.
Root cause
DescramblerImpl::descramble receives srcOffset, dstOffset and srcBuffer.offset as 64-bit values (uint64_t in HIDL 1.0/1.1/1.2, int64_t in AIDL). The existing validation (validateRangeForSize / isInRange and the heapBase size check) works on 64-bit values. Per the commit message, the offsets are then handed to the DescramblerPlugin ABI as int32. A value that exceeds INT32_MAX (or is negative in the AIDL variant) is truncated at that boundary, so the plugin can operate on an offset other than the one that was validated. The commit describes the result as an out-of-bounds write/read in hal_cas_default.
How the fix works
- cas/1.0/default/DescramblerImpl.cpp:DescramblerImpl::descramble: at function entry, if srcOffset > INT32_MAX || dstOffset > INT32_MAX || srcBuffer.offset > INT32_MAX, the function logs via ALOGE, emits android_errorWriteLog(0x534e4554, "517593332"), invokes _hidl_cb(toStatus(BAD_VALUE), 0, NULL) and returns Void(). This runs before the heapBase.size() > SIZE_MAX check and before mapMemory.
- cas/1.1/default/DescramblerImpl.cpp:DescramblerImpl::descramble: same check and early return as 1.0.
- cas/1.2/default/DescramblerImpl.cpp:DescramblerImpl::descramble: same check and early return as 1.0.
- cas/aidl/default/DescramblerImpl.cpp:DescramblerImpl::descramble: because the AIDL offsets are int64_t, the check also rejects negative values: srcOffset < 0 || srcOffset > INT32_MAX || dstOffset < 0 || dstOffset > INT32_MAX || srcBuffer.offset < 0 || srcBuffer.offset > INT32_MAX. On failure it logs, writes the errorWriteLog event and returns toStatus(BAD_VALUE) before the mmap of srcBuffer.heapBase.
- The fix is validation only. It does not change the plugin ABI types or the later validateRangeForSize logic; it ensures the three offsets are representable in int32 before further processing.
Completeness
- Covers the three offset inputs named in the diff (srcOffset, dstOffset, srcBuffer.offset) in all four default implementations (HIDL 1.0, 1.1, 1.2, AIDL).
- The AIDL path also rejects negative offsets; the HIDL parameters are uint64_t, so they cannot be negative.
- The commit only touches the default (hal_cas_default) implementations; vendor CAS HAL implementations are not changed by it.
- The material does not show the code after the check (the plugin call and how dstBuffer is handled), so it cannot show whether any other 64-bit field is narrowed at the same boundary.
Behavior changes
- descramble now fails with BAD_VALUE (via toStatus) when srcOffset, dstOffset or srcBuffer.offset exceeds INT32_MAX, or is negative in the AIDL HAL. Before the fix no check rejected these values for that reason.
- New ALOGE log line "Invalid offsets: ..." and an android_errorWriteLog event (tag 0x534e4554, bug id 517593332) on rejection.
- No change for callers passing offsets within int32 range.
Per major
- Android 14: same fix: commit e0e3eb2bcaca in android-security-14.0.0_r31, identical hunks in all four DescramblerImpl.cpp files (blob hashes and the 1.0 hunk line offset differ); 8/8 lines present.
- Android 15: same fix: commit 2bb3ae6b891a in android-security-15.0.0_r19, four files, 36 insertions; 8/8 lines present.
- Android 16: same fix: commit fd6aba50dc28 in android-security-16.0.0_r10, identical hunks and blob hashes to the 15 commit; 8/8 lines present.
- Android 17: same fix: commit e565bcbc10f5 in android-security-17.0.0_r3, identical hunks (AIDL hunk anchored one line later, different AIDL blob hashes); 8/8 lines present.
Unknowns
- The material does not show the DescramblerPlugin::descramble call site or its signature, so the int32 parameters at the plugin ABI boundary are known only from the commit message.
- Whether DestinationBuffer carries additional 64-bit offset fields that are narrowed at the same boundary is not visible in the provided code.
- The specific out-of-bounds access the truncation enabled inside the plugin is not shown.
- Which clients can reach the HAL with out-of-int32-range offsets, and how srcBuffer.offset is formed by the framework callers, is not shown.