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

Correctly handle new `ChannelMonitorUpdate`s to old post-FC chans

Public commit record

What the developer wrote

Authored by Matt Corallo

88/100 · Strong
Correctly handle new `ChannelMonitorUpdate`s to old post-FC chans

In 0.1 (1481216793169ae83c87ae26fddda8a1971e35f9) we started
setting `ChannelMonitorUpdate::update_id` to a non-`u64::MAX` value
for updates generated after a channel has been closed.

This is great, but in 71a364c13345396fd75b22877e03b6a7b1d2bca1 we
then started calculating the next `update_id` by incrementing the
last `update_id` we saw when we started and were looking at the
`ChannelMonitor`. However, the last-applied `update_id` may well be
`u64::MAX` for old `ChannelMonitor`s which were closed prior to
0.1. In that case the increment would overflow.

Here we fix this naively by simply replacing the increment with a
`saturating_add`. While its possible this will result in a
`ChannelMonitorUpdate` being tracked as in-flight (only for the
`ReleasePaymentComplete` updates added in 71a364c13345396fd75b2287)
at the same `update_id` as other updates already in-flight and
handling post-`ChannelMonitorUpdate` actions too early, this should
only apply to releasing payment complete updates, which have no
post-`ChannelMonitorUpdate` action.

Its also possible that this leads to a regression in the future,
where we have some new post-closure update that does have a
post-`ChannelMonitorUpdate` action and we run it too early, but by
then presumably its fairly rare to have a `ChannelMonitor` for a
channel closed pre-0.1 that still needs multiple updates.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This patch fixes an integer overflow bug in the Lightning Dev Kit (LDK) rust-lightning implementation. For very old channels that were closed before version 0.1, an internal counter used to track channel monitor updates could be set to the maximum possible value (u64::MAX). When LDK later needed to generate a new update for one of these old closed channels, it tried to add 1 to that maximum value, which would overflow and cause a panic (crash). The fix replaces the simple addition with a 'saturating add,' which keeps the value at the maximum instead of wrapping around. The commit notes this is a naive fix that could theoretically cause a future regression if new types of post-closure updates are added, but for now only applies to updates that have no follow-up action.

Recommended action

Apply the patch. Users running nodes with ChannelMonitors from channels closed before LDK 0.1 should upgrade to avoid a potential panic when payment resolution or force-closure-related monitor updates are regenerated. Monitor for any future post-closure update types that may rely on unique update_id sequencing.

Security signals we found

01

Integer overflow in update_id generation for pre-0.1 closed channels

02

Potential panic/crash when processing monitor updates for legacy closed channels

03

Post-closure ChannelMonitorUpdate ID collision risk acknowledged by author

04

Saturating arithmetic used as defensive fix

Risk score

Why this scored 42/100

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