This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
0xStalin - Spender is allowed to transfer more tokens than the owner of the tokens ever wanted to allow the spender to spend #142
Labels
Non-Reward
This issue will not receive a payout
0xStalin
high
Spender is allowed to transfer more tokens than the owner of the tokens ever wanted to allow the spender to spend
Summary
The setApprovalForERC20() uses the approve() of the ERC20 standard and doesn't reset the total allowance to 0 before updating the new value.
A malicious user can take advantage of this and perform a transaction order to end up spending more tokens than the total tokens the owner intended to allow this user to spend, a more detailed example is in the "Vulnerability Detail" Section.
You can refer to this thread about this transaction ordering caused by the approve() of the EIP20 proposal
Vulnerability Detail
Here is a possible attack scenario:
Impact
Code Snippet
https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumEscrow.sol#L80
Tool used
Manual Review
Recommendation
first reduce the spender's allowance to 0 and set the desired value afterwards. Additionally make sure to check the returned value to ensure that the allowance was indeed updated as expected
Duplicate of #8
The text was updated successfully, but these errors were encountered: