RewardThrottle.setTimekeeper: If changing the timekeeper causes the epoch to change, it will mess up the system
The setTimekeeper function lets a privileged role swap the timekeeper contract while the reward throttle is active, and if the new timekeeper reports a different epoch number the reward accounting breaks. An attacker with that role could raise the epoch and then claim a large batch of rewards, or lower it and block rewards for the current epoch.
Submitted by cccz
RewardThrottle.setTimekeeper allows POOLUPDATERROLE to update the timekeeper when RewardThrottle is active:
function setTimekeeper(address _timekeeper)
external
onlyRoleMalt(POOL_UPDATER_ROLE, "Must have pool updater privs")
{
require(_timekeeper != address(0), "Not address 0");
timekeeper = ITimekeeper(_timekeeper);
}
if newTimekeeper.epoch changes, it will cause the following:
- The newTimekeeper.epoch increases, and the user can immediately call checkRewardUnderflow to fill the gap epoch, thereby distributing a large amount of rewards.
- The newTimekeeper.epoch decreases, and the contract will use the state of the previous epoch. Since the state.rewarded has reached the upper limit, this will cause the current epoch to be unable to receive rewards.
Proof of Concept
Recommended Mitigation Steps
Consider only allowing setTimekeeper to be called when RewardThrottle is not active.
0xScotch (Malt) confirmed and commented:
This is a good find and I think we will just remove the
setTimekeepermethods. There is no reason for the timekeeper to ever be updated at this point given all it does it track epochs.Historically this method was there because what we now call the timekeeper was called the
MaltDAOand was earmarked to be used for many other things other than timekeeping. Eventually we realised the timekeeping should be separated into its own thing. These methods were clearly forgotten about and not removed.
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 setTimekeeper function does not check that the new timekeeper reports the same epoch as the old one, and does not reset the per-epoch reward state.
Impact
A holder of the pool updater role could cause a large amount of rewards to be distributed early, or make the current epoch unable to receive rewards.
What the attacker needed
POOL_UPDATER_ROLE; RewardThrottle is active
The fix
The project said it would remove the setTimekeeper methods entirely, since the timekeeper should never need updating.
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 time in numbered periods called epochs and pays out rewards per epoch. A special admin function can swap the component that reports the current epoch, but the contract does not reset its reward bookkeeping when that happens. If the new component reports a different epoch number, the reward maths is wrong, so someone with admin rights could either collect too many rewards or stop rewards being paid.
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.