
A bug in Uniswap has been fixed that could have cost users millions, if not billions, of dollars. By total value locked, the DEX is the largest exchange in the world, with $3.26 billion in assets under management.
The Dedaub team was the first to identify the re-entrancy error that could have resulted in the loss of user funds. They then informed the Uniswap development group. The DEX developer acknowledged the error, fixed it, and redeployed the Universal Router smart contracts across all of Polygon’s chains.
The Dedaub team noted that this weakness was introduced as a result of Uniswap’s decision to introduce the Universal Router, which combines NFTs and ERC-20 (fungible) tokens into a single swap router. According to their analysis, malicious actors could “embed a scripting language for all kinds of token actions.”
“Such commands could include transfers to third party (potentially untrusted) recipients. In a correct implementation, such a transfer should send to the recipient only what the call parameters specify. However, if third-party code is invoked at any point in the transfer (which manifests itself due to composition of protocols), the code can reenter the Universal Router and claim any tokens temporarily in the contract.”
After Uniswap re-deployed the Universal Router and added “a re-entrancy lock to the core execution,” funds are now secure.
Because of the way transfers are handled in account-based blockchains like Ethereum, the re-entrancy attack is a common smart contracting mistake. Hackers have discovered this flaw over time and have stolen hundreds of millions of tokens.
For context, it should be noted that a re-entrancy attack was used to lock millions of ETH in the first-ever DAO in Ethereum, causing the network to split into the longer-chain Ethereum and the proof-of-work Ethereum classic.
In order to take advantage of this weakness, the attacker starts an endless loop between the weak smart contracts and their smart contract, draining the latter’s holdings of money. Once the transaction is approved from the pool, the victim cannot recover funds because smart contracts are executed on an immutable base layer.
Dedaub was awarded a $40k bounty as part of the $3 million program that Uniswap announced.