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

SFT-8229: validate arguments explicitly in the foundation bindings

Public commit record

What the developer wrote

Authored by Jack

91/100 · Strong
SFT-8229: validate arguments explicitly in the foundation bindings

TypeError for an argument that is not a string, ValueError for a UR
unwrapped as the wrong variant or an optional field that is absent,
following the precedent #711 set for unwrap_bytes.

Add a lint job keeping mp_check_self out of extmod/foundation/, which
addresses a different case that the interpreter already covers for us.
Scoped to our own bindings; uses under extmod/trezor-firmware/ are
upstream's and are correct for what they do.

Unit tests pin each raise and its type, with the valid call beside it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit hardens the firmware's low-level Python bindings by replacing a generic internal check with explicit, user-friendly error messages when a function receives the wrong type of input or tries to access a missing field. It also adds automated tests and a lint rule to keep the old pattern from returning. The change is defensive: it does not fix a known exploit, but it reduces the chance that a confused or malformed input could lead to an unexpected crash or be misused.

Recommended action

Treat as a defensive hardening commit. Reviewers should verify that all public foundation bindings now raise the correct exception types, that the new unit tests run on device/emulator, and that the lint job correctly flags any future mp_check_self use in extmod/foundation/. No urgent security response is indicated by the diff alone.

Security signals we found

01

Replaces generic mp_check_self assertions with typed, explicit Python exceptions

02

Adds input-type validation for string arguments in C bindings

03

Adds variant/field-presence validation for UR value unwrap accessors

04

Introduces unit tests that verify both invalid and valid calls

05

Adds CI lint rule to enforce explicit validation in foundation bindings

Risk score

Why this scored 34/100

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