You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 27, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
mintRollovers() use incorrect mint amount which will cause part of funds being locked in a vault forever.
Vulnerability Detail
The rollover mint should be equal to withdraw() plus deposit(). The assets in the rollover queue represent how much share of an epoch that an user wants to rollover. The rollover gets minted only if user won the epoch he is rolling over. That means a user can withdraw more underlying token from the epoch then he deposited. So the rollover should be minted using the amount of previewWithdraw(queue[index].epochId, queue[index].assets) rather than queue[index].assets. Using queue[index].assets indicate that the extra bonus is not counted and will be left in vault forever (since each epoch has it's own finalTVL/claimTVL which is isolated from other epochs).
Impact
User will not be able to rollover with correct amount (entitledShares).
Part of extra underlying token of an epoch will get locked in a vault forever.
Code Snippet
function mintRollovers(uint256_epochId, uint256_operations)
{
// ...// ...while (...) {
// only roll over if last epoch is resolvedif (epochResolved[queue[index].epochId]) {
uint256 entitledShares =previewWithdraw(
queue[index].epochId,
queue[index].assets
);
// mint only if user won epoch he is rolling overif (entitledShares > queue[index].assets) {
_burn(...);
_burnEmissions(...);
emissionsToken.safeTransfer(...);
emitWithdraw(...);
// @audit should be entitledShares - relayerFeeuint256 assetsToMint = queue[index].assets - relayerFee;
_mintShares(queue[index].receiver, _epochId, assetsToMint);
emitDeposit(...);
rolloverQueue[index].assets = assetsToMint;
rolloverQueue[index].epochId = _epochId;
// only pay relayer for successful mints
executions++;
}
}
index++;
}
// ...// ...
}
Tool used
Manual Review
Recommendation
Calculate assetsToMint in mintRollovers() using entitledShares instead.
Record rollover queue index only when an item is pushed into queue.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
charlesjhongc
high
Incorrect mint amount is used in mintRollovers()
Summary
mintRollovers()
use incorrect mint amount which will cause part of funds being locked in a vault forever.Vulnerability Detail
The rollover mint should be equal to
withdraw()
plusdeposit()
. Theassets
in the rollover queue represent how much share of an epoch that an user wants to rollover. The rollover gets minted only if user won the epoch he is rolling over. That means a user can withdraw more underlying token from the epoch then he deposited. So the rollover should be minted using the amount ofpreviewWithdraw(queue[index].epochId, queue[index].assets)
rather thanqueue[index].assets
. Usingqueue[index].assets
indicate that the extra bonus is not counted and will be left in vault forever (since each epoch has it's own finalTVL/claimTVL which is isolated from other epochs).Impact
Code Snippet
Tool used
Manual Review
Recommendation
Calculate
assetsToMint
inmintRollovers()
usingentitledShares
instead.Record rollover queue index only when an item is pushed into queue.
Duplicate of #163
The text was updated successfully, but these errors were encountered: