Research/Bitcoin Dev Archive / lightning-dev list
"Updates Overflow" Attacks against Two-Party Eltoo ?
6 messages, Dec 13 to 14, 2022. Started by Antoine Riard.
Antoine Riard (3), Anthony Towns (2), Greg Sanders
Hi list,
The following post describes a potential attack vector against eltoo-based Lightning channels, from my understanding also including the recent two-party eltoo w/ punishment construction. While I think this concern has been known for a while among devs, and I believe it's mitigable by adopting an adequate fee-bumping strategy, I still wonder how exactly it affects eltoo-based constructions.
AFAICT, the eltoo 2-stage proposal relies on a serie of pre-signed update transactions, of which in the optimistic case only one of them confirms. There is a script-spend path, where an update transaction N can spend an update transaction K, assuming K<N and an aggregated musig for the checksigverify.
The attack purpose is to delay the confirmation of the final settlement transaction S, to double-spend a HTLC forwarded by a routing hop. I.e you have Ned the routing hop receiving the HTLC from Mallory upstream and sending the HTLC to Malicia downstream. Thanks to the cltv_expiry_delta, the HTLC forward should be safe as Ned can timeout the HTLC on the Ned-Malicia link before it is timed-out by Mallory on the Mallory-Ned link. In case of timeout failure, Malicia can claim the HTLC forward with the corresponding preimage, at the same block height than Mallory timeout the HTLC, effectively double-spending Ned.
The cltv_expiry_delta requested by Ned is equal to N=144.
The attack scenario works in the following way: Malicia updates the Eltoo channel N time, getting the possession of N update transactions. At block A, she breaks the channel and confirms the update transaction 0 by attaching a feerate equal to or superior to top mempool block space + 1 sat. At each new block, she iterates by confirming the next update transaction, i.e update transaction 1 at block A+1, update transaction transaction 2 at block A+2, update transaction 3 at block A+3, ...
Quoted text (1 line)
>From Ned's viewpoint, there is limited rationality of the network mempools,
as such each punishment transaction R, as it's confirmation could have been delay due to "honest" slow propagation on the network is likely to be pre-signed with top mempool block space feerate, but not more to save on fees. Therefore, transaction RN.0 should fail to punish update transaction 0 as it's double-spent by update transaction 1, transaction RN.1 should fail to punish update transaction 1 as it's double-spent by update transaction 2, transaction RN.2 should fail to punish update transaction 2 as it's double-spent by update transaction 3...
While there is a RBF-race, I think this can be easily won by Malicia by mass-connecting on the transaction-relay network and ignoring the Core transaction-relay delay timers (here for privacy purposes iirc).
If it holds, I think the attack is economically opportun as long as the sum of the chain of update transactions weight multiplied by the spent feerate is inferior to the sum of HTLC values stolen (upper bounded to `max_htlc_value_in_flight_msat`, not `funding_satoshis`). The attack could be more sound in periods of low-fee, as the number of HTLC exploitable is higher.
A mitigation could be for a fee-bumping strategy to adopt a scorched approach when the HTLC-timeout is approaching, and there is a corresponding incoming HTLC. When the HTLC-timeout is near expiration (e.g X blocks from incoming HTLC expiry), probably 100% of the HTLC value should be burnt in update transaction fees.
I think some implementations in the LN-penalty are already doing "upward" fee-bumping frequency, while I believe it reduces the attack surface, I still think there is an exploitable window for "update overflow" attack. E.g in LDK justice transactions are bumped by 25% every block according to a height timer schedule [0].
Assuming the attack holds, and scorched approach are adopted by default to mitigate this concern, there is a second-order concern, we might open Lightning channels to miner-harvesting attacks, where the confirmation of the update transactions are deferred to kick-out the scorched earth reaction of the fee-bumping engine. In my opinion, this would be still an improvement, as we're moving a (plausible) security risk triggerable by a Lightning counterparty to (hypothetical) one triggerable by a wide coalition of miners.
There is another caveat, it sounds if the update transaction can be malleable (i.e SIGHASH_SINGLE|ANYONECANPAY), update transactions across Lightning channels could be aggregated by the attacker, changing the economy there in a way defavorable to the victims. I.e the attacker can select the targeted channels, but the victim cannot coordinate with each other to respond with a collective fee-bumping.
Is the understanding of the two-party eltoo construction correct, and this "update overflow" attack is sound and economically opportun ? If it holds, I still wonder if we have variants playing with mempool descendant limits. In all cases, it sounds to me the implications are more in the way fee-bumping is implemented by Lightning softwares rather than directly on eltoo-based constructions, I don't see an immediate way to address it by the construction itself.
Mistakes and confusions are my own.
Antoine
On Mon, Dec 12, 2022 at 08:38:43PM -0500, Antoine Riard wrote:
Quoted text (3 lines)
> The attack purpose is to delay the confirmation of the final settlement > transaction S, to double-spend a HTLC forwarded by a routing hop. > The cltv_expiry_delta requested by Ned is equal to N=144.
I believe what you're suggesting here is:
Mallory has two channels with Bob, M1 and M2. Both have a to_self_delay of 144 blocks. In that case cltv_expiry_delay should include some slack, I'm going to assume it's 154 blocks in total.
Mallory forwards a large payment, M1->Bob->M2.
Mallory claims the funds on M2 just prior to the timeout, but goes offline on M1.
Bob chose the timeout for M2 via cltv_expiry_delay, so now has 154 blocks before the CLTV on the M1->Bob payment expires.
In this scenario, under the two-party eltoo scheme, Bob should:
1) immediately broadcast the most recent UB.n state for M1/Bob,
aiming for this to be confirmed within 5 blocks
2) wait 144 blocks for the relative timelock to expire
3) broadcast SB.n to finalise the funds, and immediately claim the
large HTLC. providing this confirms within 5 blocks, it will confirm
before the HTLC timelock expires, and Mallory will have been unable
to claim the funds.
The only transactions Mallory could broadcast are:
prior to (1): UA.k (k <= n) -- However this allows Bob to immediately broadcast one of either CA.n or RA.n, and will then have ~150 blocks to claim the HTLC before its timeout
during (2): CA.n -- Again, this allows Bob to claim the HTLC immediately, prior to its timeout
The only delaying attack with repeated transactions comes if Bob broadcasts an old state UB.k (k < n), in which case Mallory can broadcast (n-k) WA.i watchtower transactions prior to finalising the state. However if Bob *only* has old state, Mallory can simply broadcast WA.n, at which point Bob can do nothing, as (by assumption) he doesn't have access to current state and thus doesn't have SB.n to broadcast it.
Quoted text (7 lines)
> The attack scenario works in the following way: Malicia updates the Eltoo > channel N time, getting the possession of N update transactions. At block > A, she breaks the channel and confirms the update transaction 0 by > attaching a feerate equal to or superior to top mempool block space + 1 > sat. At each new block, she iterates by confirming the next update > transaction, i.e update transaction 1 at block A+1, update transaction > transaction 2 at block A+2, update transaction 3 at block A+3, ...
I think traditional eltoo envisages being able to spend update transaction 1 immediately, without having to wait for the next block. This might not be compatible with the version 3 relay rules that are being thought about, though, and presumably would hit ancestor limits.
I think a simple way to avoid that problem would be for eltoo nodes to have a priority tx relay network -- if they see a channel close to state N, always replace any txs closing to an earlier state K<N, and always quickly relay that close to all other peers. There's no reason to assume the bad guys have the best access to the network when we can write code so that the honest participants have it instead.
Quoted text (9 lines)
> From Ned's viewpoint, there is limited rationality of the network mempools, > as such each punishment transaction R, as it's confirmation could have been > delay due to "honest" slow propagation on the network is likely to be > pre-signed with top mempool block space feerate, but not more to save on > fees. Therefore, transaction RN.0 should fail to punish update transaction > 0 as it's double-spent by update transaction 1, transaction RN.1 should > fail to punish update transaction 1 as it's double-spent by update > transaction 2, transaction RN.2 should fail to punish update transaction 2 > as it's double-spent by update transaction 3...
In the two-party scheme, the only transaction Mallory can broadcast after sending UA.k and having it confirmed on chain is SA.k, and that only after a 144 block relative timelock. UA.(k+1) etc only spend the funding output, but that has already been spent by UA.k.
Cheers, aj
Hi Antoine,
Nothing you say here(about vanilla eltoo) sounds absurd.
Quoted text (8 lines)
> Therefore, transaction RN.0 should fail to punish update transaction 0 as it's double-spent by update transaction 1, transaction RN.1 should fail to punish update transaction 1 as it's double-spent by update transaction 2, transaction RN.2 should fail to punish update transaction 2 as it's double-spent by update transaction 3... >While there is a RBF-race, I think this can be easily won by Malicia by mass-connecting on the transaction-relay network and ignoring the Core transaction-relay delay timers (here for privacy purposes iirc).
Right, there are some network-level games that can be played, however honest participants can be given a leg up through as AJ notes, alternative relays, or even a "rebinder" widget which means only the single highest fee bidding copy of the final update transaction has to make it to the miners' mempool. So if the honest party bids X% of the HTLC value in fees, the attacker will be paying more than that every single block, constantly racing, until it loses either a mempool race or the latest bid.
I'm starting simple and assuming we don't need all this machinery, and hope the risk of counterparty either losing the race a single time, or being outbid a single time is enough to dissuade an attack at all.
Quoted text (5 lines)
> A mitigation could be for a fee-bumping strategy to adopt a scorched approach when the HTLC-timeout is approaching, and there is a corresponding incoming HTLC. When the HTLC-timeout is near expiration (e.g X blocks from incoming HTLC expiry), probably 100% of the HTLC value should be burnt in update transaction fees.
I kind of always thought that's how HTLCs would have worked in theory and practice eventually. As the clock runs down you're willing to spend more to take less of the full value.
Quoted text (8 lines)
> Assuming the attack holds, and scorched approach are adopted by default to mitigate this concern, there is a second-order concern, we might open Lightning channels to miner-harvesting attacks, where the confirmation of the update transactions are deferred to kick-out the scorched earth reaction of the fee-bumping engine. In my opinion, this would be still an improvement, as we're moving a (plausible) security risk triggerable by a Lightning counterparty to (hypothetical) one triggerable by a wide coalition of miners.
As I said before, I think this is already the case. We're assuming liveliness of blockchain for these contracts, if a unilateral close gets targeted by a large fraction of miners, I don't think eltoo is the risk, it's the HTLC constract that's the risk.
Quoted text (6 lines)
> There is another caveat, it sounds if the update transaction can be malleable (i.e SIGHASH_SINGLE|ANYONECANPAY), update transactions across Lightning channels could be aggregated by the attacker, changing the economy there in a way defavorable to the victims. I.e the attacker can select the targeted channels, but the victim cannot coordinate with each other to respond with a collective fee-bumping.
In my current eltoo design, I'm assuming *by policy* APO (V3?) transactions can only have one input, and each transaction is only allowed a single ephemeral anchor which is attached but not committed to by the SIGHASH_SINGLE|APOAS signature. This results in a 1-input-2-output transaction that isn't malleable. If and when we figure out how to un-pin these kinds of transactions, this policy can be relaxed, and we can get the benefits of aggregated transactions.
Cheers, Greg
On Mon, Dec 12, 2022 at 8:39 PM Antoine Riard <antoine.riard at gmail.com> wrote:
Quoted text (103 lines)
> Hi list, > > The following post describes a potential attack vector against eltoo-based > Lightning channels, from my understanding also including the recent > two-party eltoo w/ punishment construction. While I think this concern has > been known for a while among devs, and I believe it's mitigable by adopting > an adequate fee-bumping strategy, I still wonder how exactly it affects > eltoo-based constructions. > > AFAICT, the eltoo 2-stage proposal relies on a serie of pre-signed update > transactions, of which in the optimistic case only one of them confirms. > There is a script-spend path, where an update transaction N can spend an > update transaction K, assuming K<N and an aggregated musig for the > checksigverify. > > The attack purpose is to delay the confirmation of the final settlement > transaction S, to double-spend a HTLC forwarded by a routing hop. I.e you > have Ned the routing hop receiving the HTLC from Mallory upstream and > sending the HTLC to Malicia downstream. Thanks to the cltv_expiry_delta, > the HTLC forward should be safe as Ned can timeout the HTLC on the > Ned-Malicia link before it is timed-out by Mallory on the Mallory-Ned link. > In case of timeout failure, Malicia can claim the HTLC forward with the > corresponding preimage, at the same block height than Mallory timeout the > HTLC, effectively double-spending Ned. > > The cltv_expiry_delta requested by Ned is equal to N=144. > > The attack scenario works in the following way: Malicia updates the Eltoo > channel N time, getting the possession of N update transactions. At block > A, she breaks the channel and confirms the update transaction 0 by > attaching a feerate equal to or superior to top mempool block space + 1 > sat. At each new block, she iterates by confirming the next update > transaction, i.e update transaction 1 at block A+1, update transaction > transaction 2 at block A+2, update transaction 3 at block A+3, ... > > From Ned's viewpoint, there is limited rationality of the network > mempools, as such each punishment transaction R, as it's confirmation could > have been delay due to "honest" slow propagation on the network is likely > to be pre-signed with top mempool block space feerate, but not more to save > on fees. Therefore, transaction RN.0 should fail to punish update > transaction 0 as it's double-spent by update transaction 1, transaction > RN.1 should fail to punish update transaction 1 as it's double-spent by > update transaction 2, transaction RN.2 should fail to punish update > transaction 2 as it's double-spent by update transaction 3... > > While there is a RBF-race, I think this can be easily won by Malicia by > mass-connecting on the transaction-relay network and ignoring the Core > transaction-relay delay timers (here for privacy purposes iirc). > > If it holds, I think the attack is economically opportun as long as the > sum of the chain of update transactions weight multiplied by the spent > feerate is inferior to the sum of HTLC values stolen (upper bounded to > `max_htlc_value_in_flight_msat`, not `funding_satoshis`). The attack could > be more sound in periods of low-fee, as the number of HTLC exploitable is > higher. > > A mitigation could be for a fee-bumping strategy to adopt a scorched > approach when the HTLC-timeout is approaching, and there is a corresponding > incoming HTLC. When the HTLC-timeout is near expiration (e.g X blocks from > incoming HTLC expiry), probably 100% of the HTLC value should be burnt in > update transaction fees. > > I think some implementations in the LN-penalty are already doing "upward" > fee-bumping frequency, while I believe it reduces the attack surface, I > still think there is an exploitable window for "update overflow" attack. > E.g in LDK justice transactions are bumped by 25% every block according to > a height timer schedule [0]. > > Assuming the attack holds, and scorched approach are adopted by default to > mitigate this concern, there is a second-order concern, we might open > Lightning channels to miner-harvesting attacks, where the confirmation of > the update transactions are deferred to kick-out the scorched earth > reaction of the fee-bumping engine. In my opinion, this would be still an > improvement, as we're moving a (plausible) security risk triggerable by a > Lightning counterparty to (hypothetical) one triggerable by a wide > coalition of miners. > > There is another caveat, it sounds if the update transaction can be > malleable (i.e SIGHASH_SINGLE|ANYONECANPAY), update transactions across > Lightning channels could be aggregated by the attacker, changing the > economy there in a way defavorable to the victims. I.e the attacker can > select the targeted channels, but the victim cannot coordinate with each > other to respond with a collective fee-bumping. > > Is the understanding of the two-party eltoo construction correct, and this > "update overflow" attack is sound and economically opportun ? If it holds, > I still wonder if we have variants playing with mempool descendant limits. > In all cases, it sounds to me the implications are more in the way > fee-bumping is implemented by Lightning softwares rather than directly on > eltoo-based constructions, I don't see an immediate way to address it by > the construction itself. > > Mistakes and confusions are my own. > > Antoine > > [0] > https://github.com/lightningdevkit/rust-lightning/blob/5e14c24a11f610ab8c402f788ec5bd637e9e24af/lightning/src/chain/onchaintx.rs#L505 > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Hi AJ,
I believe we're in sync on the attack description.
Quoted text (4 lines)
> prior to (1): UA.k (k <= n) -- However this allows Bob to immediately > broadcast one of either CA.n or RA.n, and will then have ~150 blocks > to claim the HTLC before its timeout >From my understanding, with two party eltoo w/punihsment, UA.k has a
tapscript path with "1 CHECKSIGVERIFY k<n CLTV", where the internal pubkey substituted is "musig(A,B)/1. Mallory should receive Bob's signature for UA.k, though also UA.k+1, UA.k+2, UAk+3, until k=n.
Or is this a tapscript only existing for the dual-funding case ? I think this a bit unclear from the gist construction, how Mallory is restrained to use the tapscript path on UA.k, with UA.k+1 as she should be in possession of Bob's signature for this state.
Quoted text (4 lines)
> I think traditional eltoo envisages being able to spend update transaction > 1 immediately, without having to wait for the next block. This might > not be compatible with the version 3 relay rules that are being thought > about, though, and presumably would hit ancestor limits.
While update transaction 1 could spend update transaction 0 immediately, there is no reliable knowledge by U*.1 transaction broadcaster of the state of the network mempools. I believe the update transactions themselves could be used to partition network mempools in multiple subsets (at least this is achievable under LN-penalty with using old revoked states).
Quoted text (6 lines)
> I think a simple way to avoid that problem would be for eltoo nodes > to have a priority tx relay network -- if they see a channel close to > state N, always replace any txs closing to an earlier state K<N, and > always quickly relay that close to all other peers. There's no reason > to assume the bad guys have the best access to the network when we can > write code so that the honest participants have it instead.
While I think this solution of eltoo nodes quickly replacing any state K previous to the latest state N, there is no guarantee the latest state K doesn't offer a higher feerate than state N, making it more attractive to the miners.
One other solution could be a p2p extension allowing an update transaction N to be "blindly" rebinded on any update transaction K, with K < N, by pointing to the channel funding output, and a per-counterparty ancestor limit enforced as a policy rule (otherwise the malicious counterparty could still buy all the ancestor limits).
A more sophisticated solution could be to "trim" the counterparty ability to confirm multiple update transactions with some TLUV mechanism.
Quoted text (4 lines)
> In the two-party scheme, the only transaction Mallory can broadcast > after sending UA.k and having it confirmed on chain is SA.k, and that > only after a 144 block relative timelock. UA.(k+1) etc only spend the > funding output, but that has already been spent by UA.k.
See above question on the existence of a tapscript 1 path in update transaction, and by which transaction type it could/should be spent. I think the crux of the attack's soundness (or not) against two parties eltoo w/ punishment relies here. AFAICT, if there is an unbounded spending path cycle introduced for one of the counterparties, you're exposed to "eltoo states overflow".
Best, Antoine
Le lun. 12 déc. 2022 à 22:51, Anthony Towns <aj at erisian.com.au> a écrit :
Quoted text (89 lines)
> On Mon, Dec 12, 2022 at 08:38:43PM -0500, Antoine Riard wrote: > > The attack purpose is to delay the confirmation of the final settlement > > transaction S, to double-spend a HTLC forwarded by a routing hop. > > The cltv_expiry_delta requested by Ned is equal to N=144. > > I believe what you're suggesting here is: > > Mallory has two channels with Bob, M1 and M2. Both have a to_self_delay > of 144 blocks. In that case cltv_expiry_delay should include some slack, > I'm going to assume it's 154 blocks in total. > > Mallory forwards a large payment, M1->Bob->M2. > > Mallory claims the funds on M2 just prior to the timeout, but > goes offline on M1. > > Bob chose the timeout for M2 via cltv_expiry_delay, so now has 154 > blocks before the CLTV on the M1->Bob payment expires. > > In this scenario, under the two-party eltoo scheme, Bob should: > > 1) immediately broadcast the most recent UB.n state for M1/Bob, > aiming for this to be confirmed within 5 blocks > > 2) wait 144 blocks for the relative timelock to expire > > 3) broadcast SB.n to finalise the funds, and immediately claim the > large HTLC. providing this confirms within 5 blocks, it will confirm > before the HTLC timelock expires, and Mallory will have been unable > to claim the funds. > > The only transactions Mallory could broadcast are: > > prior to (1): UA.k (k <= n) -- However this allows Bob to immediately > broadcast one of either CA.n or RA.n, and will then have ~150 blocks > to claim the HTLC before its timeout > > during (2): CA.n -- Again, this allows Bob to claim the HTLC > immediately, prior to its timeout > > The only delaying attack with repeated transactions comes if Bob > broadcasts an old state UB.k (k < n), in which case Mallory can broadcast > (n-k) WA.i watchtower transactions prior to finalising the state. However > if Bob *only* has old state, Mallory can simply broadcast WA.n, at which > point Bob can do nothing, as (by assumption) he doesn't have access > to current state and thus doesn't have SB.n to broadcast it. > > > The attack scenario works in the following way: Malicia updates the Eltoo > > channel N time, getting the possession of N update transactions. At block > > A, she breaks the channel and confirms the update transaction 0 by > > attaching a feerate equal to or superior to top mempool block space + 1 > > sat. At each new block, she iterates by confirming the next update > > transaction, i.e update transaction 1 at block A+1, update transaction > > transaction 2 at block A+2, update transaction 3 at block A+3, ... > > I think traditional eltoo envisages being able to spend update transaction > 1 immediately, without having to wait for the next block. This might > not be compatible with the version 3 relay rules that are being thought > about, though, and presumably would hit ancestor limits. > > I think a simple way to avoid that problem would be for eltoo nodes > to have a priority tx relay network -- if they see a channel close to > state N, always replace any txs closing to an earlier state K<N, and > always quickly relay that close to all other peers. There's no reason > to assume the bad guys have the best access to the network when we can > write code so that the honest participants have it instead. > > > From Ned's viewpoint, there is limited rationality of the network > mempools, > > as such each punishment transaction R, as it's confirmation could have > been > > delay due to "honest" slow propagation on the network is likely to be > > pre-signed with top mempool block space feerate, but not more to save on > > fees. Therefore, transaction RN.0 should fail to punish update > transaction > > 0 as it's double-spent by update transaction 1, transaction RN.1 should > > fail to punish update transaction 1 as it's double-spent by update > > transaction 2, transaction RN.2 should fail to punish update transaction > 2 > > as it's double-spent by update transaction 3... > > In the two-party scheme, the only transaction Mallory can broadcast > after sending UA.k and having it confirmed on chain is SA.k, and that > only after a 144 block relative timelock. UA.(k+1) etc only spend the > funding output, but that has already been spent by UA.k. > > Cheers, > aj >
Hi Greg,
Quoted text (8 lines)
> Right, there are some network-level games that can be played, however > honest participants can be given a leg up through as AJ notes, alternative > relays, or even a "rebinder" widget which means only the single highest fee > bidding copy of the final update transaction has to make it to the miners' > mempool. So if the honest party bids X% of the HTLC value in fees, the > attacker will be paying more than that every single block, > constantly racing, until it loses either a mempool race or the latest bid.
Yes, I think you could have a p2p extension enabling "blind" rebinding on a chain of update transactions by pointing to the known channel funding output. However, the attacker might still pay the mempool feerate (assuming nversion=3), and win any round of the race. As noted in the description, the attack opportunity relies on some economic bounds, like the HTLC value, the CLTV expiry delta and the mempool backlog.
Quoted text (1 line)
> A mitigation could be for a fee-bumping strategy to adopt a scorched
approach when the HTLC-timeout is approaching, and there is a corresponding incoming HTLC. When the HTLC-timeout is near expiration (e.g X blocks from incoming HTLC expiry), probably 100% of the HTLC value should be burnt in update transaction fees.
Quoted text (4 lines)
> I kind of always thought that's how HTLCs would have worked in theory and > practice eventually. As the clock runs down you're willing to spend more to > take less of the full value.
One of the biggest unknown from a fee-bumping strategy design is the fee-bump delta you should attach in function of your prediction of mempool backlogs. To the best of my knowledge, this is not how current generations of fee-estimators are working.
Quoted text (4 lines)
> As I said before, I think this is already the case. We're assuming > liveliness of blockchain for these contracts, if a unilateral close gets > targeted by a large fraction of miners, I don't think eltoo is the risk, > it's the HTLC constract that's the risk.
Yes, here it's just under LN-penalty. I think the rational fee-bumping strategy is to target top mempool feerate backlog (assuming nversion=3), as during the HTLC CLTV delay, there is no competition from the counterparty. So I agree the HTLC contract is the risk itself, though the dimensions of the miners bribery attacks might be changed under eltoo.
Quoted text (9 lines)
> In my current eltoo design, I'm assuming *by policy* APO (V3?) transactions > can only have one input, and each transaction is only allowed a single > ephemeral anchor which is attached but not committed to by the > SIGHASH_SINGLE|APOAS signature. This results in a 1-input-2-output > transaction that isn't malleable. If and when we figure out how to un-pin > these kinds of transactions, this policy can be relaxed, and we can get the > benefits of aggregated transactions.
I think this is the most conservative design for now, to restrain malleability of transactions to the minimum, as aggregation transactions can be played out by honest channel participants by an adversary.
Best, Antoine
Le mar. 13 déc. 2022 à 09:47, Greg Sanders <gsanders87 at gmail.com> a écrit :
Quoted text (175 lines)
> Hi Antoine, > > Nothing you say here(about vanilla eltoo) sounds absurd. > > > Therefore, transaction RN.0 should fail to punish update transaction 0 > as it's double-spent by update transaction 1, transaction RN.1 should fail > to punish update transaction 1 as it's double-spent by update transaction > 2, transaction RN.2 should fail to punish update transaction 2 as it's > double-spent by update transaction 3... > > >While there is a RBF-race, I think this can be easily won by Malicia by > mass-connecting on the transaction-relay network and ignoring the Core > transaction-relay delay timers (here for privacy purposes iirc). > > Right, there are some network-level games that can be played, however > honest participants can be given a leg up through as AJ notes, alternative > relays, or even a "rebinder" widget which means only the single highest fee > bidding copy of the final update transaction has to make it to the miners' > mempool. So if the honest party bids X% of the HTLC value in fees, the > attacker will be paying more than that every single block, > constantly racing, until it loses either a mempool race or the latest bid. > > I'm starting simple and assuming we don't need all this machinery, and > hope the risk of counterparty either losing the race a single time, or > being outbid a single time is enough to dissuade an attack at all. > > > A mitigation could be for a fee-bumping strategy to adopt a scorched > approach when the HTLC-timeout is approaching, and there is a corresponding > incoming HTLC. When the HTLC-timeout is near expiration (e.g X blocks from > incoming HTLC expiry), probably 100% of the HTLC value should be burnt in > update transaction fees. > > I kind of always thought that's how HTLCs would have worked in theory and > practice eventually. As the clock runs down you're willing to spend more to > take less of the full value. > > > Assuming the attack holds, and scorched approach are adopted by default > to mitigate this concern, there is a second-order concern, we might open > Lightning channels to miner-harvesting attacks, where the confirmation of > the update transactions are deferred to kick-out the scorched earth > reaction of the fee-bumping engine. In my opinion, this would be still an > improvement, as we're moving a (plausible) security risk triggerable by a > Lightning counterparty to (hypothetical) one triggerable by a wide > coalition of miners. > > As I said before, I think this is already the case. We're assuming > liveliness of blockchain for these contracts, if a unilateral close gets > targeted by a large fraction of miners, I don't think eltoo is the risk, > it's the HTLC constract that's the risk. > > > There is another caveat, it sounds if the update transaction can be > malleable (i.e SIGHASH_SINGLE|ANYONECANPAY), update transactions across > Lightning channels could be aggregated by the attacker, changing the > economy there in a way defavorable to the victims. I.e the attacker can > select the targeted channels, but the victim cannot coordinate with each > other to respond with a collective fee-bumping. > > In my current eltoo design, I'm assuming *by policy* APO (V3?) > transactions can only have one input, and each transaction is only allowed > a single ephemeral anchor which is attached but not committed to by the > SIGHASH_SINGLE|APOAS signature. This results in a 1-input-2-output > transaction that isn't malleable. If and when we figure out how to un-pin > these kinds of transactions, this policy can be relaxed, and we can get the > benefits of aggregated transactions. > > Cheers, > Greg > > On Mon, Dec 12, 2022 at 8:39 PM Antoine Riard <antoine.riard at gmail.com> > wrote: > >> Hi list, >> >> The following post describes a potential attack vector against >> eltoo-based Lightning channels, from my understanding also including the >> recent two-party eltoo w/ punishment construction. While I think this >> concern has been known for a while among devs, and I believe it's mitigable >> by adopting an adequate fee-bumping strategy, I still wonder how exactly it >> affects eltoo-based constructions. >> >> AFAICT, the eltoo 2-stage proposal relies on a serie of pre-signed update >> transactions, of which in the optimistic case only one of them confirms. >> There is a script-spend path, where an update transaction N can spend an >> update transaction K, assuming K<N and an aggregated musig for the >> checksigverify. >> >> The attack purpose is to delay the confirmation of the final settlement >> transaction S, to double-spend a HTLC forwarded by a routing hop. I.e you >> have Ned the routing hop receiving the HTLC from Mallory upstream and >> sending the HTLC to Malicia downstream. Thanks to the cltv_expiry_delta, >> the HTLC forward should be safe as Ned can timeout the HTLC on the >> Ned-Malicia link before it is timed-out by Mallory on the Mallory-Ned link. >> In case of timeout failure, Malicia can claim the HTLC forward with the >> corresponding preimage, at the same block height than Mallory timeout the >> HTLC, effectively double-spending Ned. >> >> The cltv_expiry_delta requested by Ned is equal to N=144. >> >> The attack scenario works in the following way: Malicia updates the Eltoo >> channel N time, getting the possession of N update transactions. At block >> A, she breaks the channel and confirms the update transaction 0 by >> attaching a feerate equal to or superior to top mempool block space + 1 >> sat. At each new block, she iterates by confirming the next update >> transaction, i.e update transaction 1 at block A+1, update transaction >> transaction 2 at block A+2, update transaction 3 at block A+3, ... >> >> From Ned's viewpoint, there is limited rationality of the network >> mempools, as such each punishment transaction R, as it's confirmation could >> have been delay due to "honest" slow propagation on the network is likely >> to be pre-signed with top mempool block space feerate, but not more to save >> on fees. Therefore, transaction RN.0 should fail to punish update >> transaction 0 as it's double-spent by update transaction 1, transaction >> RN.1 should fail to punish update transaction 1 as it's double-spent by >> update transaction 2, transaction RN.2 should fail to punish update >> transaction 2 as it's double-spent by update transaction 3... >> >> While there is a RBF-race, I think this can be easily won by Malicia by >> mass-connecting on the transaction-relay network and ignoring the Core >> transaction-relay delay timers (here for privacy purposes iirc). >> >> If it holds, I think the attack is economically opportun as long as the >> sum of the chain of update transactions weight multiplied by the spent >> feerate is inferior to the sum of HTLC values stolen (upper bounded to >> `max_htlc_value_in_flight_msat`, not `funding_satoshis`). The attack could >> be more sound in periods of low-fee, as the number of HTLC exploitable is >> higher. >> >> A mitigation could be for a fee-bumping strategy to adopt a scorched >> approach when the HTLC-timeout is approaching, and there is a corresponding >> incoming HTLC. When the HTLC-timeout is near expiration (e.g X blocks from >> incoming HTLC expiry), probably 100% of the HTLC value should be burnt in >> update transaction fees. >> >> I think some implementations in the LN-penalty are already doing "upward" >> fee-bumping frequency, while I believe it reduces the attack surface, I >> still think there is an exploitable window for "update overflow" attack. >> E.g in LDK justice transactions are bumped by 25% every block according to >> a height timer schedule [0]. >> >> Assuming the attack holds, and scorched approach are adopted by default >> to mitigate this concern, there is a second-order concern, we might open >> Lightning channels to miner-harvesting attacks, where the confirmation of >> the update transactions are deferred to kick-out the scorched earth >> reaction of the fee-bumping engine. In my opinion, this would be still an >> improvement, as we're moving a (plausible) security risk triggerable by a >> Lightning counterparty to (hypothetical) one triggerable by a wide >> coalition of miners. >> >> There is another caveat, it sounds if the update transaction can be >> malleable (i.e SIGHASH_SINGLE|ANYONECANPAY), update transactions across >> Lightning channels could be aggregated by the attacker, changing the >> economy there in a way defavorable to the victims. I.e the attacker can >> select the targeted channels, but the victim cannot coordinate with each >> other to respond with a collective fee-bumping. >> >> Is the understanding of the two-party eltoo construction correct, and >> this "update overflow" attack is sound and economically opportun ? If it >> holds, I still wonder if we have variants playing with mempool descendant >> limits. In all cases, it sounds to me the implications are more in the way >> fee-bumping is implemented by Lightning softwares rather than directly on >> eltoo-based constructions, I don't see an immediate way to address it by >> the construction itself. >> >> Mistakes and confusions are my own. >> >> Antoine >> >> [0] >> https://github.com/lightningdevkit/rust-lightning/blob/5e14c24a11f610ab8c402f788ec5bd637e9e24af/lightning/src/chain/onchaintx.rs#L505 >> _______________________________________________ >> Lightning-dev mailing list >> Lightning-dev at lists.linuxfoundation.org >> https://www.learnbitcoin.com/archive/lists/lightning-dev >> >
On Tue, Dec 13, 2022 at 08:22:55PM -0500, Antoine Riard wrote:
Quoted text (7 lines)
> > prior to (1): UA.k (k <= n) -- However this allows Bob to immediately > > broadcast one of either CA.n or RA.n, and will then have ~150 blocks > > to claim the HTLC before its timeout > From my understanding, with two party eltoo w/punihsment, UA.k has a > tapscript path with "1 CHECKSIGVERIFY k<n CLTV", where the internal pubkey > substituted is "musig(A,B)/1. Mallory should receive Bob's signature for > UA.k, though also UA.k+1, UA.k+2, UAk+3, until k=n.
Yes, Mallory can be assumed to be able to generate signatures for UA.0 through UA.n. They all spend the funding transaction (only) though, so she can only choose one of them, which I called UA.k above.
More particular, I'm imagining scriptPubKeys something like:
F: taproot(AB)
UA.n: taproot(AB/1, "IF CODESEP <n> CLTV DROP ENDIF OP_1 CHECKSIG") WB.n: taproot(AB/1, "IF CODESEP <n> CLTV DROP ENDIF OP_1 CHECKSIG")
UB.n: taproot(AB/2, "IF CODESEP <n> CLTV DROP ENDIF OP_1 CHECKSIG") WA.n: taproot(AB/2, "IF CODESEP <n> CLTV DROP ENDIF OP_1 CHECKSIG")
where AB=musig(A,B) and AB/1 and AB/2 are unhardened HD subkeys of AB. (The outputs of SA/RA/CA and SB/RB/CB are the balances and active HTLCs)
Then I think the following setup works to allow each transaction to only spend from the transactions that it's supposed to:
UA.n have ALL or SINGLE|ANYONECANPAY signatures spending F with key
AB.
CA.n/WA.n have ANYPREVOUTANYSCRIPT signatures with codesep_pos=2
against AB/2, with locktime set to n
RA.n has an ANYPREVOUTANYSCRIPT signature with codesep_pos=2
against AB/2, with locktime set to n-1
SA.n has an ANYPREVOUT signature with codesep_pos=FFFFFFFF
against AB/1, with nSequence enforcing to_self_delay
B's signatures are similar, swapping AB/2 and AB/1.
(In order to do the fast forward stuff via scriptless scripts, you also need F to have an "A CHECKSIGVERIFY B CHECKSIG" tapscript path as well, and there's probably other things I've glossed over)
Quoted text (4 lines)
> Or is this a tapscript only existing for the dual-funding case ? I think > this a bit unclear from the gist construction, how Mallory is restrained to > use the tapscript path on UA.k, with UA.k+1 as she should be in possession > of Bob's signature for this state.
You lock Mallory into using a particular signature with a particular script template by only using the key for that signature within that script template, and you lock them into using a particular path through that script via use of OP_CODESEPARATOR.
Quoted text (3 lines)
> While update transaction 1 could spend update transaction 0 immediately, > there is no reliable knowledge by U*.1 transaction broadcaster of the state > of the network mempools.
That doesn't need to be true; we can easily have lightning nodes gossip mempool state for channel closes by pattern matching on the close transaction, including offering "catchup" info for nodes that were offline, even if that isn't something we do for regular mempool transactions.
I don't really think getting into the weeds on that now is very productive though; it's still an open question whether we can get eltoo working in a laboratory environment, let alone in the wild.
Quoted text (4 lines)
> While I think this solution of eltoo nodes quickly replacing any state K > previous to the latest state N, there is no guarantee the latest state K > doesn't offer a higher feerate than state N, making it more attractive to > the miners.
I think there's really two situations here: one is where miners are just running friendly mempool software that tries to do right by the network, in which case "always update to the newest state, even if the fee rate goes down" is probably workable; the other is where miners want to profit maximise on every single block and will run MEV software; in which case all we need is for the final state to be relayed -- provided its at a reasonable feerate, the MEV miner will include it on top of the high-fee paying chain of earlier states, even if that would mean it has "too many" in-mempool descendants.
Cheers, aj