# dettachFromManagedNFT might revert and temporarily prevent users from detaching in certain situations

detachFromManagedNFT calls _poke which recasts votes; if a voted gauge was killed, _vote reverts, temporarily blocking users from detaching their veNFT.

- Payout: Audit contest
- Severity: medium
- Program: Fenix Finance
- Found by: nnez
- Disclosed: 2024-10-11
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-09-fenix-finance-findings/issues/5
- Library page: https://bugbountylibrary.com/r/c4%3A2024-09-fenix-finance%3AM-05
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:code4rena sev:medium tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** VotingEscrow/ManagedNFT detach flow (Solidity contract)
**Root cause:** detachFromManagedNFT unconditionally calls _poke, which recasts existing votes via _vote; _vote reverts with GaugeAlreadyKilled if any previously voted gauge is dead, so detach reverts too.
**Steps:**
1. Bob attaches veNFT to ManagedNFT.
2. ManagedNFT votes for `[gaugeA, gaugeB]`.
3. gaugeB is killed mid-epoch.
4. Bob calls `detachFromManagedNFT(tokenId)`; `_poke` -> `_vote` iterates pools and hits `if (!state.isAlive) revert GaugeAlreadyKilled();`.
5. Transaction reverts; Bob cannot detach until ManagedNFT recasts votes excluding gaugeB.
**How found:** Code reading of detachFromManagedNFT's _poke path and _vote's isAlive check, reasoning that a killed gauge in the stored poolVote list would make the recast revert.
**Insight:** When a function re-applies stored state (recast votes, replay config), check whether validation that was valid at write time (gauge alive) can fail at replay time, turning a cleanup/exit path into a revert DoS.

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

**dettachFromManagedNFT calls _poke which reverts on killed gauge**

```
function dettachFromManagedNFT(uint256 tokenId_) external nonReentrant onlyNftApprovedOrOwner(tokenId_) {
    _checkVoteDelay(tokenId_);
    _checkVoteWindow();
    IManagedNFTManager managedNFTManagerCache = IManagedNFTManager(managedNFTManager);
    uint256 managedTokenId = managedNFTManagerCache.getAttachedManagedTokenId(tokenId_);
    managedNFTManagerCache.onDettachFromManagedNFT(tokenId_);
    uint256 weight = IVotingEscrowV2(votingEscrow).balanceOfNftIgnoreOwnershipChange(managedTokenId);
    if (weight == 0) {
        _reset(managedTokenId);
        delete lastVotedTimestamps[managedTokenId];
    } else {
        _poke(managedTokenId);
    }
    emit DettachFromManagedNFT(tokenId_);
}
```

**_vote reverts GaugeAlreadyKilled on dead gauge**

```
function _vote(uint256 tokenId_, address[] memory pools_, uint256[] memory weights_) internal {
    _reset(tokenId_);
    uint256 nftVotePower = IVotingEscrowV2(votingEscrow).balanceOfNFT(tokenId_);
    uint256 totalVotesWeight;
    uint256 totalVoterPower;
    for (uint256 i; i < pools_.length; i++) {
        GaugeState memory state = gaugesState[poolToGauge[pools_[i]]];
        if (!state.isAlive) {
            revert GaugeAlreadyKilled();
        }
        totalVotesWeight += weights_[i];
    }
```

