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 28, 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
Lack of CEI in mintRollovers can be exploited by users two inflate their shares amount
Summary
Because storage is updated after minting the shares, a malicious attacker can enter delistRollover using onERC1155Received to inflate the shares amount of another user.
Vulnerability Detail
minting of shares in rollover is done before updating storage
_mintShares() mints shares to the depositor, in the form of an ERC1155 token. ERC1155._mint() has a safety hook to ensure the receiver handles this type of tokens:
This can be exploited by a depositor:
if they use a smart contract to deposit, and have the following logic in onERC1155Received: call delistRollover
This will delete them from the queue, and place the last user at their index
File: Earthquake/src/v2/Carousel/Carousel.sol
292: } else {
293: // overwrite the item to be removed with the last item in the queue294: rolloverQueue[index] = rolloverQueue[length -1]; //@audit key part of the attack295: // remove the last item in the queue296: rolloverQueue.pop();
297: // update the index of prev last user ( mapping index is allways array index + 1)298: ownerToRollOverQueueIndex[rolloverQueue[index].receiver] =299: index +300: 1;
301: // remove receiver from index mapping302: delete ownerToRollOverQueueIndex[_owner];
303: }
Which will then be updated at the end of mintRollovers.
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
joestakey
high
Lack of CEI in
mintRollovers
can be exploited by users two inflate their shares amountSummary
Because storage is updated after minting the shares, a malicious attacker can enter
delistRollover
usingonERC1155Received
to inflate the shares amount of another user.Vulnerability Detail
minting of shares in rollover is done before updating storage
_mintShares()
mints shares to the depositor, in the form of an ERC1155 token.ERC1155._mint()
has a safety hook to ensure the receiver handles this type of tokens:This can be exploited by a depositor:
if they use a smart contract to deposit, and have the following logic in
onERC1155Received
: calldelistRollover
This will delete them from the queue, and place the last user at their index
Which will then be updated at the end of
mintRollovers
.Meaning that "new" user at index
index
has inflated their shares for free (ifassetToMint
is greater than what they had previously)Impact
The attacker can inflate shares of another users.
Note that they do not lose any shares themselves, as they can still
withdraw()
in this new epoch.Code Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L437-L445
Tool used
Manual Review
Recommendation
Duplicate of #468
The text was updated successfully, but these errors were encountered: