{"type":"rich","version":"1.0","author_name":"npub1zlxd3xlzjhq2ue03e5m5p2w6mp8v3dkhq5r39flsftjjsje04wvsdd2k4w","author_url":"https://nostr.ae/npub1zlxd3xlzjhq2ue03e5m5p2w6mp8v3dkhq5r39flsftjjsje04wvsdd2k4w","provider_name":"njump","provider_url":"https://nostr.ae","html":"📅 Original date posted:2020-06-17\n📝 Original message:\nHey everyone and of course good morning ZmnSCPxj (:\n\nabout 11 months ago I discovered a potential blackmail attack with HTLCs\nafter answering this question on stack exchange (c.f\nhttps://bitcoin.stackexchange.com/questions/89232/why-is-my-spendable-msat-much-lower-than-msatoshi-to-us/89235#89235).\nThis attack is similar to the one that was possible with tx malleability on\nthe funding transaction without the segwit upgrade (c.f.\nhttps://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\u0026page=126).\nMeaning an attacker can force a victim to lose money and use this fact to\nblackmail the victim, to potentially gain / steal some of the lost funds.\n\nTL;DR:\n=====\n* Depending on the circumstances this attack allows an attacker to make\nchannel partners lose a substantial amount of BTC without substantial costs\nfor the attacker.\n* Depending on the exact circumstances this could be for example ~0.15 BTC.\nIn particular it demonstrates why opening a channel is not an entirely\ntrustless activity.\n* The attacker will reliably only be able to force the victim to lose this\namount of Bitcoin.\n* It is not clear how in practice the attacker could gain this amount or\nparts of it as this would involve not only game theory but also rather\nquick communication between attacker and victim and customized Lightning\nnodes which at least for the victim would be unlikely to exist.\n* None of the suggested fixes seems to be satisfying though the current\nsolution of lowering the maximum amount of HTLCs that can concurrently be\nin flight seems to be a reasonable start for now.\n\n\nTimeline on Disclosure\n=================\nI have disclosed this attack on Sunday July 21st 2019 to Fabrice Drouin\n(and shortly after to Christian Decker) in a phone call who in turn has\ndiscussed it with people from the other implementations. From his feedback\nI understood that people working on implementations have been more or less\naware of the possibility of this attack. Fabrice also mentioned that he\nbelieved implementations currently try to mitigate this by setting low\nlimits of allowed / accepted HTLCs in flight. However at that time this was\nonly true for e-clair. It is now also true for c-lightning and as far as I\nknow still not true for lnd. Fabrice said that the people he talked to have\nsuggested that I should eventually describe the attack in public to raise\nawareness (also from the group of node operators) for the problems related\nto this attack. He also suggested that - if I wanted to - I should update\nthe rfc with recommendations  and warnings. While I already have in mind\nhow to change the rfc I wanted to start the discussion first. Maybe some\npeople find better fixes than just a warning that I have in mind. So far I\ndidn't do anything because I wanted to also give lnd the chance to handle\nthe problem.\n\nThere are two reasons I disclose this attack today:\n1.) I think almost 1 year is enough time to do something about it. The only\nimplementation that afaik didn't yet is lnd (see below) but I got roasbeefs\nok last week to go ahead and publish the attack anyway so that we can have\na broader discussion on mitigation strategies.\n2.) The attack seems actually very similar to the one described in the\n\"Flood \u0026 Loot: A Systemic Attack On The Lightning Network\" - paper which\ncame out 2 days ago (c.f.: https://arxiv.org/abs/2006.08513 ). I believe\nany person reading that paper will understand the possibility of the attack\nthat I describe anyway so I believe it is now more or less public anyway\nand thus time for an open / public discussion.\n\nThe main difference between the two attacks (if I understand this novel\npaper correctly) is: In the \"flood and loot\"-attack one tries to steal the\nHTLC output of the victims. Where in the \"flood and blackmail\"-attack that\nI describe I try to to force the victim to lose almost all its funds due to\nhigh on chain fees (Which I could use to blackmail the victim)\n\nDescription of the attack\n===================\nLet us assume the victim has funded a channel with an attacker meaning it\nwill have to pay the fees for the commitment transaction in case of a force\nclose.\n\nDuring a fee spike (let us assume fee estimators suggest 150 sat / byte)\nthe attacker spams this channel with the maximum possible amount of HTLCs\nthat the protocol allows. The HTLCs can be of a small value but need to be\nbigger than the dust limit so that additional outputs are actually added to\nthe commitment transaction which makes it quite large in Bytes. According\nto the BOLTs these are 483 additional outputs to the commitment\ntransaction.\nThe direction of HTLCs are chosen so that the amount is taken from the\n`to_remote` output of the attacker (obviously on the victims side it will\nbe the `to_local` output) For the actual attack it does not matter in which\ndirection the HTLCs are spammed but economically the direction I propose\nmakes even more sense for the attacker and can be achieved with circular\nonions.\n\nThe attacked channel partner will happily - according to the protocol - use\na higher fee than the current fee rate. I quote from BOLT 02 which suggests\na buffer of a factor of 5\nhttps://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#updating-fees-update_fee:\n\n\n\u003e The node responsible for paying the Bitcoin fee [...] SHOULD send\nupdate_fee to ensure the current fee rate is sufficient (by a significant\nmargin) for timely processing of the commitment transaction. [...] Given\nthe variance in fees, and the fact that the transaction may be spent in the\nfuture, it's a good idea for the fee payer to keep a good margin (say 5x\nthe expected fee requirement); but, due to differing methods of fee\nestimation, an exact value is not specified.\n\nThis overpayment of fees will result in 750 sat / byte for this fee spike\nscenario. This is by the way not completely unrealistic [I recently opened\na channel with 2.56 sat / byte (c.f.:\nhttps://www.smartbit.com.au/tx/c0ac6cfe15e0d0c921362ab9fad998a8a8e16cd8d9d4159487dd69141ea2b9b0)\nand the channel was force closed a couple minutes later due to an\nimplementation bug resulting in fees of 101.17 sat / byte (c.f.:\nhttps://www.smartbit.com.au/tx/e32135315ec147bb27f771b2e15c7178ea573afd16cd4970bf814c9b18bc46e3\n)\n\nAs far as I understand the appendix of BOLT 03 offered HTLCs are 43 Byte in\nsize (c.f.:\nhttps://github.com/lightningnetwork/lightning-rfc/blob/master/03-transactions.md#appendix-a-expected-weights)\nresulting in the following additional fees for the spammed commitment\ntransaction:\n\nfee (for 483 htlcs)  = 483 * 43 byte * 750 sat / byte = 15576750 sat =\n0.1557675 BTC\n\nAdditionally the victim will also have to swipe all offered HTLCs (which\nwill be additional costs but could be done once the fees came down) so we\nneglect them.\n\nOnce all HTLCs are set up the attacker will stop signing commitment\ntransactions. In the beginning this is not suspicious as the HTLCs will\ntake some time to settle anyway. But also when fees go down and the victim\nwho funded the channel wants to update the fees the attacker will just not\nbe responsive. Eventually the victim will dare to force close the channel\nwith all those expensive HTLCs.\n\nKnowing that this will happen and that the victim has to spend those funds\n(publishing old state obviously does not work!) the attacker has a time\nwindow to blackmail the victim outside of the lightning network protocol:\n\"Either you will pay those 0.1557675 BTC of fees or we will collaboratively\nclose the channel but that will cost you part of the amount you lost.\" Game\ntheory suggests that the attacker will be able to claim the major fraction\nof the BTC (c.f. https://en.wikipedia.org/wiki/Ultimatum_game that are\nfrozen in tx fees as the victim effectively already has lost that money and\ncan only gain something back.\n\n\nThoughts\n=======\nYou might say that the blackmail part of this attack is unrealistic as the\nblackmailing person will not have enough time to successfully do the\nblackmail as the channel that is not operational will fail.\n\n1.) The only thing that lightning nodes might do is a fee update as the\nhtlcs stuffed the channel so I believe there is actually some time to\ncontact the victim.\n2.) What if the attacker is a mining pool who is just interested in high\nfees who does not even need to do the blackmailing stuff but will just\nforce close the channel once the htlcs are set up?\n3.) The attacker might not even be interested in blackmailing the victim.\nThe attacker could just be interested in harming the victim. Though it\nmight certainly be a challenge to target a specific victim and trick it\ninto opening a channel with an attacker.\n\nAlso you might say that an attacker needs many incoming channels to execute\nthis attack. This can be achieved by gaming the autopilot. an attacker can\nstart by creating many channels making him a highly likely channel partner\nfor autopilot users (who will also fund the channel). Such a highly\nconnected node might also be interesting for non autopilot users.\n\nImplementations\n============\n\nI looked at the code myself. I hope I do oversee things but to me it looks\nlike only eclaire was somehow mitigating this attack from being exploited.\n(by a default config of 30 accepted htlcs which will protect the average\nuser and is much lower than the 483) and c-lightning has merged a patch\nfrom me which I provided after I disclosed the attack:\n\n## clightning:\n\nc-lightning did not by default set a hard cap on htlcs before version 0.7.2\nbut then merged my patch\nhttps://github.com/ElementsProject/lightning/pull/2858 which tried to\nresemble the eclair defaults\n\n## eclaire:\n\nthe max accepted htlc value per channel is set as a constant to 483 which\nfollows the recommendation of the BOLTs:\nhttps://github.com/ACINQ/eclair/blob/e62adf2deae213d2cd0f2a6874227dcfc57880ae/eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala#L52\n\nThe value is tested against at:\nhttps://github.com/ACINQ/eclair/blob/f724efaa76b256048de18f706e9cb58ecbebd6aa/eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala#L99\n\nand:\nhttps://github.com/ACINQ/eclair/blob/f724efaa76b256048de18f706e9cb58ecbebd6aa/eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala#L132\n\nand:\nhttps://github.com/ACINQ/eclair/blob/93d9369f900766171f2ddf579e8b12e28d8f0d25/eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala#L154\n\nHowever the default config file specifies a maximum amount of 30 accepted\nhtlcs at:\nhttps://github.com/ACINQ/eclair/blob/9afb26e09c69dd5d6a14732baf5dcdf2b7a9142b/eclair-core/src/main/resources/reference.conf#L62\n\n\n## lnd\nIt seems like lnd did not and last time I checked (maybe I oversaw\nsomething) does not set a hard cap on htlcs by default. The way how I\nunderstand the code they allow up to 483 htlcs by default:\n\nThe test when adding an htlc if it is beyond the maximum accepted values is\nhere:\nhttps://github.com/lightningnetwork/lnd/blob/970d7604071baae227db42d4665ef9d1b56988e8/lnwallet/channel.go#L3795\n\nthe default configuration seems to be here (and in the most recent commit\nthe line still exists):\nhttps://github.com/lightningnetwork/lnd/blob/8b04cfbf12f460853e8c55611cd1bba21b1510ef/input/size.go#L187\n\nthe software will accept up to 483 htlcs according to this line:\nhttps://github.com/lightningnetwork/lnd/blob/111cbeaa990cba78563d6cc8c19b152e2d3042f6/lnwallet/reservation.go#L314\n\nI could not find any spec lower than that in the suggested sample config\nat:\nhttps://github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf\n\n\nIdeas for Fixes\n===========\n\nI am completely unhappy with each of the following ideas. I hope you will\ncome up with smarter solutions. I believe the solution is not obvious. Thus\nI thought it makes sense in the brainstorm phase to even post some ideas\nwith obvious drawbacks.\n\n1. The current solution is to just not use up the max value of\nhtlc's. Eclaire and c-lightning by default only use up to 30 htlcs.\n2. Probably the best fix (not sure if I understand the consequences\ncorrectly) is coming from this PR to bitcoin core (c.f.\nhttps://github.com/bitcoin/bitcoin/pull/15681 by @TheBlueMatt . If I get it\ncorrectly with that we could always have low fees and ask the person who\nwant to claim their outputs to pay fees. This excludes overpayment and\ncould happen at a later stage when fees are not spiked. Still the victim\nwho offered the htlcs would have to spend those outputs at some time.\n3. Don't overpay fees in commitment transactions. We can't foresee the\nfuture anyway\n4. Don't add htlcs for which the on chain fee is higher than the HTLCs\nvalue (like we do with sub dust amounts and sub satoshi amounts. This would\nat least make the attack expensive as the attacker would have to bind a lot\nof liquidity.\n5. Somehow be able to aggregate htlc's. In a world where we use payment\npoints instead of preimages we might be able to do so. It would be really\ncool if separate HTLC's could be combined to 1 single output. I played\naround a little bit but I have not come up with a scheme that is more\ncompact in all cases. Thus I just threw in the idea.\n6. Split onchain fees differently (now the attacker would also lose fees by\nconducting this attack) - No I don't want to start yet another fee\nbikeshadding debate. (In particular I believe that a different split of\nfees might make the Flood \u0026 Loot attack economically more viable which\nrelies on the same principle)\n\nIndependently I think we should have a hint in our readme file about where\nand how people can disclose attacks and vulnerabilities. Implementations\nhave this but the BOLTs do not.\n\nwith kind regards Rene\n\n-- \n\nhttps://www.rene-pickhardt.de\n\nSkype: rene.pickhardt\n-------------- next part --------------\nAn HTML attachment was scrubbed...\nURL: \u003chttp://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20200617/07158fbc/attachment-0001.html\u003e"}
