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

lnwallet/chancloser: validate delivery scripts in the RBF closer

Public commit record

What the developer wrote

Authored by Olaoluwa Osuntokun

83/100 · Strong
lnwallet/chancloser: validate delivery scripts in the RBF closer

In this commit, we make the RBF co-op closer validate the remote party's
delivery script in all cases, matching what the negotiation closer already does.
Previously we only ran the check when we had an upfront shutdown script on record
for the peer, so a peer that never committed to an upfront script could hand us a
delivery script that we'd stash and carry through the rest of the close flow
without ever looking at it.

We now always call validateShutdownScript with the (possibly nil) upfront
script: a nil upfront script still runs the well-formedness check on the peer's
script, and a non-nil one additionally enforces the exact match, same as before.
We also require the script to be present. The wire format puts no lower bound on
the address length, and validateShutdownScript treats an absent peer script as
nothing to check, so an empty one passed validation by default rather than on its
merits. Both entry points now go through one helper that insists on a script
before running the usual checks over it, which also covers a CloserScript
swapped in mid-negotiation via ClosingComplete rather than letting that one go
unchecked.

The delivery-form coverage is spelled out in the tests: the spec dropped p2pkh
and p2sh for co-op closes to keep the dust calculations uniform, and we don't
implement the OP_RETURN form that option_simple_close allows, so all of those are
rejected along with an empty or malformed script.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a bug in LND's cooperative channel-closing code where a peer could supply an invalid, empty, or even money-burning Bitcoin address during a close, and LND would accept it without checking. The fix makes the newer 'RBF' closer always validate the peer's payout address, matching what the older negotiation closer already did. Before, validation only happened if the peer had previously committed to a specific upfront address. Without that, a malicious or buggy peer could have caused funds to be sent to an unspendable or malformed script.

Recommended action

Upgrade to a release containing this commit. Nodes running LND with the RBF cooperative close path should ensure peers cannot supply malformed or unspendable shutdown scripts. Review any channels that were closed using the RBF closer for unexpected delivery scripts.

Security signals we found

01

Missing input validation on remote-supplied shutdown/delivery script

02

Empty/zero-length script accepted as valid due to nil-treatment in validator

03

Mid-negotiation script swap via ClosingComplete not validated

04

Funds could be directed to provably unspendable scripts (OP_RETURN) or unsupported legacy forms (P2PKH/P2SH)

05

Fix aligns RBF closer behavior with existing negotiation closer behavior

Risk score

Why this scored 64/100

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