code-423n4 / 2022-05-factorydao-findings

1 stars 1 forks source link

Users Can Prevent Excess Tokens From Being Withdrawn By The Pool Creator In `withdrawExcessRewards()` #256

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L242-L256 https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L185-L189 https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L221

Vulnerability details

Impact

Because pools will likely never be fully utilised by stakers while active, the following assumption in withdrawExcessRewards() can be broken by preventing any receipt withdrawal:

require(pool.totalDepositsWei == 0, 'Cannot withdraw until all deposits are withdrawn');

There are two main ways that this assumption can be broken:

Recommended Mitigation Steps

Make use of a grace period after a pool's staking period ends. This should give ample time to stakers to make the necessary withdrawal on the pool. Subsequently, the withdrawExcessRewards() function should be callable by anyone, allowing all funds unused funds to be withdrawn.

illuzen commented 2 years ago

Duplicate #20

gititGoro commented 2 years ago

reducing severity as rewards are not base assets.

0xleastwood commented 2 years ago

Pretty sure this is different. A single user could prevent excess rewards from being withdrawn. IMO, this is not a dupe of #20