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

feat(core): allow preempting stale THP channels on all interfaces

Public commit record

What the developer wrote

Authored by Roman Zeyde

100/100 · Strong
feat(core): allow preempting stale THP channels on all interfaces

Instead of running 2 separate THP session handling tasks
(on USB & BLE interfaces), this PR uses a single task, which
will handle both - in order to allow preempting the event loop
in case there is an unresponsive channel.

`ThpContext` is split into interface-specific class (`InterfaceContext`)
and a "global" THP receiver (`ThpContext`).

Also, removing `core/tests/test_trezor.wire.thp.py` - to be reimplemented in a following PR.

[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✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit rewrites how the Trezor firmware handles the new Trezor Host Protocol (THP) across USB and Bluetooth. Instead of running one independent session handler for each interface, it merges them into a single task that can switch attention between interfaces. The main goal is to let the device abandon ('preempt') a stuck or unresponsive THP channel so that another interface can still make progress. The change is described as a feature/refactor, not as a security fix, and one THP test file is removed to be rewritten later.

Recommended action

Treat this as a significant refactor of a security-critical transport layer. Re-run the full THP test suite (including Bluetooth and USB cross-interface scenarios), reimplement the deleted test promptly, and review the preemption logic for race conditions, buffer lifetime, and exception safety. Verify that a stale channel cannot be abused to deny service to a legitimate second interface or to leak buffers.

Security signals we found

01

Refactor of concurrent multi-interface protocol handling

02

Introduction of channel preemption based on elapsed time since last write

03

Shared packet buffer sized to the largest interface RX packet length

04

Removal of an existing THP unit test without immediate replacement

05

Use of `race()` and generator-based timeout to avoid allocations in embedded code

Risk score

Why this scored 34/100

Our methodology →
Potential impact 8/30
Exploitability 6/25
Stealth signal 5/15
Affected reach 7/15
Confidence 5/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.