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

Fix overflow bug in `Weight` constructors

Public commit record

What the developer wrote

Authored by Shing Him Ng

73/100 · Adequate
Fix overflow bug in `Weight` constructors

This fixes an overflow bug which occured when these constructors were
used to construct a `Weight` of max value. Since `Weight` is a `u64`
under the hood, the constructors panicked during the attempt to add
to the max weight value
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit fixes a panic (crash) in two Bitcoin weight-unit conversion helpers when they are called on the maximum possible weight value. The functions now use saturating addition, so instead of overflowing and crashing they return a large but valid rounded-up result. This is a reliability fix that prevents denial-of-service-style crashes from untrusted inputs.

Recommended action

Review callers of `to_kwu_ceil()` and `to_vbytes_ceil()` to confirm they do not rely on overflow/panic behavior, and include this fix in the next maintenance release. No immediate incident response is required unless an application exposes these helpers to adversarial input.

Security signals we found

01

Integer overflow in public conversion API

02

Potential panic on untrusted/malicious max-value weight input

03

Denial-of-service vector via crafted `Weight::MAX` usage

04

Use of `saturating_add` to eliminate overflow panic

Risk score

Why this scored 38/100

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