This repository has been archived by the owner on Nov 26, 2023. It is now read-only.
pontifex - FootiumEscrow_Don't use approve() to decrease/increase allowance #345
Labels
Non-Reward
This issue will not receive a payout
pontifex
medium
FootiumEscrow_Don't use approve() to decrease/increase allowance
Summary
The
setApprovalForERC20
function setsamount
as an allowance forto
address to spend the escrow contract'serc20Contract
tokens. This function allows the club owner to call theERC20.approve
function. In case when the club owner wants to change the preset allowance it is recommended to callERC20.increaseAllowance
orERC20.decreaseAllowance
instead ofERC20.approve
function.Vulnerability Detail
Suppose the club owner preset allowance
M > 0
foraddress(attacker)
(tx1) and wants to change allowance toN > 0
(tx2). Attacker intercepts tx2, and makes tx1.5 (transferFrom(M)
). Then the attacker sends tx3 (transferFrom(N)
). The attacker spent M + N tokens from the escrow contract.Impact
The club owner takes a risk of tokens loss when changes allowances through the
ERC20.approve
function in one transaction. In other case it is necessary to make two transactions to firstly reset allowances with approve(0).Code Snippet
https://github.com/sherlock-audit/2023-04-footium/blob/11736f3f7f7efa88cb99ee98b04b85a46621347c/footium-eth-shareable/contracts/FootiumEscrow.sol#L75-L81
Tool used
Manual Review
Recommendation
It is recommended adding functions to call
ERC20.increaseAllowance
orERC20.decreaseAllowance
, or using “expected_current_allowance” as an argument.Duplicate of #8
The text was updated successfully, but these errors were encountered: