Improper Handling of Paused Tokens in `TokenRewards._resetExcluded()` Function
The _resetExcluded function in TokenRewards updates excluded rewards for all reward tokens without checking whether a token is paused in REWARDS_WHITELISTER. This can lead to incorrect reward calculations for stakers when paused tokens are involved.
Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/517
Found by
0xAadi, X77, ZoA, cu5t0mPe0, fibonacci, pkqs90, prosper, queen, silver_eth
Summary
The function _resetExcluded in TokenRewards contract does not properly handle tokens that have been paused in the REWARDS_WHITELISTER. As a result, the excluded rewards for paused tokens may still be updated, which can lead to inconsistent or incorrect reward calculations for stakers.
Vulnerability Detail
In the _resetExcluded function, there is a loop that iterates over all rewards tokens. Inside the loop, the function checks if each reward token has been paused by the REWARDS_WHITELISTER. However, the logic fails to take into account the paused state of tokens. Specifically, the REWARDS_WHITELISTER.paused(_token) check is not used to skip the update of the excluded rewards for tokens that are paused.
Here is the problematic code:
for (uint256 _i; _i < _allRewardsTokens.length; _i++) {
@> address _token = _allRewardsTokens[_i]; // @audit REWARDS_WHITELISTER paused not considered
rewards[_token][_wallet].excluded = _cumulativeRewards(_token, shares[_wallet], true);
}
In this loop, the function attempts to update the excluded rewards for each token, but it does not consider whether the token has been paused. If a token is paused, the excluded reward calculation should be skipped to avoid improper reward distribution.
Impact
- Inaccurate reward distribution: If paused tokens are not properly handled, users could receive incorrect reward amounts, either by having their excluded rewards incorrectly updated or by missing out on rewards for paused tokens while performing
setShares().
Code Snippet
Tool used
Manual Review
Recommendation
- Add the check for paused tokens in the loop to prevent updating rewards for paused tokens.
- Modify the _resetExcluded function to respect the paused state of tokens as follows:
for (uint256 _i; _i < _allRewardsTokens.length; _i++) {
address _token = _allRewardsTokens[_i];
+ if (REWARDS_WHITELISTER.paused(_token)) {
+ continue; // Skip paused tokens
+ }
rewards[_token][_wallet].excluded = _cumulativeRewards(_token, shares[_wallet], true);
}
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 _resetExcluded function does not skip tokens that are paused according to REWARDS_WHITELISTER, so it updates excluded rewards for paused tokens.
Impact
Users could receive incorrect reward amounts, either by having their excluded rewards incorrectly updated or by missing out on rewards for paused tokens.
What the attacker needed
None
The fix
The _resetExcluded function should be modified to check if a token is paused and skip updating its excluded rewards.
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 tracks rewards for people who stake tokens. When someone's stake changes, the contract recalculates their share of rewards. The bug is that it does this even for tokens that have been paused, which can mess up the reward amounts.
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.