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

onchaind: Close a racy onchain resolution

Public commit record

What the developer wrote

Authored by cdecker

85/100 · Strong
onchaind: Close a racy onchain resolution

Upon timing out an upstream incoming HTLC, we were setting the
resolution to be ignored, since the funds will presumably be returned
to the peer, not us. However, since the HTLC timeout and the internal
resolution do not line up perfectly, due to the security margin, there
is a chance for a late preimage coming in, resolving the HTLC in the
other direction, i.e., we now own it. If that resolution comes in
after we have internally marked the output as ignored, we would not
clean up our prior decision, leaving the HTLC stranded, but
recoverable.

This just ensures that we clear our internal resolution too, when the
downstream preimage comes in, so that we can use the preimage to grab
the funds in the HTLC.

Changelog-Fixed: onchaind: Fixed a race between preimage return from downstream to upstream
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This fix addresses a timing bug in Core Lightning's on-chain dispute handler. When a payment hash preimage arrives late from a downstream peer, the software could have already marked the related funds as 'ignored' because the upstream timeout had passed. The old code stopped processing once it saw an existing resolution, leaving the funds stuck. The fix clears the prior 'ignored' resolution so the late preimage can still be used to claim the funds. It is a recoverable race condition, not a direct theft of funds, but it could delay or complicate recovery of HTLC funds during on-chain settlement.

Recommended action

Apply the patch. Nodes running earlier versions should upgrade if they route HTLCs that may settle on-chain, especially where downstream preimages can arrive near upstream timeout deadlines. Monitor onchaind logs for 'HTLC already resolved ... when we found preimage' to detect historical occurrences.

Security signals we found

01

Race condition between upstream HTLC timeout and downstream preimage

02

Prior resolution not cleared, potentially stranding HTLC funds

03

Fix clears both proposal and resolved state when preimage arrives

04

Changelog labels this as a fixed race in onchaind

Risk score

Why this scored 57/100

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