Android security tags, read closely by Lightrion

CVE-2024-0040 AI-generated analysis

platform/frameworks/av, media/mtp (libmtp, MtpPacket)

AI-generated: written from the bulletin and the fixing diffs by claude-fable-5-1, then checked against the code by claude-opus-5-5 (4 corrections). Verify against the commit before relying on it.

MtpPacket::setParameter now calls allocate(mPacketSize) when it grows mPacketSize, so the buffer is reallocated before putUInt32 writes the parameter at the new offset.

Root cause

In media/mtp/MtpPacket.cpp, MtpPacket::setParameter computes offset = MTP_CONTAINER_PARAMETER_OFFSET + (index - 1) * sizeof(uint32_t). If mPacketSize is smaller than offset + sizeof(uint32_t), it raises mPacketSize to that value. The code then called putUInt32(offset, value) without reallocating the packet buffer, so the logical packet size could exceed the allocated buffer when the write happened. The commit message says this directly: the buffer size was not changed when the packet size was increased.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to February 2024 · Findings