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

fix(crypto): make aes functions reject negative length

Public commit record

What the developer wrote

Authored by M1nd3r

62/100 · Adequate
fix(crypto): make aes functions reject negative length

[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 fixes a bug in Trezor's AES encryption/decryption code where a negative length value could be passed to low-level AES functions. Previously, those functions treated the signed length as a large unsigned number, which could cause them to read or write far beyond the intended memory buffer. The patch makes every AES mode reject negative lengths and adds error handling so callers fail safely instead of silently producing bad results or touching memory they shouldn't.

Recommended action

Treat this as a security hardening fix with possible memory-safety implications. Review whether any Trezor message handler or Python API could previously supply a negative length (e.g., from malformed protobuf fields or MicroPython buffer objects) and confirm the new error paths are reachable. Run the added `test_aes_negative_length` tests and consider fuzzing the AES bindings with edge-case lengths.

Security signals we found

01

Signed/unsigned confusion on length parameter in cryptographic primitives

02

Missing bounds check allowing negative length to bypass alignment validation

03

Potential out-of-bounds read/write in AES mode loops

04

Return-value propagation added to callers (defense-in-depth)

05

New unit tests specifically targeting negative length rejection

Risk score

Why this scored 47/100

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