Skip to content

openingd: reject a peer dust_limit_satoshis below 354 sat - #9604

Open
Mohil-Ahuja wants to merge 1 commit into
ElementsProject:masterfrom
Mohil-Ahuja:fix/9403-dust-limit-floor
Open

Mohil-Ahuja wants to merge 1 commit into
ElementsProject:masterfrom
Mohil-Ahuja:fix/9403-dust-limit-floor

Conversation

@Mohil-Ahuja

Copy link
Copy Markdown

Fixes #9403.

BOLT 2 says the receiver of open_channel MUST fail the channel if dust_limit_satoshis is smaller than 354 satoshis, and the accept_channel fields 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() in openingd/common.c. That's the shared function for "is their config reasonable", and it's already called on every path: openingd as opener and fundee, and the four call sites in dualopend (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 with devtools/check_quotes.py against the pinned BOLT version (and a deliberately altered quote fails, so the check is actually comparing).

tests/fuzz/fuzz-open_channel.c clamps the generated dust limit to 354, the same way it already clamps max_accepted_htlcs, to_self_delay and the feerate to get past check_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_openingd and lightning_dualopend with 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 custom dust_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 raw open_channel, or an lnprototest case.

Checklist

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes. (Fuzz target updated; see above.)
  • Documentation has been reviewed and updated as needed. (No user-facing docs describe this bound.)
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade. (No persistent state is touched.)

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

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.

Failure to reject dust_limit_satoshis below 354 sat

1 participant