# The Users who voted for collection shutdown will lose their collection tokens by cancelling the shutdown

CollectionShutdown.cancel() deletes shutdown params without refunding voters whose tokens were escrowed in _vote(), permanently losing their collection tokens.

- Payout: Audit contest
- Severity: high
- Program: Flayer
- Found by: 0xAlix2
- Disclosed: 2024-08-06
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/261
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-flayer%3AH-10
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity vuln:accounting-error vuln:business-logic

**Target:** CollectionShutdown contract (Solidity)
**Root cause:** _vote() transfers the voter's full collection token balance into the contract, but cancel() deletes _collectionParams without iterating voters to refund escrowed tokens.
**Steps:**
1. Deploy Flayer, create a collection, reach shutdown quorum so voters (e.g. address(1), address(2)) call _vote() and their tokens are transferred to CollectionShutdown.
2. Mint additional collection tokens to push totalSupply above MAX_SHUTDOWN_TOKENS * denomination (test uses `collectionToken.mint(address(10), _additionalAmount)`).
3. Call `collectionShutdown.cancel(address(erc721b))`.
4. Observe `collectionToken.balanceOf(address(1))` and `balanceOf(address(2))` are 0 — tokens never refunded.
**How found:** Code review of _vote() escrow logic vs cancel() cleanup: noticed cancel() only deletes params and emits event, with no refund loop, then wrote a Foundry PoC to confirm balances stay zero.
**Exploitation:** Any holder can trigger cancel() once total supply exceeds the threshold; all prior voters' escrowed tokens remain stuck in the contract with no reclaim path, permanently losing their collection tokens.
**Insight:** When a contract escrows user funds during a stateful process, audit every terminal transition (cancel, abort, expire) for a matching refund path — deletion of state without unwinding escrow is a classic fund-loss pattern.

## Proof of concept (copied exactly from the original report)

**Test case proving voters lose tokens on cancel**

```
function test_CancelShutdownNotRefund() public withQuorumCollection {
        uint256 _additionalAmount = 1 ether;
        // Confirm that we can execute with our quorum-ed collection
        assertCanExecute(address(erc721b), true);

        vm.prank(address(locker));
        collectionToken.mint(address(10), _additionalAmount); 

        // Cancel our shutdown
        collectionShutdown.cancel(address(erc721b));

        // Now that we have cancelled the shutdown process, we should no longer
        // be able to execute the shutdown.
        assertCanExecute(address(erc721b), false);

        console.log("Address 1 balance after:", collectionToken.balanceOf(address(1)));
        console.log("Address 2 balance after:", collectionToken.balanceOf(address(2)));
    }
```

**Cancel function that fails to refund voters**

```
function cancel(address _collection) public whenNotPaused {
        // Ensure that the vote count has reached quorum
        CollectionShutdownParams memory params = _collectionParams[_collection];
        if (!params.canExecute) revert ShutdownNotReachedQuorum();

        // Check if the total supply has surpassed an amount of the initial required
        // total supply. This would indicate that a collection has grown since the
        // initial shutdown was triggered and could result in an unsuspected liquidation.
        if (params.collectionToken.totalSupply() <= MAX_SHUTDOWN_TOKENS * 10 ** locker.collectionToken(_collection).denomination()) {
            revert InsufficientTotalSupplyToCancel();
        }

        // Remove our execution flag
        delete _collectionParams[_collection];
        emit CollectionShutdownCancelled(_collection);
    }
```

