Since the pool.depositToken can be any token, it is possible that pool will be created with tokens that support fee on transfer. If a fee on transfer token is chosen, other user's funds might be drained. The actual amount of tokens the contract holds could be less than receipt.amountDepositedWei
Assume transfer fee to be 5% and PermissionlessBasicPoolFactory.sol has 200 token.
Alice deposit 100 token. Now, PermissionlessBasicPoolFactory.sol has 295 token.
Alice withdraw 100 token.
PermissionlessBasicPoolFactory.sol ends up having 195 token.
Alice can drain token hold by PermissionlessBasicPoolFactory.sol by doing this multiple times.
Lines of code
https://github.com/code-423n4/2022-05-factorydao/blob/main/contracts/PermissionlessBasicPoolFactory.sol#L180-L202
Vulnerability details
Proof of Concept
Since the
pool.depositToken
can be any token, it is possible that pool will be created with tokens that support fee on transfer. If a fee on transfer token is chosen, other user's funds might be drained. The actual amount of tokens the contract holds could be less thanreceipt.amountDepositedWei
PermissionlessBasicPoolFactory.sol
has 200 token.PermissionlessBasicPoolFactory.sol
has 295 token.PermissionlessBasicPoolFactory.sol
ends up having 195 token.Alice can drain token hold by
PermissionlessBasicPoolFactory.sol
by doing this multiple times.Recommended Mitigation Steps
change to
Since every receipt can only be withdrawn once, this is safe from reentrance call to
withdraw