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

lightningd: store the revocation secret before acting on its HTLCs

Public commit record

What the developer wrote

Authored by Christian Decker

73/100 · Adequate
lightningd: store the revocation secret before acting on its HTLCs

peer_got_revoke() applied the HTLC changes which a revoke_and_ack
locks in -- forwarding the final accepts, settling updates and
failing fails -- before it had checked the revocation secret. If
wallet_shachain_add_hash() rejects that secret we fail the channel
anyway, so it must not act on them first.

Run the shachain and revokenum checks before acting on the HTLCs.
Nothing in between touches HTLC state, and crash-consistency is
unchanged: sd_msg_read() wraps every channeld message in a single DB
transaction, so a crash replays the whole message or nothing.

Reported-by: Erick C (@erickcestari)
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes an ordering bug in Core Lightning's handling of 'revoke_and_ack' messages from a peer. Previously, the node would apply pending HTLC (payment channel) changes—such as forwarding payments or settling/failing them—before verifying and storing the peer's revocation secret. If that secret was invalid, the channel would be closed anyway, but only after the HTLC state had already been altered. The fix moves the revocation-secret verification and storage to happen before any HTLC state changes, preventing a potentially inconsistent or exploitable state.

Recommended action

Treat as a security-relevant correctness fix. Review whether the prior ordering could have led to loss of funds or channel inconsistency in adversarial scenarios, and consider backporting to supported releases. No immediate emergency response is indicated by the diff alone, but a security advisory may be warranted if further analysis confirms exploitability.

Security signals we found

01

State-machine ordering bug: HTLC effects applied before revocation secret validation

02

Potential inconsistency if invalid revocation leads to channel failure after HTLC mutation

03

Fix explicitly moves secret storage before HTLC state changes

04

Reported by external contributor Erick C (@erickcestari)

Risk score

Why this scored 63/100

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