Missing approve(0)
The smart contract calls the ERC20 approve function without first resetting the allowance to zero. For tokens like USDT that require this, transactions will revert, affecting protocol availability.
Originally disclosed on Code4rena
Submitted by sirhashalot, also found by Jujic, and sirhashalot
Impact
There are 3 instances where the IERC20.approve() function is called only once without setting the allowance to zero. Some tokens, like USDT, require first reducing the address’ allowance to zero by calling approve(_spender, 0). Transactions will revert when using an unsupported token like USDT (see the approve() function requirement at line 199).
Proof of Concept
Note: the usage of approve() in yield/CompoundYield.sol (lines 211-212), in yield/YearnYield.sol (lines 211-212), and in yield/AaveYield.sol (lines 297-298) do not need modification since it they already use the recommended approach. Additionally the usage of approve() in yield/AaveYield.sol:307 likely does not need modification since that approve function only handles ETH.
Recommended Mitigation Steps
Use approve(_spender, 0) to set the allowance to zero immediately before each of the existing approve() calls.
ritik99 (Sublime) confirmed 0xean (judge) commented:
moving to medium risk as the availability of the protocol is affected.
2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The contract calls approve() without first setting the allowance to zero, which is required by some ERC20 tokens like USDT.
Impact
Transactions will revert when using an unsupported token like USDT, affecting the availability of the protocol.
What the attacker needed
Using a token like USDT that requires zeroing allowance…
The fix
The fix is to call approve(_spender, 0) to set the allowance to zero immediately before each existing approve() call.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some digital tokens have a safety rule: before you can change how much someone is allowed to spend on your behalf, you must first set that permission to zero. This contract skips that step, so with those tokens the transaction fails and the protocol cannot operate.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.