Type: #arbitraryData #validation
Project: Li.Fi protocol
Date: 16/07/24
Blockchain: Eth, Arbitrum
Problem: Possible calling arbitrary addresses with arbitrary data.
On July 11, 2024, Li.Fi added the GasZipFacet to their protocol, enabling ERC20 token swaps to native tokens and deposits to
gas.zip, and just five days after integrating new facet, the contract was exploited. The vulnerability was exactly the same as in previous protocol exploit, the LibSwap library allowed arbitrary calls to arbitrary contracts. Despite having contract and selector whitelists in other helper contract, developers mistakenly imported the incorrect contract during development, and the lack of an audit for the new facet compounded the issue. This has led to a problem that anyone could transfer from funds from the users wallets, who has made infinite approvals to the Li.Fi contract.
Lessons learned by Li.Fi:
1) Contracts must be audited.
2) The repo must have good test coverage to ensure secure code delivery.
3) Any written code which goes to production should be cross-checked and reviewed.
4) Add documentation to the code, specifying how to use libraries securely, there was no documentation in the hacked library.
5) Teams must prepare an incident response to be ready for any circumstances.
6) A contract should have a blacklist of function selectors/addresses.
7) All contracts of big protocols are always monitored by bad actors. For example, a Telegram channel posts new updates of proxy contracts.
8) Don’t make infinite approvals. Revoke your existing approvals using
revoke.cash.
The Hacker:1) Called the depositToGasZipERC20 function, passing arbitrary transferFrom data and assetId as the attacker’s contract.
2) During the approve call to the hacker’s contract, a new contract was deployed and self-destructed, increasing the Li.Fi contract’s balance by 1 wei.
3) Executed the call from the facet to the token addresses, calling transferFrom from users who had given excessive allowance to the contract, transferring tokens to their address.
4) Finished the transaction with the successful deposit of 1 wei.
Discoverer: NaN,
was hacked.
Harm: 11.6 M $
link |
boost |
twitter