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

fix(core): refuse an emulator BLE read that cannot take a whole packet

Public commit record

What the developer wrote

Authored by tychovrahe

85/100 · Strong
fix(core): refuse an emulator BLE read that cannot take a whole packet

The socket is SOCK_DGRAM, so `recvfrom()` consumes the datagram whole and
discards whatever does not fit the buffer it is given. Passing
`MIN(max_len, sizeof(buf))` therefore let a caller with a short buffer destroy
part of a received packet and get only its own length back - the emulator's
version of the defect just fixed in the hardware driver, reached through UDP
truncation rather than a queue dequeue.

Reject a `max_len` below the packet size before reading, as the hardware
driver now does, and read a whole buffer unconditionally: with the check above
it, the MIN could only ever pick `sizeof(buf)`.

No caller is affected. `py_iface_read()` requires a buffer at least
`RX_PACKET_SIZE` long and the bootloader wire layer requires an exact size;
only a direct `ble_read` syscall could ask for less.

[no changelog]

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a bug in the Trezor emulator's Bluetooth-over-UDP code. Previously, if a caller asked to read a Bluetooth packet into a buffer smaller than a full packet, the emulator would silently throw away the leftover data. Now it refuses short reads up front, matching a fix already made in the real hardware driver. The commit message says no real callers were affected because all normal callers use full-size buffers.

Recommended action

Treat as a low-severity hardening fix. Verify that all callers of ble_read() indeed use buffers of at least BLE_RX_PACKET_SIZE, and consider adding a static assertion or documentation to maintain this invariant. No urgent action is required unless a direct ble_read() syscall with a short buffer is exposed to untrusted code.

Security signals we found

01

Data truncation / silent packet loss on datagram socket

02

Emulator-only code path, but mirrors a hardware driver security fix

03

Possible inconsistency between returned length and consumed datagram

04

Defensive bounds check added to refuse undersized reads

Risk score

Why this scored 45/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 9/15
Affected reach 6/15
Confidence 7/10
Evidence quality 3/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.