Research/Bitcoin Dev Archive / lightning-dev list
Disclosure of a fee blackmail attack that can make a victim loose almost all funds of a non Wumbo channel and potential fixes
12 messages, Jun 17 to 22, 2020. Started by René Pickhardt.
ZmnSCPxj (4), Jeremy Rubin (3), Olaoluwa Osuntokun (2), René Pickhardt, Antoine Riard, David A. Harding
Hey everyone and of course good morning ZmnSCPxj (:
about 11 months ago I discovered a potential blackmail attack with HTLCs after answering this question on stack exchange (c.f https://bitcoin.stackexchange.com/questions/89232/why-is-my-spendable-msat-much-lower-than-msatoshi-to-us/89235#89235). This attack is similar to the one that was possible with tx malleability on the funding transaction without the segwit upgrade (c.f. https://commons.wikimedia.org/w/index.php?title=File:Introduction_to_the_Lightning_Network_Protocol_and_the_Basics_of_Lightning_Technology_(BOLT_aka_Lightning-rfc).pdf&page=126). Meaning an attacker can force a victim to lose money and use this fact to blackmail the victim, to potentially gain / steal some of the lost funds.
TL;DR: ===== * Depending on the circumstances this attack allows an attacker to make channel partners lose a substantial amount of BTC without substantial costs for the attacker. * Depending on the exact circumstances this could be for example ~0.15 BTC. In particular it demonstrates why opening a channel is not an entirely trustless activity. * The attacker will reliably only be able to force the victim to lose this amount of Bitcoin. * It is not clear how in practice the attacker could gain this amount or parts of it as this would involve not only game theory but also rather quick communication between attacker and victim and customized Lightning nodes which at least for the victim would be unlikely to exist. * None of the suggested fixes seems to be satisfying though the current solution of lowering the maximum amount of HTLCs that can concurrently be in flight seems to be a reasonable start for now.
Timeline on Disclosure ================= I have disclosed this attack on Sunday July 21st 2019 to Fabrice Drouin (and shortly after to Christian Decker) in a phone call who in turn has discussed it with people from the other implementations. From his feedback I understood that people working on implementations have been more or less aware of the possibility of this attack. Fabrice also mentioned that he believed implementations currently try to mitigate this by setting low limits of allowed / accepted HTLCs in flight. However at that time this was only true for e-clair. It is now also true for c-lightning and as far as I know still not true for lnd. Fabrice said that the people he talked to have suggested that I should eventually describe the attack in public to raise awareness (also from the group of node operators) for the problems related to this attack. He also suggested that - if I wanted to - I should update the rfc with recommendations and warnings. While I already have in mind how to change the rfc I wanted to start the discussion first. Maybe some people find better fixes than just a warning that I have in mind. So far I didn't do anything because I wanted to also give lnd the chance to handle the problem.
There are two reasons I disclose this attack today: 1.) I think almost 1 year is enough time to do something about it. The only implementation that afaik didn't yet is lnd (see below) but I got roasbeefs ok last week to go ahead and publish the attack anyway so that we can have a broader discussion on mitigation strategies. 2.) The attack seems actually very similar to the one described in the "Flood & Loot: A Systemic Attack On The Lightning Network" - paper which came out 2 days ago (c.f.: https://arxiv.org/abs/2006.08513 ). I believe any person reading that paper will understand the possibility of the attack that I describe anyway so I believe it is now more or less public anyway and thus time for an open / public discussion.
The main difference between the two attacks (if I understand this novel paper correctly) is: In the "flood and loot"-attack one tries to steal the HTLC output of the victims. Where in the "flood and blackmail"-attack that I describe I try to to force the victim to lose almost all its funds due to high on chain fees (Which I could use to blackmail the victim)
Description of the attack =================== Let us assume the victim has funded a channel with an attacker meaning it will have to pay the fees for the commitment transaction in case of a force close.
During a fee spike (let us assume fee estimators suggest 150 sat / byte) the attacker spams this channel with the maximum possible amount of HTLCs that the protocol allows. The HTLCs can be of a small value but need to be bigger than the dust limit so that additional outputs are actually added to the commitment transaction which makes it quite large in Bytes. According to the BOLTs these are 483 additional outputs to the commitment transaction. The direction of HTLCs are chosen so that the amount is taken from the `to_remote` output of the attacker (obviously on the victims side it will be the `to_local` output) For the actual attack it does not matter in which direction the HTLCs are spammed but economically the direction I propose makes even more sense for the attacker and can be achieved with circular onions.
The attacked channel partner will happily - according to the protocol - use a higher fee than the current fee rate. I quote from BOLT 02 which suggests a buffer of a factor of 5 https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#updating-fees-update_fee:
Quoted text (1 line)
> The node responsible for paying the Bitcoin fee [...] SHOULD send
update_fee to ensure the current fee rate is sufficient (by a significant margin) for timely processing of the commitment transaction. [...] Given the variance in fees, and the fact that the transaction may be spent in the future, it's a good idea for the fee payer to keep a good margin (say 5x the expected fee requirement); but, due to differing methods of fee estimation, an exact value is not specified.
This overpayment of fees will result in 750 sat / byte for this fee spike scenario. This is by the way not completely unrealistic [I recently opened a channel with 2.56 sat / byte (c.f.: https://www.smartbit.com.au/tx/c0ac6cfe15e0d0c921362ab9fad998a8a8e16cd8d9d4159487dd69141ea2b9b0) and the channel was force closed a couple minutes later due to an implementation bug resulting in fees of 101.17 sat / byte (c.f.: https://www.smartbit.com.au/tx/e32135315ec147bb27f771b2e15c7178ea573afd16cd4970bf814c9b18bc46e3 )
As far as I understand the appendix of BOLT 03 offered HTLCs are 43 Byte in size (c.f.: https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#appendix-a-expected-weights) resulting in the following additional fees for the spammed commitment transaction:
fee (for 483 htlcs) = 483 * 43 byte * 750 sat / byte = 15576750 sat = 0.1557675 BTC
Additionally the victim will also have to swipe all offered HTLCs (which will be additional costs but could be done once the fees came down) so we neglect them.
Once all HTLCs are set up the attacker will stop signing commitment transactions. In the beginning this is not suspicious as the HTLCs will take some time to settle anyway. But also when fees go down and the victim who funded the channel wants to update the fees the attacker will just not be responsive. Eventually the victim will dare to force close the channel with all those expensive HTLCs.
Knowing that this will happen and that the victim has to spend those funds (publishing old state obviously does not work!) the attacker has a time window to blackmail the victim outside of the lightning network protocol: "Either you will pay those 0.1557675 BTC of fees or we will collaboratively close the channel but that will cost you part of the amount you lost." Game theory suggests that the attacker will be able to claim the major fraction of the BTC (c.f. https://en.wikipedia.org/wiki/Ultimatum_game that are frozen in tx fees as the victim effectively already has lost that money and can only gain something back.
Thoughts ======= You might say that the blackmail part of this attack is unrealistic as the blackmailing person will not have enough time to successfully do the blackmail as the channel that is not operational will fail.
1.) The only thing that lightning nodes might do is a fee update as the htlcs stuffed the channel so I believe there is actually some time to contact the victim. 2.) What if the attacker is a mining pool who is just interested in high fees who does not even need to do the blackmailing stuff but will just force close the channel once the htlcs are set up? 3.) The attacker might not even be interested in blackmailing the victim. The attacker could just be interested in harming the victim. Though it might certainly be a challenge to target a specific victim and trick it into opening a channel with an attacker.
Also you might say that an attacker needs many incoming channels to execute this attack. This can be achieved by gaming the autopilot. an attacker can start by creating many channels making him a highly likely channel partner for autopilot users (who will also fund the channel). Such a highly connected node might also be interesting for non autopilot users.
Implementations ============
I looked at the code myself. I hope I do oversee things but to me it looks like only eclaire was somehow mitigating this attack from being exploited. (by a default config of 30 accepted htlcs which will protect the average user and is much lower than the 483) and c-lightning has merged a patch from me which I provided after I disclosed the attack:
## clightning:
c-lightning did not by default set a hard cap on htlcs before version 0.7.2 but then merged my patch https://github.com/ElementsProject/lightning/pull/2858 which tried to resemble the eclair defaults
## eclaire:
the max accepted htlc value per channel is set as a constant to 483 which follows the recommendation of the BOLTs: https://github.com/ACINQ/eclair/blob/e62adf2deae213d2cd0f2a6874227dcfc57880ae/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala#L52
The value is tested against at: https://github.com/ACINQ/eclair/blob/f724efaa76b256048de18f706e9cb58ecbebd6aa/eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala#L99
However the default config file specifies a maximum amount of 30 accepted htlcs at: https://github.com/ACINQ/eclair/blob/9afb26e09c69dd5d6a14732baf5dcdf2b7a9142b/eclair-core/src/main/resources/reference.conf#L62
## lnd It seems like lnd did not and last time I checked (maybe I oversaw something) does not set a hard cap on htlcs by default. The way how I understand the code they allow up to 483 htlcs by default:
The test when adding an htlc if it is beyond the maximum accepted values is here: https://github.com/lightningnetwork/lnd/blob/970d7604071baae227db42d4665ef9d1b56988e8/lnwallet/channel.go#L3795
the default configuration seems to be here (and in the most recent commit the line still exists): https://github.com/lightningnetwork/lnd/blob/8b04cfbf12f460853e8c55611cd1bba21b1510ef/input/size.go#L187
the software will accept up to 483 htlcs according to this line: https://github.com/lightningnetwork/lnd/blob/111cbeaa990cba78563d6cc8c19b152e2d3042f6/lnwallet/reservation.go#L314
I could not find any spec lower than that in the suggested sample config at: https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf
Ideas for Fixes ===========
I am completely unhappy with each of the following ideas. I hope you will come up with smarter solutions. I believe the solution is not obvious. Thus I thought it makes sense in the brainstorm phase to even post some ideas with obvious drawbacks.
1. The current solution is to just not use up the max value of htlc's. Eclaire and c-lightning by default only use up to 30 htlcs. 2. Probably the best fix (not sure if I understand the consequences correctly) is coming from this PR to bitcoin core (c.f. https://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get it correctly with that we could always have low fees and ask the person who want to claim their outputs to pay fees. This excludes overpayment and could happen at a later stage when fees are not spiked. Still the victim who offered the htlcs would have to spend those outputs at some time. 3. Don't overpay fees in commitment transactions. We can't foresee the future anyway 4. Don't add htlcs for which the on chain fee is higher than the HTLCs value (like we do with sub dust amounts and sub satoshi amounts. This would at least make the attack expensive as the attacker would have to bind a lot of liquidity. 5. Somehow be able to aggregate htlc's. In a world where we use payment points instead of preimages we might be able to do so. It would be really cool if separate HTLC's could be combined to 1 single output. I played around a little bit but I have not come up with a scheme that is more compact in all cases. Thus I just threw in the idea. 6. Split onchain fees differently (now the attacker would also lose fees by conducting this attack) - No I don't want to start yet another fee bikeshadding debate. (In particular I believe that a different split of fees might make the Flood & Loot attack economically more viable which relies on the same principle)
Independently I think we should have a hint in our readme file about where and how people can disclose attacks and vulnerabilities. Implementations have this but the BOLTs do not.
with kind regards Rene
Good morning Rene,
Thank you for the report, this is good.
Quoted text (3 lines)
> 1. The current solution is to just not use up the max value of htlc's. Eclaire and c-lightning by default only use up to 30 htlcs. > 2. Probably the best fix (not sure if I understand the consequences correctly) is coming from this PR to bitcoin core (c.f. https://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get it correctly with that we could always have low fees and ask the person who want to claim their outputs to pay fees. This excludes overpayment and could happen at a later stage when fees are not spiked. Still the victim who offered the htlcs would have to spend those outputs at some time. > 3. Don't overpay fees in commitment transactions. We can't foresee the future anyway
Fee futures could help against this. I remember writing about this some time ago but cannot find where (not sure if it was in lightning-dev or bitcoin-dev).
As a rough sketch, a client contacts a fee insurance service. For a fixed fee, the client arranges such that the fee insurance service pays for fees in case of a condition where feerates increase.
This is done by arranging a 2-of-2 output spending the insurance premium payment and some maximum fee the insurance service provides. Initially sign an `nLockTime`d transaction that represents the end of the insurance service contract. Then at each commitment tx, sign a variety of feerates spending the CPFP carve-out and the insurance 2-of-2, utilizing the insurnace funds for doing the CPFP.
Quoted text (1 line)
> 4. Don't add htlcs for which the on chain fee is higher than the HTLCs value (like we do with sub dust amounts and sub satoshi amounts. This would at least make the attack expensive as the attacker would have to bind a lot of liquidity.
Seems a reasonable heuristic.
Quoted text (1 line)
> 5. Somehow be able to aggregate htlc's. In a world where we use payment points instead of preimages we might be able to do so. It would be really cool if separate HTLC's could be combined to 1 single output. I played around a little bit but I have not come up with a scheme that is more compact in all cases. Thus I just threw in the idea.
This seems impossible; once you add the points of two unrelated PTLCs, in order to separate them again once you learn the aggregate scalar, you need to learn the scalar of one separately from the scalar of the other, but the aggregate PTLC does not impose the requirement from the receiver to reveal each of the scalars separately.
You *could* require multiple signatures instead of a single signature, in which case each completed signature can reveal a separate scalar behind a point. Revealing the points and the signatures is 96 bytes, plus a few more bytes for opcodes, divided by 4 because witness, so about equivalent to 24 block space per PTLC you merge.
This cost would be paid by the receiver of the HTLC. The timelock branch can be made not to have to reveal any of the points, by Taproot-signing the timelock branch, or using a separate tapscript (at the cost of additional 32 witness bytes to select branches, if my taproot understanding holds).
Good morning all,
Quoted text (3 lines)
> > Fee futures could help against this. > I remember writing about this some time ago but cannot find where (not sure if it was in lightning-dev or bitcoin-dev).
`harding` found it: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-January/017601.html
Regards, ZmnSCPxj
Hi Rene,
Thanks for disclosing this vulnerability,
I think this blackmail scenario holds but sadly there is a lower scenario.
Both "Flood & Loot" and your blackmail attack rely on `update_fee` mechanism and unbounded commitment transaction size inflation. Though the first to provoke block congestion and yours to lockdown in-flight fees as funds hostage situation.
Quoted text (2 lines)
> 1. The current solution is to just not use up the max value of htlc's. Eclaire and c-lightning by default only use up to 30 htlcs.
As of today, yes I would recommend capping commitment size both for ensuring competitive propagation/block selection and limiting HTLC exposure.
Quoted text (7 lines)
> 2. Probably the best fix (not sure if I understand the consequences correctly) is coming from this PR to bitcoin core (c.f. https://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get it correctly with that we could always have low fees and ask the person who want to claim their outputs to pay fees. This excludes overpayment and could happen at a later stage when fees are not spiked. Still the victim who offered the htlcs would have to spend those outputs at some time.
It's a bit more complex, carve-out output, even combined with anchor output support on the LN-side won't protect against different flavors of pinning. I invite you to go through logs of past 2 LN dev meetings.
Quoted text (2 lines)
> 3. Don't overpay fees in commitment transactions. We can't foresee the future anyway
Once 2. is well-addressed we may deprecate `update_fee`.
Quoted text (4 lines)
> 4. Don't add htlcs for which the on chain fee is higher than the HTLCs value (like we do with sub dust amounts and sub satoshi amounts. This would at least make the attack expensive as the attacker would have to bind a lot of liquidity.
Ideally we want dust_limit to be dynamic, dust cap should be based on HTLC economic value, feerate of its output, feerate of HTLC-transaction, feerate estimation of any CPFP to bump it. I think that's kind of worthy to do once we solved 3. and 4
Quoted text (5 lines)
> 5. Somehow be able to aggregate htlc's. In a world where we use payment points instead of preimages we might be able to do so. It would be really cool if separate HTLC's could be combined to 1 single output. I played around a little bit but I have not come up with a scheme that is more compact in all cases. Thus I just threw in the idea.
Yes we may encode all HTLC in some Taproot tree in the future. There are some wrinkles but for a high-level theoretical construction see my post on CoinPool.
Quoted text (5 lines)
> 6. Split onchain fees differently (now the attacker would also lose fees by conducting this attack) - No I don't want to start yet another fee bikeshadding debate. (In particular I believe that a different split of fees might make the Flood & Loot attack economically more viable which relies on the same principle)
Likely a bit more of fee bikeshedding is something we have to do to make LN secure... Switching fee from pre-committed ones to a single-party, dynamic one.
Quoted text (3 lines)
> Independently I think we should have a hint in our readme file about where and how people can disclose attacks and vulnerabilities. Implementations have this but the BOLTs do not.
I 100% agree, that's exactly https://github.com/lightningnetwork/lightning-rfc/pull/772, waiting for your feedback :)
Cheers,
Antoine
Le mer. 17 juin 2020 à 09:41, ZmnSCPxj via Lightning-dev < lightning-dev at lists.linuxfoundation.org> a écrit :
Quoted text (18 lines)
> > Good morning all, > > > > > Fee futures could help against this. > > I remember writing about this some time ago but cannot find where (not > sure if it was in lightning-dev or bitcoin-dev). > > `harding` found it: > https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-January/017601.html > > Regards, > ZmnSCPxj > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
I am not steeped enough in Lightning Protocol issues to get the full design space, but I'm fairly certain BIP-119 Congestion Control trees would help with this issue.
You can bucket a tree by doing a histogram of HTLC size, so that all small HTLCs live in a common CTV subtree and don't interfere with higher value HTLCs. You can also play with sequencing to prevent those HTLCs from getting longchains in the mempool until they're above a certain value.
Good morning Jeremy,
Quoted text (3 lines)
> I am not steeped enough in Lightning Protocol issues to get the full design space, but I'm fairly certain BIP-119 Congestion Control trees would help with this issue. > > You can bucket a tree by doing a histogram of HTLC size, so that all small HTLCs live in a common CTV subtree and don't interfere with higher value HTLCs. You can also play with sequencing to prevent those HTLCs from getting longchains in the mempool until they're above a certain value.
If the attacker stops responding, then all HTLC rules need to be published onchain for enforcement of the HTLC rules. And that publication onchain is the problem: every HTLC published requires onchain space, which must be paid for.
The most compact way to expose the HTLCs is as a flat array, i.e. outputs of a single transaction. Every tree structure is going to take up more space than a flat array.
What CTV buys is to be able to defer *when* you reveal scripts, possibly to a later time when blockchain space is cheaper. But in case the victim owns the timelock branch of an outgoing HTLC, it is unsafe for the victim to defer: it has to enforce the locktime soon or it could end up losing both incoming and outgoing HTLC amounts. And to enforce the locktime it has to publish the HTLC.
Now of course with CTV you could publish only the HTLC you have to enforce *now*, and keep the rest in an CTV output. The attacker can counter this by pushing 483 HTLCs with the same timelock at the victim, so that the victim has to publish all HTLCs simultaneously. And a flat array of outputs is cheaper than a tree.
What *can* be done would be to bin by timelock rather than amount; tree leaves are a transaction that exposes all HTLCs with a particular timelock as a flat array of outputs, but different timelocks go to different tree branches. But the attacker can still do the same-timelock trick, and the tree structure is likely to take up more space in the end than just a non-treed flat array of outputs.
Regards, ZmnSCPxj
Quoted text (65 lines)
> -- > @JeremyRubin > > On Thu, Jun 18, 2020 at 1:41 AM Antoine Riard <antoine.riard at gmail.com> wrote: > > > Hi Rene, > > Thanks for disclosing this vulnerability, > > > > I think this blackmail scenario holds but sadly there is a lower scenario. > > > > Both "Flood & Loot" and your blackmail attack rely on `update_fee` mechanism and unbounded commitment transaction size inflation. Though the first to provoke block congestion and yours to lockdown in-flight fees as funds hostage situation. > > > > > 1. The current solution is to just not use up the max value of htlc's. Eclaire and c-lightning by default only use up to 30 htlcs. > > > > As of today, yes I would recommend capping commitment size both for ensuring competitive propagation/block selection and limiting HTLC exposure. > > > > > 2. Probably the best fix (not sure if I understand the consequences correctly) is coming from this PR to bitcoin core (c.f. https://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get it correctly with that we could always have low fees and ask the person who want to claim their outputs to pay fees. This excludes overpayment and could happen at a later stage when fees are not spiked. Still the victim who offered the htlcs would have to spend those outputs at some time. > > > > It's a bit more complex, carve-out output, even combined with anchor output support on the LN-side won't protect against different flavors of pinning. I invite you to go through logs of past 2 LN dev meetings. > > > > > 3. Don't overpay fees in commitment transactions. We can't foresee the future anyway > > > > Once 2. is well-addressed we may deprecate `update_fee`. > > > > > 4. Don't add htlcs for which the on chain fee is higher than the HTLCs value (like we do with sub dust amounts and sub satoshi amounts. This would at least make the attack expensive as the attacker would have to bind a lot of liquidity. > > > > Ideally we want dust_limit to be dynamic, dust cap should be based on HTLC economic value, feerate of its output, feerate of HTLC-transaction, feerate estimation of any CPFP to bump it. I think that's kind of worthy to do once we solved 3. and 4 > > > > > 5. Somehow be able to aggregate htlc's. In a world where we use payment points instead of preimages we might be able to do so. It would be really cool if separate HTLC's could be combined to 1 single output. I played around a little bit but I have not come up with a scheme that is more compact in all cases. Thus I just threw in the idea. > > > > Yes we may encode all HTLC in some Taproot tree in the future. There are some wrinkles but for a high-level theoretical construction see my post on CoinPool. > > > > > 6. Split onchain fees differently (now the attacker would also lose fees by conducting this attack) - No I don't want to start yet another fee bikeshadding debate. (In particular I believe that a different split of fees might make the Flood & Loot attack economically more viable which relies on the same principle) > > > > Likely a bit more of fee bikeshedding is something we have to do to make LN secure... Switching fee from pre-committed ones to a single-party, dynamic one. > > > > > Independently I think we should have a hint in our readme file about where and how people can disclose attacks and vulnerabilities. Implementations have this but the BOLTs do not. > > > > I 100% agree, that's exactly https://github.com/lightningnetwork/lightning-rfc/pull/772, waiting for your feedback :) > > > > Cheers, > > > > Antoine > > > > Le mer. 17 juin 2020 à 09:41, ZmnSCPxj via Lightning-dev <lightning-dev at lists.linuxfoundation.org> a écrit : > > > > > Good morning all, > > > > > > > > > > > Fee futures could help against this. > > > > I remember writing about this some time ago but cannot find where (not sure if it was in lightning-dev or bitcoin-dev). > > > > > > `harding` found it: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-January/017601.html > > > > > > Regards, > > > ZmnSCPxj > > > _______________________________________________ > > > Lightning-dev mailing list > > > Lightning-dev at lists.linuxfoundation.org > > > https://www.learnbitcoin.com/archive/lists/lightning-dev > > > > _______________________________________________ > > Lightning-dev mailing list > > Lightning-dev at lists.linuxfoundation.org > > https://www.learnbitcoin.com/archive/lists/lightning-dev
Hi ZmnSCPxj,
My understanding is that you can use the CTV deferral to also get independent HTLC relative timelocks start points per output. This would help with this sort of issue right?
And you're correct that there's overhead of indirection, but it's not super large (minimally complicated something like an extra 100 bytes per output, if you were to have a flat array where each entry is a CTV output so that each out gets its own clock).
Essentially something like this:
Chan
|
---------------------------------------------
| | | | |
CTV(A) CTV(B) CTV(C) CTV(D) (Optional CPFP Anchor?)
| | | |
1 block 1 block 1 block 1 block
| | | |
A B C D
Where A B C and D are all HTLCs.
Now because of the one-hop indirection, A B C and D can all expand independently. It's also possible for the Channel Operator to do something like:
Chan
|
---------------------------------------------
| | | | |
CTV(A) CTV(B) CTV(C) CTV(D) (Optional CPFP Anchor?)
| | | |
1 block 1 block 1 block 10 blocks
| | | |
A B C D
To make D have a further out resolution time to prevent the simultaneous-ness issue (trees or a linear-chain rather than total fan-out can also be used but I think it's a bit more confusing for a basic example). The benefit of trees is that I can do something like:
Chan
|
--------------------------------------------------------
| | | | |
CTV(A) CTV(B) CTV(C) CTV(400 HTLC) (Optional CPFP Anchor?)
| | | | |
1 block 1 block 1 block 10 blocks (Optional CPFP Anchor?)
| | | |
| | | / ....\
A B C | ..... |
Which makes it so that the low-value new HTLCs can be deprioritized fee wise. So that the attack, which occurs during a fee spike, doesn't end up *requiring* substantial fees to be added to the channel to support a burst of HTLCS.
Good morning Jeremy,
Quoted text (31 lines)
> My understanding is that you can use the CTV deferral to also get independent HTLC relative timelocks start points per output. This would help with this sort of issue right? > > And you're correct that there's overhead of indirection, but it's not super large (minimally complicated something like an extra 100 bytes per output, if you were to have a flat array where each entry is a CTV output so that each out gets its own clock). > > Essentially something like this: > > Chan > | > ------------------------------------ > | | | | | > CTV(A) CTV(B) CTV(C) CTV(D) (Optional CPFP Anchor?) > | | | | > 1 block 1 block 1 block 1 block > | | | | > A B C D > > Where A B C and D are all HTLCs. > > Now because of the one-hop indirection, A B C and D can all expand independently. It's also possible for the Channel Operator to do something like: > > Chan > | > ----------------------------------- > | | | | | > CTV(A) CTV(B) CTV(C) CTV(D) (Optional CPFP Anchor?) > | | | | > 1 block 1 block 1 block 10 blocks > | | | | > A B C D > > To make D have a further out resolution time to prevent the simultaneous-ness issue (trees or a linear-chain rather than total fan-out can also be used but I think it's a bit more confusing for a basic example).
The Lightning HTLCs use absolute timelocks, and the timelocks are pre-arranged by the original sender. A forwarding node has to ensure that the outgoing HTLC timeout is respected, or else it could lose funds (by having the outgoing HTLC be claimed by outgoing peer hashlock and the incoming HTLC be calimed by the incoming peer timelock).
(We cannot use relative timelocks in the timelock branches of the HTLCs because we are coordinating possibly up to 20 different nodes, and do not want to leak the entire route to any of the intermediate nodes, so everyone has to use the same clock --- the absolute blockheight --- to measure time)
So, if my understanding of your above graph is correct, you are suggesting that HTLC D could have a relative timelock of 10 blocks instead of 1.
But all that means is that if the timelock of D is at height L, then the forwarder has to ensure that the commitment transaction appears onchain no later than height L - 10 (in practice I have to publish it at L - 11 so it propagates to miners who are building L - 10). If not, the HTLC cannot be published at height L and the timelock cannot be enforced, risking fund loss.
This seems to *tighten* whatever leeway I might have bought by using CTV. In current C-Lightning, for instance, for a timelock in my favor at height L, I have to broadcast the commitment transaction at time L - 1 so it goes into block L and I can claim it. Thus, I have the option to publish from now up to L - 1. With a further delay of 10 on the HTLC tx D, I now only have the option to publish from now up to L - 11, thus I have *less* leeway in when I can publish the commitment tx.
Basically the fund-security of the forwarding node is based on the absolute timelock of every HTLC it offers, so the timelock is an absolute bound on whatever techniques I might use to reduce fees.
Quoted text (14 lines)
> The benefit of trees is that I can do something like: > > Chan > | > -------------------------------------------------------- > | | | | | > CTV(A) CTV(B) CTV(C) CTV(400 HTLC) (Optional CPFP Anchor?) > | | | | | > 1 block 1 block 1 block 10 blocks (Optional CPFP Anchor?) > | | | | > | | | / ....\ > A B C | ..... | > > Which makes it so that the low-value new HTLCs can be deprioritized fee wise. So that the attack, which occurs during a fee spike, doesn't end up *requiring* substantial fees to be added to the channel to support a burst of HTLCS.
If the HTLCs have a timelock L, then I *need* to publish the HTLCs at timelock L or else the timelock cannot be enforced.
This means I need to publish the big `| ..... |` transaction with 400 HTLCs before timelock L, where L is `min (L) for all 400 HTLCs`.
The attacker can arrange to have the 400 low-value HTLCs have the same timelock L. So even if the `| ..... |` is a tree of CTVs, I have to publish the entire tree at the same time so that the final HTLCs appear at timelock L and I can reclaim my funds.
If I do not publish, I run the risk that the total fund going to `CTV(400 HTLC)` gets stolen from me by publication of the hashlock on the outgoing and publication of the timelock at the incoming. Not publishing this due to fee spikes is basically trusting that the next peer is not going to steal the fund by hashlock branch. And the next peer is an attacker in this attack, so obviously cannot be trusted.
So it seems to me that this is better done by just rate-limiting simultaneous HTLCs, to limit what can be stolen.
A better solution might be to allow only one HTLC at each absolute timelock, and use a single CTV tree, with one leaf for each of the absolute timelocks. Then I can publish parts of the CTV tree at my leisure, with my only constraint being the absolute timelock of each HTLC.
Chan
|
CTV
|
+------+
| |
CTV HTLC(L = now + 1)
|
+------+
| |
CTV HTLC(L = now + 2)
|
+------+
| |
CTV HTLC(L = now + 3)
|
...
Such a singly-linked list would take up even more absolute block space, incidentally, and makes high-fee spikes more likely.
Regards, ZmnSCPxj
Hi Rene,
IMO this is mostly mitigated by anchor commitments. The impact of this attack is predicated on the "victim" paying 5x on-chain fees (for their confirmation target) to sweep all their HTLCs. Anchor commitments let the initiator of the channel select a very low starting fee (just enough to get into the mempool), and also let them actually bump the fees of second-level HTLC transactions.
In addition to being able to pay much lower fees ("just enough" to get into the chain), anchor commitments allow second-level HTLC _aggregation_, This means that for HTLCs with the same expiry height, a peer is able to _batch_ them all into a single transaction, further saving on fees.
lnd shipped with a form of anchor commitments in our past major release (v0.10.0-beta). In that release the format is opt in, and is enabled with a startup command-line flag. For 0.11, we're planning on making this the default commitment type, giving all users that update the ability to _finally_ have proper fee control of their commitments, and second-level HTLC transactions.
Quoted text (3 lines)
> The direction of HTLCs are chosen so that the amount is taken from the > `to_remote` output of the attacker (obviously on the victims side it will > be the `to_local` output)
One relevant detail here is that if the attacker is to attempt this with minimal setup, then they'll need to be the ones that open the channel. Since they're the initiator, they'll actually be the ones paying the fees rendering this attempt moot.
Alternatively, they could use something like Lightning Loop to gain the _outbound_ bandwidth (Loop In) needed to attempt this attack (using inbound opened channels, but they'll need to pay for that bandwidth, adding a further cost to the attack. Not to mention that they'll need to pay on-chain fees to sweep the HTLCs they created themselves. In short, this attack isn't costless as they'll need to acquire outbound liquidity for an incoming channel, and also need to pay fees independent of the "success" of their attack.
Quoted text (1 line)
> I quote from BOLT 02 which suggests a buffer of a factor of 5
I'm not sure how many implementations actually follow this in practice. FWIW, lnd doesn't.
Quoted text (3 lines)
> Additionally the victim will also have to swipe all offered HTLCs (which > will be additional costs but could be done once the fees came down) so we > neglect them.
No, the attacker is the one that needs to sweep these HTLCs, since they offered them. This adds to their costs.
Quoted text (3 lines)
> Knowing that this will happen and that the victim has to spend those funds > (publishing old state obviously does not work!) the attacker has a time > window to blackmail the victim outside of the lightning network protocol
I don't think this is always the case. Depending on the minimum HTLC settings in the channel (another mitigation), and the distribution of funds in the channel, it may be the case that the victim doesn't have any funds in the channel at all (everything was on the attacker's side). In that case, the "victim" doesn't really care if this channel is clogged up as they really have no stake in this channel.
Quoted text (2 lines)
> Also you might say that an attacker needs many incoming channels to > execute this attack. This can be achieved by gaming the autopilot.
As mentioned above, gaining purely incoming channels doesn't allow the attacker to launch this attack, as they'll be unable to _send out_ from any of those channels.
Quoted text (2 lines)
> 1. The current solution is to just not use up the max value of htlc's. > Eclaire and c-lightning by default only use up to 30 htlcs.
IMO, this isn't a solution. Lowering the max number of HTLCs in-flight just makes it easier (lowers the capital costs) to jam a channel. The authors of the paper you linked have another paper exploring these types of attacks [1], and cite the _hard coded_ limit of 483 HTLCS as an enabling factor.
Quoted text (2 lines)
> 2. Probably the best fix (not sure if I understand the consequences > correctly) is coming from this PR to bitcoin core
I think you're misinterpreting this PR, but see my first paragraph about anchor commitments which that PR enables.
Quoted text (2 lines)
> 3. Don't overpay fees in commitment transactions. We can't foresee the > future anyway
Anchors let you do this ;)
Quoted text (2 lines)
> 4. Don't add htlcs for which the on chain fee is higher than the HTLCs > value (like we do with sub dust amounts and sub satoshi amounts.
This is already how "dust HTLCs" are calculated. The amount remaining from the HTLC after it pays for its second-level transaction needs to be above dust. This policy can be asymmetric across commitments in the channel.
Quoted text (1 line)
> 5. Somehow be able to aggregate htlc's.
Anchors let you do this on the transaction level (MIMO 2nd level HTLC transactions).
I hope other implementations join lnd in deploying anchor commitments to mitigate nuisance attacks like this, and _finally_ give users better fee control for channels and any off-chain contracts within those channels.
BTW, the "Flood & Loot" paper you linked mentions anchor commitments as a solution towards the end of the paper. However, they erroneously state that an attacker would be able to spend their HTLC with a _non replaceable_ transaction. This isn't the case since all redemption paths are encumbered with a CSV delay of 1. This delay forces the attacker to spend the output with an input that has a non-final sequence, meaning the transaction is RBF-able.
[1]: https://arxiv.org/abs/2002.06564
-- Laolu
On Wed, Jun 17, 2020 at 3:30 AM René Pickhardt via Lightning-dev < lightning-dev at lists.linuxfoundation.org> wrote:
Quoted text (280 lines)
> Hey everyone and of course good morning ZmnSCPxj (: > > about 11 months ago I discovered a potential blackmail attack with HTLCs > after answering this question on stack exchange (c.f > https://bitcoin.stackexchange.com/questions/89232/why-is-my-spendable-msat-much-lower-than-msatoshi-to-us/89235#89235). > This attack is similar to the one that was possible with tx malleability on > the funding transaction without the segwit upgrade (c.f. > https://commons.wikimedia.org/w/index.php?title=File:Introduction_to_the_Lightning_Network_Protocol_and_the_Basics_of_Lightning_Technology_(BOLT_aka_Lightning-rfc).pdf&page=126). > Meaning an attacker can force a victim to lose money and use this fact to > blackmail the victim, to potentially gain / steal some of the lost funds. > > TL;DR: > ===== > * Depending on the circumstances this attack allows an attacker to make > channel partners lose a substantial amount of BTC without substantial costs > for the attacker. > * Depending on the exact circumstances this could be for example ~0.15 > BTC. In particular it demonstrates why opening a channel is not an entirely > trustless activity. > * The attacker will reliably only be able to force the victim to lose this > amount of Bitcoin. > * It is not clear how in practice the attacker could gain this amount or > parts of it as this would involve not only game theory but also rather > quick communication between attacker and victim and customized Lightning > nodes which at least for the victim would be unlikely to exist. > * None of the suggested fixes seems to be satisfying though the current > solution of lowering the maximum amount of HTLCs that can concurrently be > in flight seems to be a reasonable start for now. > > > Timeline on Disclosure > ================= > I have disclosed this attack on Sunday July 21st 2019 to Fabrice Drouin > (and shortly after to Christian Decker) in a phone call who in turn has > discussed it with people from the other implementations. From his feedback > I understood that people working on implementations have been more or less > aware of the possibility of this attack. Fabrice also mentioned that he > believed implementations currently try to mitigate this by setting low > limits of allowed / accepted HTLCs in flight. However at that time this was > only true for e-clair. It is now also true for c-lightning and as far as I > know still not true for lnd. Fabrice said that the people he talked to have > suggested that I should eventually describe the attack in public to raise > awareness (also from the group of node operators) for the problems related > to this attack. He also suggested that - if I wanted to - I should update > the rfc with recommendations and warnings. While I already have in mind > how to change the rfc I wanted to start the discussion first. Maybe some > people find better fixes than just a warning that I have in mind. So far I > didn't do anything because I wanted to also give lnd the chance to handle > the problem. > > There are two reasons I disclose this attack today: > 1.) I think almost 1 year is enough time to do something about it. The > only implementation that afaik didn't yet is lnd (see below) but I got > roasbeefs ok last week to go ahead and publish the attack anyway so that we > can have a broader discussion on mitigation strategies. > 2.) The attack seems actually very similar to the one described in the > "Flood & Loot: A Systemic Attack On The Lightning Network" - paper which > came out 2 days ago (c.f.: https://arxiv.org/abs/2006.08513 ). I believe > any person reading that paper will understand the possibility of the attack > that I describe anyway so I believe it is now more or less public anyway > and thus time for an open / public discussion. > > The main difference between the two attacks (if I understand this novel > paper correctly) is: In the "flood and loot"-attack one tries to steal the > HTLC output of the victims. Where in the "flood and blackmail"-attack that > I describe I try to to force the victim to lose almost all its funds due to > high on chain fees (Which I could use to blackmail the victim) > > Description of the attack > =================== > Let us assume the victim has funded a channel with an attacker meaning it > will have to pay the fees for the commitment transaction in case of a force > close. > > During a fee spike (let us assume fee estimators suggest 150 sat / byte) > the attacker spams this channel with the maximum possible amount of HTLCs > that the protocol allows. The HTLCs can be of a small value but need to be > bigger than the dust limit so that additional outputs are actually added to > the commitment transaction which makes it quite large in Bytes. According > to the BOLTs these are 483 additional outputs to the commitment > transaction. > The direction of HTLCs are chosen so that the amount is taken from the > `to_remote` output of the attacker (obviously on the victims side it will > be the `to_local` output) For the actual attack it does not matter in which > direction the HTLCs are spammed but economically the direction I propose > makes even more sense for the attacker and can be achieved with circular > onions. > > The attacked channel partner will happily - according to the protocol - > use a higher fee than the current fee rate. I quote from BOLT 02 which > suggests a buffer of a factor of 5 > https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#updating-fees-update_fee: > > > > The node responsible for paying the Bitcoin fee [...] SHOULD send > update_fee to ensure the current fee rate is sufficient (by a significant > margin) for timely processing of the commitment transaction. [...] Given > the variance in fees, and the fact that the transaction may be spent in the > future, it's a good idea for the fee payer to keep a good margin (say 5x > the expected fee requirement); but, due to differing methods of fee > estimation, an exact value is not specified. > > This overpayment of fees will result in 750 sat / byte for this fee spike > scenario. This is by the way not completely unrealistic [I recently opened > a channel with 2.56 sat / byte (c.f.: > https://www.smartbit.com.au/tx/c0ac6cfe15e0d0c921362ab9fad998a8a8e16cd8d9d4159487dd69141ea2b9b0) > and the channel was force closed a couple minutes later due to an > implementation bug resulting in fees of 101.17 sat / byte (c.f.: > https://www.smartbit.com.au/tx/e32135315ec147bb27f771b2e15c7178ea573afd16cd4970bf814c9b18bc46e3 > ) > > As far as I understand the appendix of BOLT 03 offered HTLCs are 43 Byte > in size (c.f.: > https://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#appendix-a-expected-weights) > resulting in the following additional fees for the spammed commitment > transaction: > > fee (for 483 htlcs) = 483 * 43 byte * 750 sat / byte = 15576750 sat = > 0.1557675 BTC > > Additionally the victim will also have to swipe all offered HTLCs (which > will be additional costs but could be done once the fees came down) so we > neglect them. > > Once all HTLCs are set up the attacker will stop signing commitment > transactions. In the beginning this is not suspicious as the HTLCs will > take some time to settle anyway. But also when fees go down and the victim > who funded the channel wants to update the fees the attacker will just not > be responsive. Eventually the victim will dare to force close the channel > with all those expensive HTLCs. > > Knowing that this will happen and that the victim has to spend those funds > (publishing old state obviously does not work!) the attacker has a time > window to blackmail the victim outside of the lightning network protocol: > "Either you will pay those 0.1557675 BTC of fees or we will collaboratively > close the channel but that will cost you part of the amount you lost." Game > theory suggests that the attacker will be able to claim the major fraction > of the BTC (c.f. https://en.wikipedia.org/wiki/Ultimatum_game that are > frozen in tx fees as the victim effectively already has lost that money and > can only gain something back. > > > Thoughts > ======= > You might say that the blackmail part of this attack is unrealistic as the > blackmailing person will not have enough time to successfully do the > blackmail as the channel that is not operational will fail. > > 1.) The only thing that lightning nodes might do is a fee update as the > htlcs stuffed the channel so I believe there is actually some time to > contact the victim. > 2.) What if the attacker is a mining pool who is just interested in high > fees who does not even need to do the blackmailing stuff but will just > force close the channel once the htlcs are set up? > 3.) The attacker might not even be interested in blackmailing the victim. > The attacker could just be interested in harming the victim. Though it > might certainly be a challenge to target a specific victim and trick it > into opening a channel with an attacker. > > Also you might say that an attacker needs many incoming channels to > execute this attack. This can be achieved by gaming the autopilot. an > attacker can start by creating many channels making him a highly likely > channel partner for autopilot users (who will also fund the channel). Such > a highly connected node might also be interesting for non autopilot users. > > Implementations > ============ > > I looked at the code myself. I hope I do oversee things but to me it looks > like only eclaire was somehow mitigating this attack from being exploited. > (by a default config of 30 accepted htlcs which will protect the average > user and is much lower than the 483) and c-lightning has merged a patch > from me which I provided after I disclosed the attack: > > ## clightning: > > c-lightning did not by default set a hard cap on htlcs before version > 0.7.2 but then merged my patch > https://github.com/ElementsProject/lightning/pull/2858 which tried to > resemble the eclair defaults > > ## eclaire: > > the max accepted htlc value per channel is set as a constant to 483 which > follows the recommendation of the BOLTs: > > https://github.com/ACINQ/eclair/blob/e62adf2deae213d2cd0f2a6874227dcfc57880ae/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala#L52 > > The value is tested against at: > > https://github.com/ACINQ/eclair/blob/f724efaa76b256048de18f706e9cb58ecbebd6aa/eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala#L99 > > and: > > https://github.com/ACINQ/eclair/blob/f724efaa76b256048de18f706e9cb58ecbebd6aa/eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala#L132 > > and: > > https://github.com/ACINQ/eclair/blob/93d9369f900766171f2ddf579e8b12e28d8f0d25/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala#L154 > > However the default config file specifies a maximum amount of 30 accepted > htlcs at: > > https://github.com/ACINQ/eclair/blob/9afb26e09c69dd5d6a14732baf5dcdf2b7a9142b/eclair-core/src/main/resources/reference.conf#L62 > > > ## lnd > It seems like lnd did not and last time I checked (maybe I oversaw > something) does not set a hard cap on htlcs by default. The way how I > understand the code they allow up to 483 htlcs by default: > > The test when adding an htlc if it is beyond the maximum accepted values > is here: > > https://github.com/lightningnetwork/lnd/blob/970d7604071baae227db42d4665ef9d1b56988e8/lnwallet/channel.go#L3795 > > the default configuration seems to be here (and in the most recent commit > the line still exists): > > https://github.com/lightningnetwork/lnd/blob/8b04cfbf12f460853e8c55611cd1bba21b1510ef/input/size.go#L187 > > the software will accept up to 483 htlcs according to this line: > > https://github.com/lightningnetwork/lnd/blob/111cbeaa990cba78563d6cc8c19b152e2d3042f6/lnwallet/reservation.go#L314 > > I could not find any spec lower than that in the suggested sample config > at: > https://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf > > > Ideas for Fixes > =========== > > I am completely unhappy with each of the following ideas. I hope you will > come up with smarter solutions. I believe the solution is not obvious. Thus > I thought it makes sense in the brainstorm phase to even post some ideas > with obvious drawbacks. > > 1. The current solution is to just not use up the max value of > htlc's. Eclaire and c-lightning by default only use up to 30 htlcs. > 2. Probably the best fix (not sure if I understand the consequences > correctly) is coming from this PR to bitcoin core (c.f. > https://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get > it correctly with that we could always have low fees and ask the person who > want to claim their outputs to pay fees. This excludes overpayment and > could happen at a later stage when fees are not spiked. Still the victim > who offered the htlcs would have to spend those outputs at some time. > 3. Don't overpay fees in commitment transactions. We can't foresee the > future anyway > 4. Don't add htlcs for which the on chain fee is higher than the HTLCs > value (like we do with sub dust amounts and sub satoshi amounts. This would > at least make the attack expensive as the attacker would have to bind a lot > of liquidity. > 5. Somehow be able to aggregate htlc's. In a world where we use payment > points instead of preimages we might be able to do so. It would be really > cool if separate HTLC's could be combined to 1 single output. I played > around a little bit but I have not come up with a scheme that is more > compact in all cases. Thus I just threw in the idea. > 6. Split onchain fees differently (now the attacker would also lose fees > by conducting this attack) - No I don't want to start yet another fee > bikeshadding debate. (In particular I believe that a different split of > fees might make the Flood & Loot attack economically more viable which > relies on the same principle) > > Independently I think we should have a hint in our readme file about where > and how people can disclose attacks and vulnerabilities. Implementations > have this but the BOLTs do not. > > with kind regards Rene > > -- > > https://www.rene-pickhardt.de > > Skype: rene.pickhardt > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
Hi Jeremy,
The up-front costs can be further mitigated even without something like CTV (which makes things more efficient) by adding a layer of in-direction w.r.t how HTLCs are manifested within the commitment transactions. To do this, we add a new 2-of-2 multi-sig output (an HTLC indirect block) to the commitment transactions. This is then spent by a new transaction (the HTLC block) that actually manifests (creates the HTLC outputs) the HTLCs.
With this change, the cost to have a commitment be mined in the chain is now _independent of the number of HTLCs in the channel_. In the past I've called this construction "coupe commitments" (lol).
Other flavors of this technique are possible as well, allowing both sides to craft varying HTLC indirection trees (double layers of indirection are possible, etc) which may factor in traits like HTLC expiration time (HTLCs that expire later are further down in the tree).
Something like CTV does indeed make this technique more powerful+efficient as it allows one to succinctly commit to all the relevant desirable combinations of HTLC indirect blocks, and HTLC fan-out transactions.
-- Laolu
On Sat, Jun 20, 2020 at 4:14 PM Jeremy <jlrubin at mit.edu> wrote:
Quoted text (123 lines)
> I am not steeped enough in Lightning Protocol issues to get the full > design space, but I'm fairly certain BIP-119 Congestion Control trees would > help with this issue. > > You can bucket a tree by doing a histogram of HTLC size, so that all small > HTLCs live in a common CTV subtree and don't interfere with higher value > HTLCs. You can also play with sequencing to prevent those HTLCs from > getting longchains in the mempool until they're above a certain value. > -- > @JeremyRubin <https://twitter.com/JeremyRubin> > <https://twitter.com/JeremyRubin> > > > On Thu, Jun 18, 2020 at 1:41 AM Antoine Riard <antoine.riard at gmail.com> > wrote: > >> Hi Rene, >> >> Thanks for disclosing this vulnerability, >> >> I think this blackmail scenario holds but sadly there is a lower scenario. >> >> Both "Flood & Loot" and your blackmail attack rely on `update_fee` >> mechanism and unbounded commitment transaction size inflation. Though the >> first to provoke block congestion and yours to lockdown in-flight fees as >> funds hostage situation. >> >> > 1. The current solution is to just not use up the max value of >> htlc's. Eclaire and c-lightning by default only use up to 30 htlcs. >> >> As of today, yes I would recommend capping commitment size both for >> ensuring competitive propagation/block selection and limiting HTLC exposure. >> >> > 2. Probably the best fix (not sure if I understand the consequences >> correctly) is coming from this PR to bitcoin core (c.f. >> https://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get >> it correctly with that we could always have low fees and ask the person who >> want to claim their outputs to pay fees. This excludes overpayment and >> could happen at a later stage when fees are not spiked. Still the victim >> who offered the htlcs would have to spend those outputs at some time. >> >> It's a bit more complex, carve-out output, even combined with anchor >> output support on the LN-side won't protect against different flavors of >> pinning. I invite you to go through logs of past 2 LN dev meetings. >> >> > 3. Don't overpay fees in commitment transactions. We can't foresee the >> future anyway >> >> Once 2. is well-addressed we may deprecate `update_fee`. >> >> > 4. Don't add htlcs for which the on chain fee is higher than the HTLCs >> value (like we do with sub dust amounts and sub satoshi amounts. This would >> at least make the attack expensive as the attacker would have to bind a lot >> of liquidity. >> >> Ideally we want dust_limit to be dynamic, dust cap should be based on >> HTLC economic value, feerate of its output, feerate of HTLC-transaction, >> feerate estimation of any CPFP to bump it. I think that's kind of worthy to >> do once we solved 3. and 4 >> >> > 5. Somehow be able to aggregate htlc's. In a world where we use payment >> points instead of preimages we might be able to do so. It would be really >> cool if separate HTLC's could be combined to 1 single output. I played >> around a little bit but I have not come up with a scheme that is more >> compact in all cases. Thus I just threw in the idea. >> >> Yes we may encode all HTLC in some Taproot tree in the future. There are >> some wrinkles but for a high-level theoretical construction see my post on >> CoinPool. >> >> > 6. Split onchain fees differently (now the attacker would also lose >> fees by conducting this attack) - No I don't want to start yet another fee >> bikeshadding debate. (In particular I believe that a different split of >> fees might make the Flood & Loot attack economically more viable which >> relies on the same principle) >> >> Likely a bit more of fee bikeshedding is something we have to do to make >> LN secure... Switching fee from pre-committed ones to a single-party, >> dynamic one. >> >> > Independently I think we should have a hint in our readme file about >> where and how people can disclose attacks and vulnerabilities. >> Implementations have this but the BOLTs do not. >> >> I 100% agree, that's exactly >> https://github.com/lightningnetwork/lightning-rfc/pull/772, waiting for >> your feedback :) >> >> Cheers, >> >> Antoine >> >> Le mer. 17 juin 2020 à 09:41, ZmnSCPxj via Lightning-dev < >> lightning-dev at lists.linuxfoundation.org> a écrit : >> >>> >>> Good morning all, >>> >>> > >>> > Fee futures could help against this. >>> > I remember writing about this some time ago but cannot find where (not >>> sure if it was in lightning-dev or bitcoin-dev). >>> >>> `harding` found it: >>> https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-January/017601.html >>> >>> Regards, >>> ZmnSCPxj >>> _______________________________________________ >>> Lightning-dev mailing list >>> Lightning-dev at lists.linuxfoundation.org >>> https://www.learnbitcoin.com/archive/lists/lightning-dev >>> >> _______________________________________________ >> Lightning-dev mailing list >> Lightning-dev at lists.linuxfoundation.org >> https://www.learnbitcoin.com/archive/lists/lightning-dev >> > _______________________________________________ > Lightning-dev mailing list > Lightning-dev at lists.linuxfoundation.org > https://www.learnbitcoin.com/archive/lists/lightning-dev >
On Sun, Jun 21, 2020 at 06:09:28PM -0700, Olaoluwa Osuntokun wrote:
Quoted text (3 lines)
> IMO this is mostly mitigated by anchor commitments. The impact of this > attack is predicated on the "victim" paying 5x on-chain fees (for their > confirmation target) to sweep all their HTLCs.
I think the attack is more clearly stated in absolute terms. An attacker can force a victim to pay for 483 P2WSH outputs (each 43 vbytes), or a total of about 20,000 vbytes (plus regular overhead).
20769 = 43 * 483
During the post-halving feerate spike just a few weeks ago, paying 100 base units ("satoshis") per vbyte was plausible to ensure the commitment transaction confirmed quickly. At $9,500 USD/BTC, that's almost $200 USD.
197.3055 = 20769 * 100 / 1e8 * 9500
With a 5x multiplier, that's horrible, but even with no multiplier, it's not good. Moreover, a patient attacker can wait for a fee spike and then attack multiple channels at once so that they compete against each other for block space, potentially raising feerates even higher.
Quoted text (4 lines)
> In addition to being able to pay much lower fees ("just enough" to get into
> the chain), anchor commitments allow second-level HTLC _aggregation_, This
> means that for HTLCs with the same expiry height, a peer is able to _batch_
> them all into a single transaction, further saving on fees.(I was initially confused by this, so for anyone else confused by this, the batching being described here is sort of the inverse of normal payment batching. Normally when you batch together multiple payments, you use one input to pay more outputs than you would with separate transactions. Here, you still need to use the same number of inputs you would to resolve HTLCs in separate ransactions (because each HTLC is a separate UTXO), but you pay a single output. This works and is indeed a nice optimization.)
Quoted text (2 lines)
> Alternatively, they could use something like Lightning Loop to gain the > _outbound_ bandwidth (Loop In)
I don't think the attacker needs outbound bandwidth. As implied in René's post ("achieved with circular onions"), if the attacker is Mallory and the victim is Bob, there just needs to be a circuit like:
Mallory → Alice → Bob → Mallory
Mallory can always settle with Alice offchain after Bob's timeout, preventing Mallory from losing any money in the attack or from having to pay for liquidity. IIUC, Mallory's only cost would be paying for LN routing fees and the time value of locking up her money until the settlement.
Quoted text (2 lines)
> No, the attacker is the one that needs to sweep these HTLCs, since they > offered them. This adds to their costs.
As described above, the attacker doesn't need to offer the HTLCs, they can simply route a payment through any of the victim's other channels.
If the attacker does that, then the victim needs to pay onchain fees to recover any remaining value in those HTLCs, potentially making this attack two or three times more costly for the victim.
Quoted text (5 lines)
> > 1. The current solution is to just not use up the max value of htlc's. > > Eclaire and c-lightning by default only use up to 30 htlcs. > > IMO, this isn't a solution. Lowering the max number of HTLCs in-flight just > makes it easier (lowers the capital costs) to jam a channel.
It looks to me like an easy and effective solution to turn a ~$200 downside into a ~$20 downside (at 100 base units/vbyte). It's certainly has other downsides too, but I'm personally more concerned about losing money than I am about having my channel jammed (and if jamming at 483 HTLCs is an issue, then hopefully the mitigation for that (e.g. upfront fees) will make jamming at HTLCs a non-issue as well).
-Dave
Yes -- to be clear, most of the feature-wise benefits of CTV for Lightning are only in the initial channel setup phase, lessening interactivity requirements.
Everything else can be emulated via multisig layers, but that can add substantial latency in doing either 2pECDSA for each layer or on chain & storage overhead in the signature space. CTV helps here because it can be both deterministic & compact, but is not adding a new feature to already interactive protocols. This does end up helping in terms of the feasibility of some of the HTLC indirection tree techniques though :).