Repository navigation
openingd: reject a peer dust_limit_satoshis below 354 sat - #9604
Open
Mohil-Ahuja wants to merge 1 commit into
Open
Mohil-Ahuja wants to merge 1 commit into
Mohil-Ahuja wants to merge 1 commit into
Conversation
BOLT 2 requires the receiver of open_channel to fail the channel when dust_limit_satoshis is smaller than 354 satoshis, and accept_channel fields carry the same requirements. We never checked the lower bound, so a peer could open (or accept) a channel with a dust limit as low as 1 sat, making its commitment transactions non-standard. Add the check to check_config_bounds(), which both openingd and dualopend call for open_channel/accept_channel and their v2 forms, so every path is covered. The open_channel fuzz target clamps the dust limit like the other fields it adjusts to get past check_config_bounds(). Fixes: ElementsProject#9403 Changelog-Fixed: Protocol: we now reject channel opens where the peer's `dust_limit_satoshis` is below 354 satoshis, as BOLT 2 requires.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9403.
BOLT 2 says the receiver of
open_channelMUST fail the channel ifdust_limit_satoshisis smaller than 354 satoshis, and theaccept_channelfields carry the same requirements. We never checked the lower bound, so a peer could set a dust limit as low as 1 sat and end up with non-standard commitment transactions.The check goes in
check_config_bounds()inopeningd/common.c. That's the shared function for "is their config reasonable", and it's already called on every path:openingdas opener and fundee, and the four call sites indualopend(v2 open, accept and RBF). So one check covers all of them, instead of adding it to each daemon separately. The comment quotes the spec line verbatim; I checked it withdevtools/check_quotes.pyagainst the pinned BOLT version (and a deliberately altered quote fails, so the check is actually comparing).tests/fuzz/fuzz-open_channel.cclamps the generated dust limit to 354, the same way it already clampsmax_accepted_htlcs,to_self_delayand the feerate to get pastcheck_config_bounds(), so the fuzzer keeps reaching the rest of the fundee flow.Our own dust limit is 546 on every chain in
chainparams.c, so CLN-to-CLN opens are unaffected.Tests
I built
lightning_openingdandlightning_dualopendwith the change. I haven't added a Python test: as far as I can see none of the existing tests can make a peer send a customdust_limit_satoshis, since we always send our own 546. If you'd like coverage beyond the fuzz target, I'm happy to add a pyln-proto based test that sends a rawopen_channel, or an lnprototest case.Checklist
tools/lightning-downgrade. (No persistent state is touched.)