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() give wrong amount of share/assets to user
Summary
The mintRollovers() do the following steps in a loop:
Take user rollover queue
withdraw that amount from old epoch. Skip if that withdraw is too small to pay fee or the withdraw rewards amount is lost due to depeg event.
deposit that amount into latest epoch
burn previous epoch token share
The deposit/ mint new share for user use wrong variable.
It take the variable set by user queue input while it should take the variable from the withdraw that included premium payout.
Vulnerability Detail
You would expect the mintRollovers() have same logic in withdraw() and then deposit()
File: Earthquake\src\v2\Carousel\Carousel.sol395: if(epochResolved[queue[index].epochId]){396: uint256entitledShares=previewWithdraw(397: queue[index].epochId,398: queue[index].assets399: );400: // mint only if user won epoch he is rolling over401: if(entitledShares>queue[index].assets){402: // skip the rollover for the user if the assets cannot cover the relayer fee instead of revert.403: if(queue[index].assets<relayerFee){404: index++;405: continue;406: }407: // @note we know shares were locked up to this point408: _burn(409: queue[index].receiver,410: queue[index].epochId,411: queue[index].assets412: );413: // transfer emission tokens out of contract otherwise user could not access them as vault shares are burned414: _burnEmissions(415: queue[index].receiver,416: queue[index].epochId,417: queue[index].assets418: );419: // @note emission token is a known token which has no before transfer hooks which makes transfer safer420: emissionsToken.safeTransfer(421: queue[index].receiver,422: previewEmissionsWithdraw(423: queue[index].epochId,424: queue[index].assets425: )426: );427:
428: emitWithdraw(429: msg.sender,430: queue[index].receiver,431: queue[index].receiver,432: _epochId,433: queue[index].assets,434: entitledShares435: );
Notice the event Withdraw use entitledShares value as WETH received amount.
The next part simplifed from deposit() suddenly use value input by user queue[index].assets instead of withdrawal value entitledShares (aka WETH received amount)
File: Earthquake\src\v2\Carousel\Carousel.sol436: uint256assetsToMint=queue[index].assets-relayerFee;//@audit H entitledShares not assets437: _mintShares(queue[index].receiver,_epochId,assetsToMint);438: emitDeposit(439: msg.sender,440: queue[index].receiver,441: _epochId,442: assetsToMint443: );
Impact
The user share already burned but does not move entire total share rewards of premium to new epoch.
Locked user funds in old epoch with no way to recover.
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
VAD37
high
mintRollovers()
give wrong amount of share/assets to userSummary
The
mintRollovers()
do the following steps in a loop:The deposit/ mint new share for user use wrong variable.
It take the variable set by user queue input while it should take the variable from the withdraw that included premium payout.
Vulnerability Detail
You would expect the
mintRollovers()
have same logic inwithdraw()
and thendeposit()
The value entitledShares for withdraw is correct same as withdraw() function
Notice the event Withdraw use
entitledShares
value as WETH received amount.The next part simplifed from
deposit()
suddenly use value input by userqueue[index].assets
instead of withdrawal valueentitledShares
(aka WETH received amount)Impact
The user share already burned but does not move entire total share rewards of premium to new epoch.
Locked user funds in old epoch with no way to recover.
Also forgot to take treasury fee during rollover.
Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L436
Tool used
Manual Review
Recommendation
change
queue[index].assets
toentitledShares
.Duplicate of #163
The text was updated successfully, but these errors were encountered: