Android security tags, read closely by Lightrion

CVE-2024-49748 AI-generated analysis

platform/packages/modules/Bluetooth, GATT server (system/stack/gatt/gatt_sr.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 in four GATT server request handlers in system/stack/gatt/gatt_sr.cc when the per-channel transmit payload size is 0 (channel already closed). As a result, a response buffer with effectively zero payload space is no longer allocated and written into.

Root cause

In gatt_sr.cc, the handlers gatts_process_primary_service_req, gatts_process_find_info, gatts_process_read_by_type_req and gatts_process_read_req get payload_size from gatt_tcb_get_payload_size_tx(tcb, cid). They immediately use it to size a response buffer (sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET, allocated with osi_calloc). Per the commit message, if the channel is already closed when the function is called, the length is zero. The buffer is then only sizeof(BT_HDR) + L2CAP_MIN_OFFSET bytes, and the response-building code that follows writes past the end of the allocation. For example, gatt_build_primary_service_rsp writes the opcode and length bytes via *p++ at (p_msg + 1) + L2CAP_MIN_OFFSET before it compares p_msg->len + p_msg->offset against payload_size.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to January 2025 · Findings