Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

VAD37 - ERC1155 _doSafeTransferAcceptanceCheck() reentrancy callback exploits #406

Closed
sherlock-admin opened this issue Mar 27, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Mar 27, 2023

VAD37

medium

ERC1155 _doSafeTransferAcceptanceCheck() reentrancy callback exploits

Summary

Carousel.sol have 2 reentrancy callback that need to patch.

  • _emissionBalances update after internal _safeTransfer callback from ERC1155. There is no current exploit to manipulate emission balance, but it is still a potential risk.
  • _mintShares() also have callback from _mint(). Allow only one meaningful manipulation of mintRollovers(), with variable rolloverQueue assets and epochId. Both of these value only used for viewing after the function called.

So there is no risk of user losing fund or DOS yet, but it is still a potential risk.

Vulnerability Detail

  • Openzeppelin ERC1155 include callback for every safeTransfer call. This include _mint() as well.

  • This allow Carousel.sol have reentrancy exploit here and here. Both allow callback before changing emission balance.

  • callback inside safeTransferFrom() allow using old emissionBalances for withdraw. But balance calculation revert on underflow check anyway. So there is no way to exploit this.

  • Because enlistInRollover() and delistInRollover() does not have reentrancy protection. This allow exploiter to exploit rolloverQueue[] value.

  • Which mintRollovers() function happen to use _mintShares right before updating rolloverQueue.

  • Exploiter can update their own rolloverQueue value they want as long it is on top of the queue. Just call delist and then enlist with value they want. And it will be override later during mintRollovers() loop.

  • The rolloverQueue at this point does not use for anything except viewing. So no risk of fund loss.

Impact

Medium. No risk lost but can manipulate contract view function to show wrong value.

Code Snippet

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L201

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L536

https://github.com/sherlock-audit/2023-03-Y2K/blob/main/Earthquake/src/v2/Carousel/Carousel.sol#L437-L447

Tool used

Manual Review

Recommendation

  • Move emission code before callback.
  • Add reentrancy for enlistInRollover and delistInRollover function.

Duplicate of #468

@github-actions github-actions bot closed this as completed Apr 3, 2023
@github-actions github-actions bot added High A valid High severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Apr 3, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant