Skip to content
Business logic Audit finding Beginner

getRewardsAmount doesn’t check epochs haven’t been claimed

The getRewardsAmount function does not check whether epochs have already been claimed, so it returns a higher reward amount than the user is actually owed. Users may be confused and distrust the contract when they receive fewer tokens than displayed.

harleythedog Follow

Originally disclosed on Code4rena

Submitted by harleythedog

Impact

In ITwabRewards.sol, it is claimed that getRewardsAmount should account for epochs that have already been claimed, and not include these epochs in the total amount (indeed, there is a line that says @dev Will be 0 if user has already claimed rewards for the epoch.)

However, no such check is done in the implementation of getRewardsAmount. This means that users will be shown rewardAmounts that are higher than they should be, and users will be confused when they are transferred fewer tokens than they are told they will. This would cause confusion, and people may begin to mistrust the contract since they think they are being transferred fewer tokens than they are owed.

Proof of Concept

See the implementation of getRewardsAmount here: https://github.com/pooltogether/v4-periphery/blob/b520faea26bcf60371012f6cb246aa149abd3c7d/contracts/TwabRewards.sol#L209

Notice that there are no checks that the epochs have not already been claimed. Compare this to claimRewards which does check for epochs that have already been claimed with the following require statement:

require(!_isClaimedEpoch(_userClaimedEpochs, _epochId), "TwabRewards/rewards-already-claimed");

A similar check should be added getRewardsAmount so that previously claimed epochs are not included in the sum.

Recommended Mitigation Steps

Add a similar check for previously claimed epochs as described above.

PierrickGT (PoolTogether) confirmed

The original report as published on Code4rena, by harleythedog. 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 getRewardsAmount function lacks a check to exclude already-claimed epochs from the reward calculation, unlike the claimRewards function which includes such a check.

Impact

Users could be misled by inflated reward amounts, leading to confusion and potential loss of trust in the contract.

What the attacker needed

None

The fix

Add a check in getRewardsAmount to exclude epochs that have already been claimed, similar to the check in claimRewards.

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.

A smart contract function that calculates rewards fails to exclude epochs that the user has already claimed. This means the displayed reward is too high, and when the user claims, they get less than expected, which can erode trust.

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 harleythedog

View all

14 more disclosed reports, best first.

More from PoolTogether

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.