Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require to claim revoked local output in its own penalty tx post-anchor #803

Merged
merged 1 commit into from
Dec 7, 2020

Conversation

ariard
Copy link
Contributor

@ariard ariard commented Oct 8, 2020

If option_anchor_outputs applies, the cheating node can pin spends of its
HTLC-timeout/HTLC-success outputs thanks to SIGHASH_SINGLE malleability.
Using a single penalty transaction for all revoked outputs is thus unsafe as it
could be blocked to propagate long enough for the `local node's main output 's
relative timelock to expire and the cheating party escaping the penalty on this
output.

I think we may just make this an unconditional requirement, indifferently of anchors.

@halseth
Copy link
Contributor

halseth commented Oct 9, 2020

I think we can allow spending them all in a single tx, but perhaps recommend something like "if confirmation doesn't happen within X blocks from expiry, to_local should be swept separately as it might be pinned etc".

@t-bast
Copy link
Collaborator

t-bast commented Oct 12, 2020

I agree with @halseth, it's worth mentioning this potential attack (good find!) but we should be more permissive with implementers.

05-onchain.md Outdated
Note: if `option_anchor_outputs` applies, the cheating node can pin spends of its
HTLC-timeout/HTLC-success outputs thanks to SIGHASH_SINGLE malleability.
Using a single penalty transaction for all revoked outputs is thus unsafe as it
could be blocked to propagate long enough for the `_local node's main output_ 's
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO it's worth nothing more of the subtly here. If they're pinning, then in order to even get into the mempool, they're likely paying a relatively high fee, which means that if they do confirm, then there's the CSV period on the second level. Also the defender can mix things up themselves, by only sweeping one of the HTLC outputs, which would then invalidate the entire "tree" (possibly needing to pay high enough fees?) of the attacker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As usual they might pay a high fee but low-feerate, which isn't a real deterrence. Updated with the reference to CSV period. You can sweep one of the HTLC output thus invalidating the batched pinning of the attacker, but the attacker can pinning each commitment HTLC output at first broadcast as you have full-malleability for each of them. Generally I don't think we should successively "react" compared on guessed attacker moves as our transaction broadcast algorithm is public but not attacker one.

05-onchain.md Outdated
@@ -513,7 +513,10 @@ A local node:
using the revocation private key.
- SHOULD extract the payment preimage from the transaction input witness, if
it's not already known.
- MAY use a single transaction to *resolve* all the outputs.
- if `option_anchor_outputs` applies:
- MUST *resolve* the _local node's main output_ in its own penalty transaction
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps this should be "should" instead? As there're other ways to defend against this, for example: sweep every output in its own transaction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reworded, it's used now a MAY use a single transaction to *resolve* all the outputs which by the negative allow to sweep every output in its own transaction as first broadcast to mitigate. I kept the MUST if the confirmation isn't reached near to CSV expiration as suggested by Johan. Thus you're free to aggregate as you like until some point to save on fees but after it's a matter of security and should you care to confirm.

@ariard ariard force-pushed the 2020-10-no-aggregation-post-anchor branch from f079142 to ab2964c Compare October 18, 2020 16:42
@ariard
Copy link
Contributor Author

ariard commented Oct 18, 2020

Updated following Johan suggestion, making the new requirement conditional on reaching a new security_delay, i.e "if confirmation doesn't happen before reaching X blocks from expiry". I poured a recommendation for its default value but defining a variable sounds better as its exact value can be a matter of implementation policy (and the confidence if your fee-bumping logic).

@Roasbeef I was hesitant to introduce a note on a scorched earth approach as we discussed on IRC. I'm still fearful of this being used as a double-edge by an attacker to burn more of the victim actual balance than it would loss by the punishment of its channel reserve.

@ariard ariard force-pushed the 2020-10-no-aggregation-post-anchor branch from ab2964c to 788c6db Compare October 18, 2020 16:50
05-onchain.md Outdated Show resolved Hide resolved
05-onchain.md Outdated Show resolved Hide resolved
05-onchain.md Outdated Show resolved Hide resolved
@rustyrussell
Copy link
Collaborator

OK, lots of good discussion at meeting about this. The spec says MAY, because if you do make one bit tx, you need to split (as HTLC txs can race you), but you also need to split because your big tx might be pinned.

It's worth noting this, for sure, but I think we can be simpler; also why pick on the to-local output? In theory any output could be largest, and you want that one.

@ariard ariard force-pushed the 2020-10-no-aggregation-post-anchor branch 2 times, most recently from fc3bcd5 to 979b80b Compare November 8, 2020 23:32
@ariard
Copy link
Contributor Author

ariard commented Nov 8, 2020

also why pick on the to-local output? In theory any output could be largest, and you want that one.

If "you want" designates the cheating party, it's right that you can pin any largest HTLC outputs but those ones must be spent by a 2nd-level HTLC txn sooner or latter. Thus for a profitable attack to makes sense you will target the to_local output. That said, a cheating party may take hostage HTLC outputs, according to mempool conditions so better to split-off there too. Extended wording to them.

Copy link
Collaborator

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

LGTM

05-onchain.md Outdated Show resolved Hide resolved
@ariard ariard force-pushed the 2020-10-no-aggregation-post-anchor branch from 979b80b to 0374aec Compare November 9, 2020 19:22
@ariard
Copy link
Contributor Author

ariard commented Nov 9, 2020

Updated with nit fix.

Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

ACK

05-onchain.md Outdated
- MAY use a single transaction to *resolve* all the outputs.
- if confirmation doesn't happen before reaching `security_delay` blocks from
expiry:
- MUST *resolve* revoked outputs in their own, separate penalty transactions. A previous
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like SHOULD is more correct here, since the sweeping node is aware of the risk and should be allowed to do as it pleases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, @ariard I think this is the last pending point before we merge, what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We've got the ACKs on this, should we wait til this is addressed? paging @ariard

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me, it's up to the implementer to gauge risk-vs-fee-saving.

If `option_anchor_outputs` applies, the cheating node can pin spends of its
HTLC-timeout/HTLC-success outputs thanks to SIGHASH_SINGLE malleability.
Using a single penalty transaction for all revoked outputs is thus unsafe as it
could be blocked to propagate long enough for the `_local node's main output_ 's
relative timelock to expire and the cheating party escaping the penalty on this
output.
@ariard ariard force-pushed the 2020-10-no-aggregation-post-anchor branch from 0374aec to aeb19de Compare December 7, 2020 17:42
@ariard
Copy link
Contributor Author

ariard commented Dec 7, 2020

Sorry for delay, updated at aeb19de!

@t-bast
Copy link
Collaborator

t-bast commented Dec 7, 2020

Merging as agreed during the last spec meeting.

ariard pushed a commit to ariard/rust-lightning that referenced this pull request Nov 9, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Nov 17, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Nov 22, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Nov 23, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Nov 30, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Dec 9, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Dec 9, 2022
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request Apr 30, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request May 4, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request May 9, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request May 9, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request May 12, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request May 14, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
ariard pushed a commit to ariard/rust-lightning that referenced this pull request May 16, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
optout21 pushed a commit to optout21/rust-lightning that referenced this pull request Jul 24, 2023
See lightning/bolts#803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.
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.

6 participants