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

Fix base64 panic in from_base64

Public commit record

What the developer wrote

Authored by Mitchell Bagot

68/100 · Adequate
Fix base64 panic in from_base64

In sign_message, the from_base64 function can panic if the string has
both a length of 88 bytes, and decodes to an array of bytes > 65. This
can happen for a string of 88 "A" characters, for example. Further, the
function incorrectly parses base64 strings that produce 64 byte arrays.
While the latter is likely caught by the underlying secp parsing, both
should be checked to provide a more meaningful error return.

Add checks for non-65 byte base64 decoding in from_base64, returning
an InvalidLength error for 64 or 66 byte decodes. Also prevent panic on
66 byte decode.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a bug in the rust-bitcoin library where a specific function used to verify Bitcoin signed messages could crash the program. The crash could be triggered by feeding it a carefully crafted 88-character base64 string that decoded to 66 bytes instead of the expected 65 bytes. The fix adds proper length checks so the function returns a clean error instead of panicking, and also rejects 64-byte results that were previously silently accepted.

Recommended action

Treat this as a security-hardening fix with denial-of-service relevance. Reviewers should verify that all callers of `from_base64` now handle `InvalidLength` correctly, confirm no other base64 decode sites in the crate use similarly sized buffers without length checks, and consider whether this bug warrants a CVE or advisory if untrusted input can reach this function in production deployments.

Security signals we found

01

Panic/crash on malicious input (denial-of-service vector)

02

Incorrect length validation of base64-decoded signature

03

Potential silent acceptance of malformed 64-byte signatures

04

Missing bounds check before using fixed-size buffer

Risk score

Why this scored 62/100

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