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

Merge PR 'Avoid overflow when averaging liquidity offsets in merge' (#5208)

Public commit record

What the developer wrote

Authored by Matt Corallo

86/100 · Strong
Merge PR 'Avoid overflow when averaging liquidity offsets in merge' (#5208)

from bot/5121-unchecked-u64-addition-in-channe-326b73 into main

Reviewed-on: https://git.rust-bitcoin.org/lightningdevkit/rust-lightning/pulls/5208
Reviewed-by: Matt Corallo <matt@noreply.git.rust-bitcoin.org>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This patch fixes an arithmetic overflow bug in rust-lightning's payment-path scoring logic. When the software merged two stored estimates of a Lightning channel's available liquidity, it added two large 64-bit numbers together and then divided by two to get an average. If both numbers were near the maximum a u64 can hold, the addition would overflow and wrap around, producing a tiny, wrong average. The fix computes the average safely by dividing each number first, then adding. The commit message and new test explicitly describe this as an overflow risk, especially when data is loaded from disk or untrusted external sources.

Recommended action

Treat as a low-to-moderate reliability/security fix. Upgrade to a release containing this commit. If running custom builds, backport the overflow-safe average to ChannelLiquidity::merge(). No immediate incident response is required unless node operators observe anomalous routing behavior after merging scorer state from untrusted or corrupted sources.

Security signals we found

01

Unchecked u64 addition in merge logic replaced with overflow-safe averaging

02

Commit message explicitly frames change as avoiding overflow

03

New regression test covers u64::MAX inputs and odd-bit rounding

04

Affected values feed into routing/scoring decisions

05

Comment states offsets can be u64::MAX when read from serialized or external sources

Risk score

Why this scored 48/100

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