Skip to content
Business logic Audit finding Intermediate

Users may lose rewards to other users if rewards are given as fee-on-transfer tokens

The reward distributor contract credits the full amount of a fee-on-transfer token as rewards, but the contract receives less due to the fee. As a result, early claimants can drain the reward pool, leaving later claimants unable to claim their rewards.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI, also found by Aits, BowTiedWardens, and MaratCerby

If rewards are given in fee-on-transfer tokens, users may get no rewards, breaking functionality.

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. (emphasis mine)

The underlying BAL protocol support fee-on-transfer tokens, so should Aura.

Proof of Concept

File: contracts/ExtraRewardsDistributor.sol   #1

87       function _addReward(
88           address _token,
89           uint256 _amount,
90           uint256 _epoch
91       ) internal nonReentrant {
92           // Pull before reward accrual
93           IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
94
95           //convert to reward per token
96           uint256 supply = auraLocker.totalSupplyAtEpoch(_epoch);
97           uint256 rPerT = (_amount * 1e20) / supply;
98           rewardData[_token][_epoch] += rPerT;

ExtraRewardsDistributor.sol#L87-L98

If a fee is charged the total amount available to be transferred later will be less than the _amount passed in.

Consider the following scenario: User A holds 98% of the total supply of vlBAL (the system is being bootstrapped) User B holds 1% User C holds 1%

  1. _token is given out as a reward. It is a fee-on-transfer token with a fee of 2%
  2. Nobody claims the reward until it’s fully available (to save gas on transaction fees)
  3. User A is the first to claim his/her reward and gets 98% of the reward, leaving 0 wei of the token left (since the other 2% was already taken as a fee by the token itself)
  4. User B tries to claim and the call reverts since there’s no balance left
  5. User C tries to claim and the call reverts for them too
  6. Users B and C are angry and stop using Aura
File: contracts/ExtraRewardsDistributor.sol   #2

87       function _addReward(
88           address _token,
89           uint256 _amount,
90           uint256 _epoch
91       ) internal nonReentrant {
92           // Pull before reward accrual
93           IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
94
95           //convert to reward per token
96           uint256 supply = auraLocker.totalSupplyAtEpoch(_epoch);
97           uint256 rPerT = (_amount * 1e20) / supply;
98           rewardData[_token][_epoch] += rPerT;

ExtraRewardsDistributor.sol#L87-L98

Recommended Mitigation Steps

Measure the contract balance before and after the transfer, and use the difference as the amount, rather than the stated amount.

0xMaharishi (Aura Finance) disputed and commented:

This contract is optional to use - it is not supposed to support fee bearing tokens.

LSDan (judge) commented:

See my comment on issue #18: “There are several cases in the code reported where the token in question comes from an external (non-admin, non-protocol) source. One of these is the addReward functionality (ExtraRewards). This would indeed cause an accounting issue and allow a potential malicious actor to send rewards which cause distribution to fail due to lack of funds. Just because you don’t plan to use fee on transfer tokens, does not mean they will not be used. This should be protected against in the scenarios where it could cause an issue.

That said, this clearly requires external factors and relies on hypothetical attack motivation that seems unlikely to me. I think it should be included as a medium risk.”


The original report as published on Code4rena, by IllIllI. 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

Impact

Users may be unable to claim their rewards, and the protocol's reward distribution functionality could be disrupted.

What the attacker needed

Rewards are given in a fee-on-transfer token; Users delay claiming rewards

The fix

The contract should measure its balance before and after the transfer and use the difference as the actual amount received.

How it was found

  1. A fee-on-transfer token is added as a reward with a 2% fee.
  2. Rewards are not claimed until the full reward period is over.
  3. User A, holding 98% of the total supply, claims first and receives 98% of the reward, leaving zero tokens.
  4. User B attempts to claim but the transaction reverts due to insufficient balance.
  5. User C also attempts to claim and the transaction reverts.

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. This contract assumes the full amount arrives and calculates rewards based on that full amount. When users claim, the contract runs out of tokens early, so some users cannot get their rewards.

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 IllIllI

View all

119 more disclosed reports, best first.

More from Aura 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.