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

fix(crypto): add missing checks for negative VLA size

Public commit record

What the developer wrote

Authored by M1nd3r

82/100 · Strong
fix(crypto): add missing checks for negative VLA size

Credit for finding this issue belongs to a security reporter Amr.

[no changelog]
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides an explanatory body✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes two functions in Trezor's base58 code that build temporary memory buffers using a user-supplied length. Before the fix, a negative length value was not rejected. On systems where negative signed integers are treated as very large unsigned values, that could cause the device to allocate a huge buffer or corrupt memory, potentially crashing the device or enabling further attacks. The fix adds simple checks to reject negative lengths.

Recommended action

Review all callers of base58_encode_check and base58_decode_check to ensure they cannot pass negative lengths, and audit other VLA usages in the codebase for similar missing lower-bound checks. Consider replacing VLAs with fixed-size or heap-allocated buffers where feasible.

Security signals we found

01

Missing negative-length validation before variable-length array allocation

02

Potential stack-based buffer overflow or allocation failure from signed/unsigned conversion

03

External security reporter credited (Amr)

Risk score

Why this scored 59/100

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