Collect modules can fail on zero amount transfers if treasury fee is set to zero
The collect modules unconditionally attempt to transfer the treasury fee, even when it is zero. If the fee currency is an ERC20 token that reverts on zero-value transfers, all collect operations fail, making the collect functionality unavailable.
Submitted by hyh
Treasury fee can be zero, while collect modules do attempt to send it in such a case anyway as there is no check in place. Some ERC20 tokens do not allow zero value transfers, reverting such attempts.
This way, a combination of zero treasury fee and such a token set as a collect fee currency will revert any collect operations, rendering collect functionality unavailable
Proof of Concept
Treasury fee can be set to zero:
Treasury fee transfer attempts are now done uncoditionally in all the collect modules.
Namely, FeeCollectModule, LimitedFeeCollectModule, TimedFeeCollectModule and LimitedTimedFeeCollectModule do not check the treasury fee to be send, treasuryAmount, before transferring:
LimitedFeeCollectModule.sol#L194
TimedFeeCollectModule.sol#L190
LimitedTimedFeeCollectModule.sol#L205
The same happens in the FeeFollowModule:
References
Some ERC20 tokens revert on zero value transfers:
https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers
Recommended Mitigation Steps
Consider checking the treasury fee amount and do transfer only when it is positive.
Now:
IERC20(currency).safeTransferFrom(follower, treasury, treasuryAmount);
To be:
if (treasuryAmount > 0)
IERC20(currency).safeTransferFrom(follower, treasury, treasuryAmount);
donosonaumczuk (Aave Lens) confirmed and commented:
This one makes sense to me. cc: @Zer0dot
Zer0dot (Aave Lens) commented:
I think it makes sense, will add!
Zer0dot (Aave Lens) resolved and commented:
Addressed in aave/lens-protocol#77.
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 does not check whether the treasury fee amount is greater than zero before attempting the transfer.
Impact
Collect operations could be completely blocked for any collect module using a token that reverts on zero-value transfers, if the treasury fee is set to zero.
What the attacker needed
Treasury fee set to zero; fee currency is a token that reverts on zero transfers
The fix
The code was fixed by only performing the treasury fee transfer when the amount is positive.
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 tokens refuse to process a transfer of zero tokens. The smart contract always tries to send the treasury fee, even when that fee is zero. If the token rejects zero transfers, the whole collect action fails and users cannot collect.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.