AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 64 Bitcoin

fix(nordic): bound the GATT write length in bt_receive_cb()

Public commit record

What the developer wrote

Authored by tychovrahe

100/100 · Strong
fix(nordic): bound the GATT write length in bt_receive_cb()

The receive callback copied the GATT write payload into a fixed 251-byte
stack buffer without checking its length. It does not overflow today, but
only because the numbers happen to line up exactly: one L2CAP RX buffer
holds a 247-byte ATT PDU, an ATT write spends 3 bytes on the opcode and the
handle, and 244 plus the 7-byte address prefix is exactly the buffer size.

Nothing tied those numbers together. Raising CONFIG_BT_BUF_ACL_RX_SIZE on
its own is enough to let a peer deliver more, because the delivered length
is bounded by the L2CAP RX MTU rather than by the negotiated ATT MTU -
att_write_req() and att_write_cmd() pass the received length straight to the
callback.

Reject anything longer than BLE_RX_PACKET_SIZE, and add a BUILD_ASSERT so
that the Bluetooth buffer configuration and BLE_RX_PACKET_SIZE can no longer
drift apart silently.

[no changelog]
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a Bluetooth code flaw in Trezor's Nordic chip firmware. A function that receives data from another device over Bluetooth was copying that data into a fixed-size on-chip memory buffer without first checking how long the incoming data was. Right now the sizes happen to match, so no overflow occurs, but a configuration change or a connected peer sending a specially large write could have overflowed the buffer. The patch now rejects oversized incoming packets and adds a compile-time check so the buffer sizes cannot silently drift apart in future builds.

Recommended action

Treat this as a security fix and include it in the next firmware release. Review whether other Bluetooth callbacks in the same file or related Zephyr-based firmware use similar unchecked copies. Verify that BLE_RX_PACKET_SIZE and CONFIG_BT_BUF_ACL_RX_SIZE are kept in sync in all build configurations, including debug/internal builds where ACL RX size may be increased.

Security signals we found

01

Stack buffer overflow risk in Bluetooth GATT receive callback

02

Missing length validation before memcpy into fixed-size buffer

03

Reachable from a connected Bluetooth peer (remote attack surface)

04

Build-time assertion added to tie buffer sizes together

05

Patch rejects oversized packets with a warning log

Risk score

Why this scored 64/100

Our methodology →
Potential impact 18/30
Exploitability 14/25
Stealth signal 10/15
Affected reach 10/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.