Skip to content

Check for preimage before failing back missing HTLCs#1233

Merged
t-bast merged 1 commit into
lightning:masterfrom
morehouse:check_preimage_before_failback
Mar 11, 2025
Merged

Check for preimage before failing back missing HTLCs#1233
t-bast merged 1 commit into
lightning:masterfrom
morehouse:check_preimage_before_failback

Conversation

@morehouse

Copy link
Copy Markdown
Contributor

When an outstanding HTLC is missing from a confirmed commitment, the current recommendation is to fail it back immediately (or after a reorg-safety delay). But if a preimage is available for the HTLC, failing it back is at best going to cause an error (if the HTLC has already been fulfilled upstream) and at worst going to cause loss of funds (if the HTLC has not already been fulfilled upstream).

Instead, the spec should clearly indicate that upstream HTLCs should be fulfilled when possible and only failed back if a preimage is not available.

Motivated by https://morehouse.github.io/lightning/lnd-excessive-failback-exploit/.

@t-bast t-bast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is much better!

Comment thread 05-onchain.md Outdated
When an outstanding HTLC is missing from a confirmed commitment, the
current recommendation is to fail it back immediately (or after a
reorg-safety delay).  But if a preimage is available for the HTLC,
failing it back is at best going to cause an error (if the HTLC has
already been fulfilled upstream) and at worst going to cause loss of
funds (if the HTLC has *not* already been fulfilled upstream).

Instead, the spec should clearly indicate that upstream HTLCs should be
fulfilled when possible and only failed back if a preimage is not
available.
@morehouse morehouse force-pushed the check_preimage_before_failback branch from 5dcc39e to ac35563 Compare March 5, 2025 14:44

@t-bast t-bast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ac35563

@Roasbeef Roasbeef left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🏎️

@Roasbeef

Roasbeef commented Mar 6, 2025

Copy link
Copy Markdown
Collaborator

@rustyrussell @TheBlueMatt anything to add here? From Morehouse's report, looks like y'all fixed a similar bug in the past.

@TheBlueMatt

Copy link
Copy Markdown
Collaborator

I went back and checked and it looks like the bug we fixed a while back that @morehouse pointed to was in fact a different but vaguely related bug (marking an outbound, not forwarded, payment as paid and then allowing it to revert to unpaid on restart). I'm not entirely convinced that this spec change would save bugs (and people definitely should be thinking deeper than just blindly implementing the spec!), but certainly don't have any issues with this change.

@rustyrussell rustyrussell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack ac35563

@t-bast t-bast merged commit 216914d into lightning:master Mar 11, 2025
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.

5 participants