Platform: Code4rena
Start Date: 08/11/2022
Pot Size: $60,500 USDC
Total HM: 6
Participants: 72
Period: 5 days
Judge: Picodes
Total Solo HM: 2
Id: 178
League: ETH
Rank: 45/72
Findings: 1
Award: $77.22
🌟 Selected for report: 0
🚀 Solo Findings: 0
77.2215 USDC - $77.22
When using any ERC20 token to purchase NFT, after the purchase is successful, the 108th line of code in the contract LooksRareAggregator determines whether there are any remaining unused ERC20 tokens. If there is any remaining, it will be returned to the address specified by the originator. The code is as follows:
if (tokenTransfersLength > 0) _returnERC20TokensIfAny(tokenTransfers, originator);
There is nothing wrong with the logic at this moment, the real problem is that in the _returnERC20TokensIfAny function, a fatal error was made when performing the refund operation:
Hackers will use the above loopholes to transfer the entire balance of an ERC20 token in the contract
Error code location: https://github.com/code-423n4/2022-11-looksrare/blob/e3b2c053f722b0ca2dce3a3eb06f64859b8b7a6f/contracts/LooksRareAggregator.sol#L244-L245
Attack steps:
In the _returnERC20TokensIfAny function, the amount of ERC20 tokens to be returned should be strictly judged, and the current balance of each user's ERC20 tokens needs to be stored for logical judgment (you can use a mapping structure or build a Merkle tree to store )
#0 - c4-judge
2022-11-19T10:20:36Z
Picodes marked the issue as duplicate of #277
#1 - c4-judge
2022-12-16T13:59:49Z
Picodes changed the severity to 2 (Med Risk)
#2 - c4-judge
2022-12-16T13:59:50Z
Picodes marked the issue as satisfactory