Introducing the first chapter of Tookey.io’s “Hacks in-depth,” we’d like to provide information and insights into what really transpired in each hack instance, as well as statistics and key lessons.
Follow us for the latest crypto news and instructive articles!
Badger DAO
What happened during the Badger DAO hack, and why does it matter?
Over $120 million in bitcoin was stolen in a couple of minutes on December 2nd, 2021. Attackers were able to abuse users of the BadgerDao Decentralized Autonomous Organization (DAO).
Hackers took advantage of a design flaw in how crypto wallets ask their users to confirm certain transactions. Read more about the assault, our findings, and practical security advice.
What exactly is BadgerDAO?
BadgerDAO is a DAO built on Ethereum smart contracts that aims to introduce Bitcoin to the web3 realm of decentralized finance (DeFi).
Before now, the majority of DeFi’s web3 innovations have occurred on the Ethereum blockchain, making it impossible for Bitcoin investors to have access to everything DeFi has to offer, notably asset interest.
According to its homepage, BadgerDAO’s goal is to develop solutions that will allow Bitcoin users to obtain access to the web3 world of DeFi in a multi-step procedure.
Recognizing web3 approvals
To comprehend this assault, we should first understand how web3 apps interact with consumers, especially their ERC20 tokens.
When a web3 app wants its user to undertake an activity on the blockchain (for example, transfer token A to an application in order to collect token B from it), it follows the four steps below:
- It executes the user’s requested transaction.
- It routes the transfer through a bridge or gateways to the user’s wallet (like WalletConnect or a web extension)
- The transaction is signed by the user using their wallet.
- The signing event is sent to the blockchain by the user.
While paying for the web3 app with an ERC20 token, customers cannot simply transfer the needed number of tokens to the app’s smart contract address. Rather, users must confirm the app’s request to transfer tokens so that the app can withdraw these tokens afterward on its own.
While this may appear to be a minor distinction, it is significant: In fact, many applications request clearance for an almost infinite number of tokens rather than asking for approval for only the minimum quantity. This is frequently done to decrease transaction costs.
Because transaction costs may be fairly costly, instead of asking for approval for each transaction — which needs a processing charge — this “unbounded token request” has evolved into a widely accepted industry standard.
As a result, web3 users are accustomed to authorizing quite large sums. The participant’s sole defense is to ensure that they are communicating with a reliable application and that the permission request makes sense in the context of their present engagement.
The Heist: stealing an infinite number of tokens
Attackers gained access to the Badger application’s webpage and injected harmful javascript code. This malware created rogue transaction approvals, which, if granted by users, would enable the criminals to withdraw cash from BadgerDAO-controlled wallets at a later stage.
According to BadgerDAO’s own post-mortem, hackers silently implemented this malware in November 2021. The hackers were able to obtain their first unauthorized permission on November 20th, 2021, but they simply waited for a large enough victim to fall into their trap. It happened on December 1st, 2021. A user, purportedly affiliated to Celsius and holding $50 million in an ERC20 token, granted the attackers access to their funds.
The hackers swiftly replied by removing all of this suspect’s cash worth $50 million, and afterward drained all other victims’ accessible accounts acquired throughout the course of the attacker’s operations, for a cumulative total of $120 million.
When we examined closely the information stored on the blockchain, we noticed a difference between the attackers’ initial successful attempt and their final strike.
Hackers employed the well-known “approve approach” outlined at the start of this piece in the first batch of attempted attacks. They then altered the desired transaction type to “increaseAllowance.”
While they share almost identical functionality, the latter is far less well-known among consumers and is rarely supported by wallets.
We constructed a test environment with a test web3 app that employs the lesser-known “increaseAllowance” mechanism to test wallet behavior. According to various sources, the $50 million victim used the popular web3 wallet Metamask. As a result, we were particularly interested in testing this wallet.
Metamask displays “Approve” in a sensible manner and also as an ERC20 token transaction. This approval’s graphic design also conveys a feeling of urgency, implying that the user exercise caution in determining whether or not to approve this request.
While presenting an “increaseAllowance” approval, the visual signals are not nearly as powerful, and there is no indication that this is an ERC20-related interaction, implying to the user that this is a typical activity with minor consequence and so does not require a critical eye.
We could deduce from evaluating the attackers’ injected script that the attackers actively modified the transaction’s function from “approve” to “increaseAllowance.” We believe this was done in reaction to the change in wallet user experience, which looked to improve attack success considerably.
We notified Metamask about the problem, and they stated that they “are actively working on some confirmation review-ability changes.”
Conclusions and suggestions
The wallet user experience of accepting ERC20 transactions is now the user’s final and only line of protection against this kind of attack.
As a result, wallets must be clear to their users when they are asking them to allow almost limitless financing access to web3 apps, and they must include visual indicators that indicate the depth insights of these approvals and any anomalies to their users. We absolutely want to solve such concerns in our planned web3 application implementation in Tookey.