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
enlistInRollover()/delistInRollover() Lack of reentrant protection provides the possibility to maliciously reentrancy modify other people's rolloverQueue, resulting in the queue may be blocked
Vulnerability Detail
mintRollovers() mints for rollovers
The code is as follows:
function mintRollovers(uint256_epochId, uint256_operations)
externalepochIdExists(_epochId)
epochHasNotStarted(_epochId)
nonReentrant
{
....
while ((index - prevIndex) < (_operations)) {
...
_mintShares(queue[index].receiver, _epochId, assetsToMint); //@audit<------if receiver is contract ,will call receiver.onERC1155BatchReceivedemitDeposit(
msg.sender,
queue[index].receiver,
_epochId,
assetsToMint
);
rolloverQueue[index].assets = assetsToMint;
rolloverQueue[index].epochId = _epochId;
// only pay relayer for successful mints
executions++;
}
}
index++;
}
From the above code, we can see that _mintShares (receiver) will be called, and then modify rolloverQueue [index].assets
If the receiver is a contract, receiver.onERC1155BatchReceived() will be called, thus providing the possibility of malicious reentrancy
And enlistInRollover()delistInRollover() does not have nonReentrant modifier
Malicious users can reentrancy and adjust the rolloverQueue, resulting in the modified rolloverQueue [index].assets may not belong to the original user
Example:
Suppose current rolloverQueue:
rolloverQueue[.] = ...
rolloverQueue[9] = jack asset =100
rolloverQueue[10] = Alice asset =100 <------malicious contract and rolloverAccounting[_epochId] =10
rolloverQueue[11] = bob asset =10
in onERC1155BatchReceived() Alice call delistInRollover(), rolloverQueue become:
rolloverQueue[.] = ...
rolloverQueue[9] = jack asset =100
rolloverQueue[10] = bob asset =100 <------alice remove , set to bob
after onERC1155BatchReceived() , back to mintRollovers() , set rolloverQueue[10].assets = 100
( index=10, No longer belongs to Alice)
This way modifies bob's rolloverQueue [10].assets, Subsequent other calls mintRollovers will fail.
because if bob's shares are not enough assets, when burn() will fail,
Impact
enlistInRollover/delistInRollover Lack of reentrant protection provides the possibility to maliciously modify other people's rolloverQueue, resulting in the queue may be blocked
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
bin2chen
medium
enlistInRollover/delistInRollover lack nonReentrant
Summary
enlistInRollover()/delistInRollover()
Lack of reentrant protection provides the possibility to maliciously reentrancy modify other people'srolloverQueue
, resulting in the queue may be blockedVulnerability Detail
mintRollovers()
mints for rolloversThe code is as follows:
From the above code, we can see that
_mintShares (receiver)
will be called, and then modifyrolloverQueue [index].assets
If the receiver is a contract,
receiver.onERC1155BatchReceived()
will be called, thus providing the possibility of malicious reentrancyAnd
enlistInRollover()
delistInRollover()
does not havenonReentrant
modifierMalicious users can reentrancy and adjust the
rolloverQueue
, resulting in the modifiedrolloverQueue [index].assets
may not belong to the original userExample:
Suppose current rolloverQueue:
rolloverQueue[.] = ...
rolloverQueue[9] = jack asset =100
rolloverQueue[10] = Alice asset =100 <------malicious contract and rolloverAccounting[_epochId] =10
rolloverQueue[11] = bob asset =10
mintRollovers(_operations=1)
Alice.onERC1155BatchReceived()
rolloverQueue
become:rolloverQueue[.] = ...
rolloverQueue[9] = jack asset =100
rolloverQueue[10] = bob asset =100 <------alice remove , set to bob
mintRollovers()
, set rolloverQueue[10].assets = 100( index=10, No longer belongs to Alice)
This way modifies bob's rolloverQueue [10].assets, Subsequent other calls
mintRollovers
will fail.because if bob's shares are not enough assets, when
burn()
will fail,Impact
enlistInRollover/delistInRollover Lack of reentrant protection provides the possibility to maliciously modify other people's
rolloverQueue
, resulting in the queue may be blockedCode Snippet
https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L437-L447
Tool used
Manual Review
Recommendation
enlistInRollover/delistInRollover
addnonReentrant
Duplicate of #468
The text was updated successfully, but these errors were encountered: