Submitted by SBSecurity, also found by 0xCiphky
In certain scenarios, shares of a subsequent depositor can be heavily reduced, losing a large amount of his deposited funds, the attacker can increase the right side of the previewMintShares by adding rewards for compounding.
That way victim can lose 6e17 of his assets for a deposit of 1e18.
Lets see how a first user, can grief a subsequent deposit and reduce his shares from the desired 1:1 ratio to 1:0000000000000005.
First, he needs to choose PowerFarmToken with no previous deposits.
The attacker does not lose his deposit of 1e18 because it is converted to rewardTokens and sent to him, basically making the inflation free.
PendlePowerFarmController.sol#L53-L111
After that, totalSupply = 3, underlyingLpAssetsCurrent = 1e18 - 1. The victim transaction is then executed:
PendlePowerFarmToken.sol#L452-L463
Both attacker and victim have 1 share, because of the fee that is taken in the deposit function.
After victim deposit: totalSupply: 5, underlyingLpAssetsCurrent = 2e18 - 1. Then, the victim tries to withdraw all his shares - 1 (1 was taken as a fee on deposit).
PendlePowerFarmToken.sol#L465-L476
User has lost 1e18 - 0.3e18 = 0.6e18 tokens.
Since there will be many PowerFarmTokens deployed, there is no way for team to perform the first deposit for all of them. Possible mitigation will be to have minimum deposit amount for the first depositor in the PendlePowerToken, which will increase the cost of the attack exponentially. There will not be enough reward tokens making the exchangeRewardsForCompoundingWithIncentive revert, due to insufficient amount. Or, could mint proper amount of tokens in the initialize function.
vm06007 (Wise Lending) commented:
vm06007 (Wise Lending) commented:
