Android security tags, read closely by Lightrion

CVE-2023-40078 AI-generated analysis

platform/packages/modules/Bluetooth, system/stack/a2dp (A2DP Opus vendor codec decoder)

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

Adds a check after the opus_decode() retry in a2dp_vendor_opus_decoder_decode_packet. If the retry fails, the packet is dropped. Before, the negative error code was turned into a huge unsigned frame length that was passed to the decode callback.

Root cause

In system/stack/a2dp/a2dp_vendor_opus_decoder.cc, a2dp_vendor_opus_decoder_decode_packet calls opus_decode(). If the first call fails, it retries with a different set of parameters (the retry call shown in the diff passes A2DP_OPUS_DECODE_BUFFER_LENGTH and flags 0). The return value of the retry was not checked. It was used directly in 'size_t frame_len = ret_val * numChannels * sizeof(a2dp_opus_decoder_cb.decode_buf[0])', and the result was handed to a2dp_opus_decoder_cb.decode_callback. If the retry also fails, ret_val is negative. Converted to unsigned, it gives an enormous size that overflows the frame buffer (per the commit message).

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to December 2023 · Findings