Malicious user can bypass execution of `CollectionShutdown` function
A manager can call preventShutdown to block a collection shutdown, but the check only looks at current vote count. An attacker can start a shutdown and then reclaim their vote to reset the count to zero, so the manager's prevention is bypassed and the shutdown can proceed.
Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/113
Found by
BugPull
Summary
Malicious user bypasses CollectionShutdown::preventShutdown by calling CollectionShutdown::start then CollectionShutdown::reclaimVote making the use of checks in preventShutdown useless.
Root Cause
In preventShutdown function there a check to make sure there isn't currently a shutdown in progress.
CollectionShutdown.sol#L420-L421
File: CollectionShutdown.sol
415: function preventShutdown(address _collection, bool _prevent) public {
416: // Make sure our user is a locker manager
417: if (!locker.lockerManager().isManager(msg.sender)) revert ILocker.CallerIsNotManager();
418:
419: // Make sure that there isn't currently a shutdown in progress
420:@> if (_collectionParams[_collection].shutdownVotes != 0) revert ShutdownProcessAlreadyStarted();
421:
422: // Update the shutdown to be prevented
423: shutdownPrevented[_collection] = _prevent;
424: emit CollectionShutdownPrevention(_collection, _prevent);
425: }
This check doesn't confirm that the shutdown is in progress or not user can call CollectionShutdown::start to start a shutdown.
Then CollectionShutdown::reclaimVote to set shutdownVotes back to 0.
Calling start function indeed increas the votes by calling _vote
CollectionShutdown.sol#L156-L157
File: CollectionShutdown.sol
135: function start(address _collection) public whenNotPaused {
//code
155: // Cast our vote from the user
156:@> _collectionParams[_collection] = _vote(_collection, params);
In _votes the count of shotdowVotes increase which is normal
CollectionShutdown.sol#L200-L201
File: CollectionShutdown.sol
191: function _vote(address _collection, CollectionShutdownParams memory params) internal returns (CollectionShutdownParams memory) {
//code
199: // Register the amount of votes sent as a whole, and store them against the user
200:@> params.shutdownVotes += uint96(userVotes);
There is no prevention for the use initiated the shutdown from calling reclaimVote .
CollectionShutdown.sol#L369-L370
File: CollectionShutdown.sol
356: function reclaimVote(address _collection) public whenNotPaused {
//code
368: // We delete the votes that the user has attributed to the collection
369:@> params.shutdownVotes -= uint96(userVotes);
This line resets back the shutdownVotes to 0
Making CollectionShutdown::preventShutdown checks useless.
Internal pre-conditions
lockerManagercallingCollectionShutdown::preventShutdown.
Attack Path 1
lockerManagercalling CollectionShutdown::preventShutdown.- Malicious user front run the
CollectionShutdown::preventShutdownby callingCollectionShutdown::startandCollectionShutdown::reclaimVote. lockerMangerbelieve this collection is prevented from shutdown but its not.
Attack Path 2
- Malicious user calling
CollectionShutdown::startandCollectionShutdown::reclaimVote. lockerManagercalling CollectionShutdown::preventShutdown.lockerMangerbelieve this collection is prevented from shutdown but its not.
Impact
Bypass preventShutdown function making it useless.
Mitigation
- When doing a shutdown check for
quorumVotesor check duringvote()that the collection is prevented from shutdown.
Change the check in preventShutdown.
- if (_collectionParams[_collection].shutdownVotes != 0) revert ShutdownProcessAlreadyStarted();
+ if (_collectionParams[_collection].quorumVotes != 0) revert ShutdownProcessAlreadyStarted();
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the preventShutdown function checks the current vote count instead of whether a shutdown process has been initiated, allowing the count to be reset to zero by reclaiming a vote.
Impact
The preventShutdown function can be bypassed, making it useless and allowing a shutdown to proceed despite the manager's attempt to prevent it.
What the attacker needed
Attacker can call start and reclaimVote; locker manager calls preventShutdown
How it was found
- The locker manager calls preventShutdown to block a collection shutdown.
- A malicious user front-runs by calling start and then reclaimVote.
- The locker manager believes the collection is prevented from shutdown but it is not.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A manager tries to stop a collection from being shut down by calling a function that checks if any votes have been cast. But an attacker can cast a vote and then take it back, making the vote count zero again. The manager's stop then goes through, but the shutdown can still happen because the check was fooled.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.