Contract does not work with fee-on transfer tokens
The TwabRewards contract does not account for fee-on-transfer tokens, so the actual token balance may be less than the amount recorded for rewards. This can cause later users to be unable to claim their rewards.
Originally disclosed on Code4rena
Submitted by pmerkleplant, also found by GiveMeTestEther, WatchPug, and defsec
Impact
There exist ERC20 tokens that charge a fee for every transfer.
This kind of token does not work correctly with the TwabRewards contract as the rewards calculation for an user is based on promotion.tokensPerEpoch (see line 320).
However, the actual amount of tokens the contract holds could be less than promotion.tokensPerEpoch * promotion.numberOfEpochs leading to not claimable rewards for users claiming later than others.
Recommended Mitigation Steps
To disable fee-on transfer tokens for the contract, add the following code in createPromotion around line 11:
uint256 oldBalance = _token.balanceOf(address(this));
_token.safeTransferFrom(msg.sender, address(this), _tokensPerEpoch * _numberOfEpochs);
uint256 newBalance = _token.balanceOf(address(this));
require(oldBalance + _tokenPerEpoch * _numberOfEpochs == newBalance);
PierrickGT (PoolTogether) confirmed
This issue results in a direct loss of funds and can happen easily.
3 — High (H): vulns have a risk of 3 and are considered “High” severity when assets can be stolen/lost/compromised directly (or indirectly if there is a valid attack path that does not have hand-wavy hypotheticals).
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 verify that the actual token balance increase matches the expected amount when creating a promotion, so fee-on-transfer tokens cause a shortfall.
Impact
This could lead to a direct loss of funds for users who claim later, as the contract may not hold enough tokens to pay all rewards.
What the attacker needed
Fee-on-transfer token used; promotion created with such token
The fix
The contract should check that the actual balance increase equals the expected amount when creating a promotion, rejecting fee-on-transfer tokens.
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 contract assumes it receives the full amount and calculates rewards based on that, but if it receives less, there may not be enough tokens to pay everyone. This means some users might not be able to claim 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.