Skip to content
Business logic Audit finding Intermediate

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.

Dravee Follow

Originally disclosed on Code4rena

Submitted by Dravee, also found by pauliax

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/Booster.sol#L356

https://github.com/code-423n4/2022-05-vetoken/blob/2d7cd1f6780a9bcc8387dea8fecfbd758462c152/contracts/VE3DRewardPool.sol#L337

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 feeOnTransfer token 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 donate function, 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.


The original report as published on Code4rena, by Dravee. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by Dravee

View all

9 more disclosed reports, best first.

More from veToken Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.