lightningd: accept OP_RETURN closer_scriptpubkey in simple-close check#9292
Open
nGoline wants to merge 1 commit into
Open
lightningd: accept OP_RETURN closer_scriptpubkey in simple-close check#9292nGoline wants to merge 1 commit into
nGoline wants to merge 1 commit into
Conversation
A peer's closing_complete may set closer_scriptpubkey to a spec-valid OP_RETURN, but close_tx_check only whitelisted the two stored shutdown scripts, so master rejected our own signed tx and force-closed the channel. Accept a zero-value OP_RETURN output, only when option_simple_close is negotiated. Adds a regression test. Reported-by: 0xaudron Changelog-None: option_simple_close is experimental and unreleased.
f69bac7 to
c325683
Compare
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.
Under
option_simple_close, a peer'sclosing_completemay setcloser_scriptpubkeyto a spec-validOP_RETURN(BOLT2 permits it when the closer treats its output as uneconomical).closingdaccepts and signs the closing tx, but master'sclose_tx_checkvalidated every output against the two stored shutdown scripts only, so theOP_RETURNoutput matched neither, master rejected our own signed tx viachannel_internal_error, and the channel force-closed.This was remotely triggerable by any peer once the feature is negotiated.
The fix is to accept an output that is a valid, zero-value
OP_RETURN, but only whenoption_simple_closeis negotiated and only after theLOCAL-scriptmatch. Our own output is always paid toshutdown_scriptpubkey[LOCAL], so anOP_RETURNmatching neither stored script can only be the peer'scloser_scriptpubkey. Being unspendable and zero-value, accepting it preserves the check's anti-exfiltration property.Kept master-side rather than whitelisting
subd-reportednegotiated scripts + validating in the signer since that would weaken the trusted-state check and require an HSM-protocol change affecting external signers (VLS).Added
lightningd/test/run-close_tx_check.c, which covers the accept path, feature-gating, non-zero-value rejection, and that unknown spendable scripts stay rejected. Verified to fail without the fix.Reported by @0xaudron via the security process.
option_simple_closeis experimental (--experimental-simple-close, off by default) and unreleased, meaning no production exposure.