A standard way to transact bitcoin could be misused to enable a kind of double-spending, new research has found.Â
Blockchain sleuths at ZenGo, a wallet startup, have found a vulnerability that affected at least three major competing crypto wallets â Ledger Live, Edge and Breadwallet (BRD) â and potentially more.Â
The bug, which the Tel Aviv-based firm calls BigSpender, allows a hacker to double-spend a userâs funds and possibly prevent them from ever using their wallet again. It works by exploiting how certain walletâs handle Bitcoinâs replace-by-fee (RBF) function, a failsafe that enables users to swap an unconfirmed transaction with one that has a higher fee.Â
â[BigSpender] can lead to substantial financial losses and in some cases to make the victimâs wallet totally unusable, with no way for the victim to protect themselves,â ZenGo CEO Ouriel Ohayon said in an email. âSo this can be seen as a high severity attack.â
Like other optional Bitcoin features with associated vulnerabilities, such as time-locked transactions, the RBF function has become a standard way for users to send value back and forth. It was pitched and accepted by the developer community as a way for Bitcoiners to circumvent slow confirmation times by paying more in fees.Â
See also: Raphael Auer â The Security Trilemma and the Future of Bitcoin
From the outset, there were fears the RBF function was not well supported by bitcoin wallets, despite being integrated at the Bitcoin systemâs protocol layer, the pseudonymous Bitcoin researcher 0xB10C said. âZenGo shows that a user can be tricked into thinking he is receiving bitcoin when he is not. I believe this to be novel. Iâve at least not heard about it before,â he said.Â
The firm tested nine different wallets including Ledger Live, Trust wallet, Exodus, Edge, Bread, Coinbase, Blockstream Green, Blockchain and Atomic Wallet. Of those tested, three were found to be vulnerable to the theoretical exploit.Â
âWe have not tested all the wallets but it could be that if three of the largest are implicated, more out there are, too,â Ohayon said. ZenGo alerted the firms about its findings, and gave them 90 days to repair the vulnerability.Â
Ledger and BRD have released code changes to prevent the attack from happening, and paid undisclosed bug bounties to ZenGo, while Edge is undergoing a âsignificant refactorâ that will address the issue, Edge CEO Paul Puey said in an email.Â
The hack leverages a known vulnerability in how certain wallets treat unconfirmed transactions, including but not limited to RBF ones, said Peter Todd, a former Bitcoin developer and RBFâs architect.Â
How it works: Attackers send funds to their intended victim, and set fees low enough to nearly guarantee the transaction will not receive a confirmation. For vulnerable wallets, this pending transaction will be reflected as an increase in the recipientâs account balance, possibly leading some victims to erroneously believe the pending transaction has already been confirmed. The attacker then âcancelsâ the pending transaction, in ZenGoâs terminology, by using RBF to change the recipient to an address they control. By the time the victim realizes that the transaction has, in fact, been canceled, heâll have delivered the goods.
To be clear: Similar attacks were possible before RBF, but in the absence of proper precautions by wallet providers, the payment option has highlighted the risk.Â
This discrepancy between a victimâs stated and actual balance could be exploited by malicious actors tricking people into providing goods or services without paying for them â except the minimal amount of fees spent. In this sense, the flaw is with a walletâs UX and UI design.
If a hacker can trick a person into believing they received payment, while simultaneously maintaining control of the bitcoin, this is a double-spend, according to ZenGoâs researchers. Others contest this use of the term.Â
âYou have to decide what is the definition of a double-spend. Most people that arenât trolls would say that a double-spend is when you have a confirmed transaction that is somehow invalidated and spent with a different confirmed transaction,â Jameson Lopp, CTO of custody startup Casa.Â
This attack, by its nature, takes advantage of the way wallets display unconfirmed transactions. In this sense, the attack â while fraudulent â isnât breaking the way the Bitcoin code functions. Â
âThe whole point of the blockchain is to prevent the double-spend problem,â Lopp said. âIt goes back to the original Satoshi white paper, which says the solution to double-spending is to have a distributed ledger that many people are checking.âÂ
The only thing you can rely on is transactions that have been mined
A general rule of thumb when transacting with bitcoin is to never trust a transaction with fewer than six confirmations, 0xB10C said. This was a point repeated by a number of developers, including Todd, Lopp and BRD CTO Samuel Sutch. If this exploit goes through, at least some of the responsibility is on the victim.Â
âThe only thing you can rely on is transactions that have been mined,â Todd said.
In this sense, Sutch called BigSpender a âminor bug,â and âkind of contrived,â but also something worth fixing and paying a bug bounty for. BRD recently passed 5 million users, Sutch said.Â
âMore wallet developers need to know their users donât know the distinctions under the hood,â Lopp said. Many donât even know the difference between confirmed and unconfirmed from a security standpoint. So the onus is on developers to build a better user experience so they cannot be confused and defrauded by things like this.â
To this end, Ledger updated the way the wallet displays pending transactions. If users are unsure âto check the status of a transactionâ using a block explorer. âSuch verification is not possible with your bank today,â Ledgerâs CTO Charles Guillemet said over email.
Updating wallets to clearly display what is happening during a RBF transaction is well and good for everyone involved. However, ZenGo researchers found there is a second-order attack, which follows the same scheme outlined above, and could permanently disable a wallet with or without the victimâs knowledge of the transaction.Â
In this case, the attacker again artificially inflates a victimâs balance by sending repeated transactions to her wallet. This can be done without a victimâs consent. By rerouting the transactions before they are confirmed, the victimâs stated wallet balance and actual funds are again decoupled, making their wallet unusable. Worse, the attack can affect multiple wallets at the same time.Â
See also: Long-Festering DeFi Dapp Bug Still Not Fixed by Industry (Updated)
Essentially, itâs a denial of service (DoS) attack, preventing people from using their wallets.
âThis also disables other kinds of sending attempts if the walletâs coin selection algorithm chooses funds from this nonexistent transaction,â Ohayon said. These wallets are âbricked,â to use Sutchâs parlance. âItâs a huge inconvenience.â
Sutch said BRD made the vulnerability a top priority for the firm after it was alerted. Strangely, it managed to fix the bug while working an unrelated problem, he said.Â
The issue ZenGo raises with its security research is not sequestered to the wallets the team tested. The vast majority of Bitcoin wallets are capable of receiving RBF transactions, and many of the companies behind them are âresource-constrained,â Sutch said, and are unable to provide a fix immediately. Â
When enabling RBF functionality on Casa, Lopp said he configured the system to not display these types of transactions until confirmed, which is non-standard in the industry. âThe default parameters would display these transactions,â he said.
Update (July 2, 20:15 UTC): A passage paraphrasing Peter Todd was modified to make it clear he was referring to the problem of how some Bitcoin wallets display unconfirmed transactions broadly, not just RBF transactions. Other passages were revised for clarity as well.Â