Android security tags, read closely by Lightrion

CVE-2024-0031 AI-generated analysis

platform/packages/modules/Bluetooth, system/stack/gatt (ATT protocol PDU builder, att_protocol.cc)

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 (5 corrections). Verify against the commit before relying on it.

Adds an early return of nullptr in attp_build_read_by_type_value_cmd when payload_size is less than 5, so the fixed 5-byte ATT header (opcode + start handle + end handle) is never written into a heap buffer sized by a too-small payload_size.

Root cause

attp_build_read_by_type_value_cmd allocates a BT_HDR with payload_size + L2CAP_MIN_OFFSET bytes of body and then unconditionally streams 5 bytes (GATT_REQ_FIND_TYPE_VALUE opcode, s_handle, e_handle) plus the UUID and the value. No check ensured payload_size was at least as large as the fixed header. If payload_size was smaller than 5, the header write itself went past the allocation; in addition, the clamp `if (p_value_type->value_len + p_buf->len > payload_size) len = payload_size - p_buf->len;` computes payload_size - p_buf->len, which for payload_size < p_buf->len underflows when stored in the uint16_t len, making the following memcpy copy far more value data than the buffer holds.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to February 2024 · Findings