Skip to content
Business logic Audit finding Intermediate

If DAO updates forkEscrow before forkThreshold is reached, the user’s escrowed Nouns will be lost

The DAO can change the fork escrow contract address via a proposal while users have Nouns escrowed in the old contract. Those escrowed Nouns then cannot be withdrawn because the withdrawal function only calls the current escrow contract, which no longer holds the tokens.

cccz Follow

Originally disclosed on Code4rena

Submitted by cccz

During the escrow period, users can escrow to or withdraw from forkEscrow their Nouns.

During the escrow period, proposals can be executed.

    function withdrawFromForkEscrow(NounsDAOStorageV3.StorageV3 storage ds, uint256[] calldata tokenIds) external {
        if (isForkPeriodActive(ds)) revert ForkPeriodActive();

        INounsDAOForkEscrow forkEscrow = ds.forkEscrow;
        forkEscrow.returnTokensToOwner(msg.sender, tokenIds);

        emit WithdrawFromForkEscrow(forkEscrow.forkId(), msg.sender, tokenIds);
    }

Since withdrawFromForkEscrow will only call the returnTokensToOwner function of ds.forkEscrow, and returnTokensToOwner is only allowed to be called by DAO.

If, during the escrow period, ds.forkEscrow is changed by the proposal’s call to _setForkEscrow, then the user’s escrowed Nouns will not be withdrawn by withdrawFromForkEscrow.

    function returnTokensToOwner(address owner, uint256[] calldata tokenIds) external onlyDAO {
        for (uint256 i = 0; i < tokenIds.length; i++) {
            if (currentOwnerOf(tokenIds[i]) != owner) revert NotOwner();

            nounsToken.transferFrom(address(this), owner, tokenIds[i]);
            escrowedTokensByForkId[forkId][tokenIds[i]] = address(0);
        }

        numTokensInEscrow -= tokenIds.length;
    }

Consider that some Nouners is voting on a proposal that would change ds.forkEscrow. There are some escrowed Nouns in forkEscrow (some Nouners may choose to always escrow their Nouns to avoid missing fork). The proposal is executed, ds.forkEscrow is updated, and the escrowed Nouns cannot be withdrawn.

Proof of Concept

https://github.com/nounsDAO/nouns-monorepo/blob/718211e063d511eeda1084710f6a682955e80dcb/packages/nouns-contracts/contracts/governance/fork/NounsDAOV3Fork.sol#L95-L102 https://github.com/nounsDAO/nouns-monorepo/blob/718211e063d511eeda1084710f6a682955e80dcb/packages/nouns-contracts/contracts/governance/fork/NounsDAOForkEscrow.sol#L116-L125 https://github.com/nounsDAO/nouns-monorepo/blob/718211e063d511eeda1084710f6a682955e80dcb/packages/nouns-contracts/contracts/governance/NounsDAOV3Admin.sol#L527-L531

Recommended Mitigation Steps

Consider allowing the user to call forkEscrow.returnTokensToOwner directly to withdraw escrowed Nouns, and need to move isForkPeriodActive from withdrawFromForkEscrow to returnTokensToOwner.

eladmallel (Nouns DAO) acknowledged


The original report as published on Code4rena, by cccz. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 withdrawal function relies on a mutable escrow contract reference, so changing that reference orphans tokens held by the previous contract.

Impact

Users' escrowed Nouns could be permanently lost if the DAO updates the fork escrow contract during an escrow period.

What the attacker needed

User escrows Nouns; DAO passes proposal changing fork escrow

The fix

The report recommends allowing users to call returnTokensToOwner directly and moving the fork-period check into that function.

How it was found

  1. A user escrows Nouns into the fork escrow contract.
  2. A proposal that changes the fork escrow address is executed.
  3. The user tries to withdraw but the withdrawal function calls the new escrow contract, so the old escrowed Nouns remain stuck.

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.

Users can lock their tokens in a special contract to be ready for a possible fork. If the DAO later points to a different contract, the old locked tokens are stranded because the withdrawal code only talks to the new contract. The report suggests letting users withdraw directly from the old contract.

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.

More by cccz

View all

104 more disclosed reports, best first.

More from Nouns DAO

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.