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

feat(core): switch from Python THP implementation to Rust-based one

Public commit record

What the developer wrote

Authored by Martin Milata

62/100 · Adequate
feat(core): switch from Python THP implementation to Rust-based one

[no changelog]
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope! No meaningful explanatory body
The short version

What changed, and why it matters

This commit replaces the Python implementation of Trezor's THP (Trezor Host Protocol) with a Rust-based one. It is a large refactoring that moves channel state management, encryption, packet handling, and handshake logic from Python into a Rust module exposed as `trezorthp`. The change also adjusts how credentials are validated, how sessions are cached, and how the event loop handles reads, writes, and retransmissions. There is no explicit security bug in the diff, but the scope of the rewrite and the removal of several safety checks (for example around buffer allocation and unexpected-message handling) create a non-trivial risk of introducing memory-management, concurrency, or protocol-edge-case bugs. The vendor does not describe this as a security fix.

Recommended action

Treat this as a high-risk refactoring of a cryptographic transport layer. Review the corresponding Rust THP implementation (not shown in the diff) for memory safety, nonce handling, state-machine correctness, and side-channel resistance. Run the existing THP device tests (`tests/device_tests/thp/`) and fuzz the packet parser and handshake state machine. Pay special attention to buffer sizing, retransmission timeouts, channel preemption, and credential validation boundaries that changed in this commit.

Security signals we found

01

Large rewrite of a security-critical transport/encryption protocol (THP)

02

Removal of Python-side buffer-allocation failure paths (now raises `FirmwareError`)

03

Credential length and field truncation now enforced in Python before Rust processing

04

Handshake key retrieval moved behind an unlock workflow with a spawned task

05

Channel preemption logic changed: stale channels are killed rather than raising `UnexpectedMessageException(None)`

06

Several previously explicit protocol constants and state machines removed from Python; behavior now depends on Rust internals not shown in diff

Risk score

Why this scored 36/100

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