Savvy attackers might be able to âlootâ bitcoin from others by way of the Lightning Network if users arenât careful, a new cybersecurity report warns.Â
The Hebrew University of Jerusalem computer scientists Jona Harris and Aviv Zohar have taken a closer look at a âsystemicâ Lightning Network attack that could lead to loss of funds. The attack, which they describe in their new paper, âFlood & Loot: A Systemic Attack on the Lightning Network,â preys on Bitcoin blockchain congestion.Â
The problem with the Bitcoin blockchain is itâs slow to settle payments and it only supports a few transactions per second. The Lightning Network is a second-layer solution that helps to solve this massive problem by pulling payments off the Bitcoin blockchain.Â
But Lightning is still tied to the Bitcoin blockchain. This attack exploits the connection and tries to take advantage of Bitcoinâs aforementioned limitations.
Developers have long known about this attack vector. But before Harrisâ and Zoharâs report, no one had done a deep analysis to measure in detail how feasible such an attack would be. These researchers found an attack is not very hard and it could be lucrative for attackers.
âThe resulting high volume of transactions in the blockchain will not allow for the proper settlement of all debts, and attackers may get away with stealing some funds,â writes Harris in a post explaining the mechanics of the attack.
Harris cautions users not to experiment with this attack since it âcan allow funds to be stolen from innocent users. Do not try this at home.â
The attack relies on a couple components of the Lightning Network.Â
The whole point of the Lightning Network is to keep funds âoff-chain,â meaning âoffâ the Bitcoin blockchain. That way, people can make bitcoin payments while using bitcoinâs scarce block space as little as possible. Bitcoin only can handle a few transactions per second in total, which isnât a lot.
That said, if something goes wrong, a user always has the ability to kick their Lightning transaction back to the Bitcoin blockchain.
Read more: Lightning Solves Bitcoinâs Speed Problem, but Watch Out for Fraudsters
First, Lightning works the best when the underlying blockchain is used very minimally. The problem comes if a bunch of Lightning channels are closed at once in the âfloodâ portion of the attack: The underlying bitcoin network cannot handle the volume, leading to problems.Â
Second, thereâs an expiration date built into each transaction by which users can send their bitcoin back to the blockchain without someone stealing it.
The Lightning Network is made up of thousands of nodes. Similar to how the internet works under the hood, a payment needs to hop along several nodes before it reaches its destination. Lightning uses âhash time-locked contractsâ (HTLCs) undergirded by cryptography so that users donât have to trust their money with these complete strangers. HTLCs have baked in rules, such as requiring knowledge of a âsecretâ to obtain the bitcoin inside, which none of these intermediary strangers know.Â
But the researchers are exploring a way to kind of game the system. In short, HTLCs build a deadline into each of these payments, giving users a chance to âsettleâ their funds on the bitcoin blockchain if something goes awry. After this deadline passes, the HTLCs are up for grabs; as a result, a malicious user can steal the funds held in the contracts.Â
You might be able to see where this is going. Attackers take advantage of the blockchain congestion and pair it with exploiting the HTLC deadlines.Â
The attack relies on the bitcoin blockchain being filled to the brim with transactions so that no more can get through. The attacker hopes he or she can push the contracts past the built-in deadlines. If successful, the attacker can begin to âlootâ the expired contracts.
âBy attacking many channels and forcing them all to be closed at the same time [â¦], some of the victimsâ HTLC-claiming transactions will not be confirmed in time, and the attacker will steal them,â Harris explains in the blog post.
The researchers ran simulations on a test Lightning Network with dummy coins to test how feasible such an attack is.
In short, each closed channel results in one more transaction being pushed to the Bitcoin blockchain. The attacker will attempt to simultaneously close as many channels as possible to increase the number of transactions sent to the blockchain, increasing the chance of success.Â
Using their simulations, the researchers found that attacking 85 channels at once was enough to âguarantee a successful attack.â
Harris notes an attacker targeting 100 channels leads to a reward of âat leastâ 7402 HTLCs, with the average HTLC today holding about $138 worth of bitcoin. That could mean a payday of roughly $1,021,476.
They also found that, as expected, less block space leads to a higher attack success rate because an HTLC is less likely to go through before the deadline.
Finding âpotential victimsâ was also eerily easy. In the simulation, the researchers found it wasnât hard to set up channels with other users. Indeed, 95% of Lightning nodes accepted their invitations to set up a Lightning channel.
Still, this research could be seen as a part of a broader effort to improve the payment system and, one hopes, make it safer for more users. In this way, bitcoiners like to describe bitcoin as âanti-fragileâ â the more a system fails and the more it is subject to attacks, the stronger it gets.Â
The researchers argue the attack is systemic and âeliminating the risk entirely seems to be a complicated task.âÂ
That said, Harris suggests several strategies for solving the problem, or at least ameliorating it if the issue canât be stomped out entirely. One is increasing the HTLC deadline so it is easier for a user tp counter the attacker via the Bitcoin blockchain in time.
Lightning Network watchtower Teos developer Sergi Delgado told CoinDesk that so-called âanchor outputs,â an in-progress upgrade, could also make the attack much harder.Â
Anchor outputs would allow users to bump up their transaction fee to get the transaction into the Bitcoin blockchain faster. This step would make it more difficult for the attacker to prevent a counter-transaction from being sent to the blockchain.
âThe current, simple version of anchors doesnât fix it [â¦], but a more mature version should,â Delgado said.
Read more: Researchers Surface Privacy Vulnerabilities in Bitcoin Lightning Network Payments
The Lightning Network could significantly improve bitcoin payments by speeding them and scaling Bitcoin as a whole so more people can use the digital currency at once. But many argue the network isnât ready for prime time. As the network grows, researchers are exploring problems like this one in the hopes that one day they can be fixed.
With these and other potential improvements, Harris thinks thereâs hope. But it will take some work. âI believe the Lightning Network is here to stay, but of course more work is required in order to minimize the potential of such threats before [Lightning] could become mainstream. There are ongoing discussions in the community around this and I believe we are on the right track,â Harris said.