Skip to content

lightningd: reject min-capacity-sat values which overflow msat. - #9754

Open
enaples wants to merge 1 commit into
ElementsProject:masterfrom
enaples:fix-min-channel-capacity-overflow
Open

enaples wants to merge 1 commit into
ElementsProject:masterfrom
enaples:fix-min-channel-capacity-overflow

Conversation

@enaples

@enaples enaples commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

--min-capacity-sat was parsed with strtoull() and never range-checked, so a value above UINT64_MAX/1000 (or "-1", which strtoull wraps to UINT64_MAX) was accepted at startup and by setconfig. The next channel open, ours or a peer's, then hit:

lightningd: amount_msat overflow for config.min_capacity_sat
lightningd: FATAL SIGNAL 6

in channel_config(). For our own fundchannel the inputs had already been reserved by fundpsbt reserve=2016, so every attempt also left them locked for 2016 blocks.

Check the value converts to msat when parsing it, so it is refused at startup and by setconfig instead.

Changelog-Fixed: lightningd: min-capacity-sat values which overflow when converted to msat (including -1) are now rejected at startup and by setconfig, instead of crashing the node on the next channel open.

`--min-capacity-sat` was parsed with strtoull() and never range-checked, so a value above UINT64_MAX/1000 (or "-1", which strtoull wraps to UINT64_MAX) was accepted at startup and by `setconfig`.  The next channel
open, ours or a peer's, then hit:

    lightningd: amount_msat overflow for config.min_capacity_sat
    lightningd: FATAL SIGNAL 6

in channel_config().  For our own `fundchannel` the inputs had already been reserved by `fundpsbt reserve=2016`, so every attempt also left them locked for 2016 blocks.

Check the value converts to msat when parsing it, so it is refused at startup  and by `setconfig` instead.

Changelog-Fixed: lightningd: `min-capacity-sat` values which overflow when  converted to msat (including `-1`) are now rejected at startup and by  `setconfig`, instead of crashing the node on the next channel open.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant