Consistently check account balance before and after transfers for Fee-On-Transfer discrepancies
The contracts assume that the amount of tokens received equals the amount specified in a transfer, but if a fee-on-transfer token is used, the actual received amount is less. This could break reward claiming or brick the system if such a token is added as a reward.
Submitted by Dravee, also found by pauliax
Vulnerability Details
As arbitrary ERC20 tokens can be passed, the amount here should be calculated every time to take into consideration a possible fee-on-transfer or deflation.
Also, it’s a good practice for the future of the solution.
Affected code:
- File: Booster.sol
345: function deposit(
346: uint256 _pid,
347: uint256 _amount,
348: bool _stake
349: ) public returns (bool) {
...
356: IERC20(lptoken).safeTransferFrom(msg.sender, staker, _amount); //@audit medium: not compatible with Fee On Transfer Tokens
...
372: ITokenMinter(token).mint(address(this), _amount);
...
374: IERC20(token).safeApprove(rewardContract, _amount);
375: IRewards(rewardContract).stakeFor(msg.sender, _amount);
...
378: ITokenMinter(token).mint(msg.sender, _amount);
...
381: emit Deposited(msg.sender, _pid, _amount);
...
- File: VE3DRewardPool.sol
336: function donate(address _rewardToken, uint256 _amount) external {
337: IERC20(_rewardToken).safeTransferFrom(msg.sender, address(this), _amount); //@audit medium: not compatible with Fee On Transfer Tokens
338: rewardTokenInfo[_rewardToken].queuedRewards += _amount;
339: }
Recommended Mitigation Steps
Use the balance before and after the transfer to calculate the received amount instead of assuming that it would be equal to the amount passed as a parameter.
solvetony (veToken Finance) confirmed and commented:
Confirmed in donate function, we are have to add a check for the reward token list However, I don’t think we do anything with lp token as we already use the exact lp token address
Alex the Entreprenerd (judge) commented:
While I think the scenario is highly unlikely, the warden has shown how, in the case of a
feeOnTransfertoken being added as reward, the claiming of reward could be potentially broken.Remediation can be as simple as checking for the actual transferred amount in the
donatefunction, or simply not allowing the tokens.However, because the warden has shown how the system could be bricked due to a configuration issue, I believe Medium Severity to be appropriate.
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
Likely the code uses the transfer amount parameter directly instead of checking the actual balance change, so it does not account for fee-on-transfer tokens.
Impact
If a fee-on-transfer token is added as a reward, claiming rewards could be broken, potentially bricking the system due to a configuration issue.
What the attacker needed
Fee-on-transfer token added as reward
The fix
The donate function should check the actual transferred amount or disallow fee-on-transfer tokens; the report does not state that a fix was applied.
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 take a small fee when transferred, so the receiver gets less than the sender sent. The code here assumes the full amount arrives, which can cause accounting errors. If such a token is used, rewards might not be claimable or the system could get stuck.
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.