sherlock-audit / 2024-08-flayer-judging

0 stars 0 forks source link

Cuddly Ocean Gibbon - There is no method of returning votes in case of cancellation, resulting in loss of funds #760

Open sherlock-admin4 opened 4 days ago

sherlock-admin4 commented 4 days ago

Cuddly Ocean Gibbon

High

There is no method of returning votes in case of cancellation, resulting in loss of funds

Summary

There is no method for users who have voted to withdraw their votes (tokens) in case of voting cancellation in collectionShutdown because reclaimVotes becomes unavailable after cancellation, which leads to loss of funds.

Vulnerability Detail

In the cancel() function, the _collectionParams[_collection] structure is deleted. Once this happens, the reclaimVote function cannot be used because it uses the _collectionParams[_collection] structure, which will be empty, and, as a result, this will lead to an overflow in the subtraction line:

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/utils/CollectionShutdown.sol#L369

(params.shutdownVotes = 0, userVotes != 0reclaimVote will revert)

The case where users who voted for the liquidation of the collection want to get their money back is the most common user behavior. However, this case was not tested in the tests, and, as shown above, does not work at all, which means the funds of those who voted will be locked.

Scenario 1:

Scenario 2:

Scenario 3:

Impact

Locking of user funds. This is a critical vulnerability with 100 percent probability.

Code Snippet

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/utils/CollectionShutdown.sol#L390-L405

https://github.com/sherlock-audit/2024-08-flayer/blob/main/flayer/src/contracts/utils/CollectionShutdown.sol#L356-L377

Tool used

Manual Review

Recommendation

Add functionality to withdraw votes in case of voting cancellation.