AutoleverageBase: Must approve 0 first
The contract's internal approve function sets a token allowance directly to the maximum value without first resetting it to zero. For tokens like USDT that require a zero allowance before changing a non-zero one, the approval call would fail, potentially blocking the contract's operations.
Submitted by cccz
Some tokens (like USDT) do not work when changing the allowance from an existing non-zero allowance value.They must first be approved by zero and then the actual allowance must be approved.
Proof of Concept
AutoleverageBase.sol#L147-L147
AutoleverageBase.sol#L178-L179
Recommended Mitigation Steps
function approve(address token, address spender) internal {
+ IERC20(token).approve(spender, 0);
IERC20(token).approve(spender, type(uint256).max);
}
0xtao (Alchemix) confirmed and commented:
This implementation will not work for tokens like USDT where the approval is not set to
0initially
0xleastwood (judge) commented:
It seems like
approve()will fail to execute on non-standard tokens which require the approval amount to start from zero. This is valid and should be updated to handle such tokens.
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's approve helper does not reset the allowance to zero before setting it to the maximum, which is required by tokens like USDT.
Impact
The approval call could fail for tokens that require a zero starting allowance, potentially preventing the contract from functioning with those tokens.
What the attacker needed
Contract uses tokens like USDT; existing non-zero allowance
The fix
The approve function should first set the allowance to zero before setting it to the maximum value.
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, such as USDT, have a rule that you cannot change an existing spending permission directly to a new amount; you must first set it to zero. The contract tried to set the permission straight to the maximum, which would be rejected by those tokens. This means certain actions in the contract could fail.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.