AbstractRewardMine.sol#setRewardToken is dangerous
The setRewardToken function allows an admin to change the reward token, which resets totalDeclaredReward to zero but leaves accumulated padding variables unchanged, causing accounting inconsistencies. An attacker with admin privileges could exploit this to disrupt reward distribution.
Submitted by 0x0x0x, also found by harleythedog and hyh
In case the reward token is changed, totalDeclaredReward will be changed and likely equal to 0. Since _userStakePadding and _globalStakePadding are accumulated, changing the reward token will not reset those values. Thus, it will create problems.
Recommendation
I think it would be the best to remove this function.
If you want to keep it, then it must have an event and it should be used by a timelock contract. Furthermore, it has to be used carefully and the new token should be distributed such that padding variables still make sense.
Alex the Entreprenerd (judge) commented:
Agree with highlighting the Admin Privilege, however because this is contingent on a malicious Admin, I’ll downgrade the finding to Medium Severity.
Mitigation could be done by ensuring old rewards are sent out, still claimable, or by making the
rewardTokenimmutable
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 setRewardToken function does not reset the accumulated padding variables when changing the reward token, leading to inconsistent reward accounting.
Impact
If an admin maliciously changes the reward token, it could disrupt reward distribution and cause accounting errors, but this requires admin privileges.
What the attacker needed
Admin privileges
The fix
The function should be removed, or if kept, it should have an event, be used by a timelock, and ensure old rewards are sent out or the reward token is made immutable.
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.
This is a smart contract issue where an admin function can change the token used for rewards. When that happens, some internal counters that track rewards are not reset, which can mess up how rewards are calculated for users. Only someone with admin rights could do this, so it's not something a regular user can trigger.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.