Open code423n4 opened 2 years ago
The warden has identified a fallacy in how add
s logic work.
Ultimately rewards in this contract have to be linearly vested over time, adding a new pool would change the rate at which vesting in all pools will go.
For that reason, it is necessary to accrue the rewards that each pool generated up to that point, before changing the slope at which rewards will be distributed.
In this case add should massUpdateFirst
Because this vulnerability ultimately breaks the accounting of the protocol, I believe High Severity to be appropriate
Lines of code
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/MasterChef.sol#L86
Vulnerability details
Impact
When adding new token pool for staking in MasterChef contract
All other, already added, pools should be updated but currently they are not. Instead, only totalPoints is updated. Therefore, old (and not updated) pools will lose it's share during the next update. Therefore, user rewards are not computed correctly (will be always smaller).
Proof of Concept
Scenario 1:
Scenario 2:
Tools Used
Manual review
Recommended Mitigation Steps
Update all existing pools before adding new pool. Use the massUdpate() function which is already present ... but unused.