This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
wzrdk3lly - Approve function vulnerable to frontrunning attack #218
Labels
Non-Reward
This issue will not receive a payout
wzrdk3lly
medium
Approve function vulnerable to frontrunning attack
Summary
Approved escrow tokens are subject to front-run attack because the approve function doesn't account for an allowance already spent by the spender. In the event where the spender has spent the amount, the approve function will approve a new amount.
Vulnerability Detail
The spender can front-run new approvals and spend their current allowance + the new allowance granted by the token owner.
Let's take the example where Alice approves Bob the ability to spend an allowance of N tokens.
Impact
A user can steal another user's token by frontrunning approvals.
Code Snippet
https://github.com/sherlock-audit/2023-04-footium/blob/main/footium-eth-shareable/contracts/FootiumEscrow.sol#L75-L81
Tool used
Manual Review
Recommendation
The recommendation is to use OpenZeppelin's
increaseAllowance
anddecreaseAllowance
. See details here:https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#ERC20-increaseAllowance-address-uint256-
https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#ERC20-decreaseAllowance-address-uint256-
Duplicate of #8
The text was updated successfully, but these errors were encountered: