Closed c4-bot-6 closed 4 months ago
Reopening for sponsor review
Because of the long cadence by which the price will update, we are not concerned about variations in schnibble accrual based on price adjustments.
The submission details that immediate changes to a token's configuration, such as the USD price reported, should not be consumed immediately which contradicts the intended purpose of the data point. I consider the submission invalid, as all changes should be immediately reflected as the Sponsor confirms.
alex-ppg marked the issue as unsatisfactory: Invalid
I noticed a comment from a sponsor in https://github.com/code-423n4/2024-05-munchables-findings/issues/100 that losing staking rewards for deactivated token is the intended behavior. I believe this is unfair to the user since schnibbles rewards are accumulated over time, the staker should be able to claim rewards that were accumulated before the token was deactivated.
Let's say Alice locked tokens for 10 days, every day she receives 100 schnibbles, on the 5-th day the token she locked was deactivated. On the 10-th day when she unlocks she should be able to claim 5X100 = 500 schnibbles instead of 0.
Hey @k4zanmalay, thanks for your feedback. As noted in my reply within #100 here, we can observe that a token being disabled will result in price measurements no longer reported for it and thus a security vulnerability arising from permitting claims while the token is deactivated.
Responsible deactivation procedures by the Munchables team will prevent the scenario you outlined (i.e. we plan to remove XYZ token from being supported in 3 days, permitting adequate time for users to claim rewards), and a token's de-activation should be immediate in case f.e. of a market crash of the token providing unreliable USD measurements for the oracles to reflect.
I appreciate the due diligence and will retain my original ruling on this submission.
Lines of code
https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/AccountManager.sol#L372-L373 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/BonusManager.sol#L128 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L461-L487 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L115-L127 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L506-L525
Vulnerability details
Impact
Changes in
configuredTokens
parameters (usdPrice
,active
) take immediate effect on accumulated user rewards.Proof of Concept
The protocol includes a reward program where users can harvest schnibbles based on the locked value and duration.
The
lockManager.getLockedWeightedValue
function is used to calculate the weighted value of the locked tokens. It iterates through the configured tokens and considers only the active tokens in the calculation.Two things to notice here:
usdPrice
is usedRewards are collected every time user locks or unlocks tokens. However, the issue arises when admin or price feeds change the parameters in the
configuredTokens
. Since the protocol uses the current parameters to calculate the Total Value Locked (TVL), it does not store the TVL calculated prior to the parameter change. This can lead to inconsistencies in the rewards received by users.Two scenarios highlight the impact:
Coded POC for
SpeedRun.t.sol
Tools Used
Foundry
Recommended Mitigation Steps
To address this issue, changes should be made to the protocol's architecture to accumulate user rewards before any token parameter changes are made. Storing and updating reward rate separately from user's locked amounts would allow for more flexibility and accuracy during token price and status updates.
Assessed type
Other