Open code423n4 opened 2 years ago
Very minor issue, severity should be 0.
Fixed in https://github.com/jpegd/core/pull/2
I'm going to downgrade this to a medium. There is a possibility for lost funds given real world external factors (user stupidity).
Lines of code
https://github.com/code-423n4/2022-04-jpegd/blob/e72861a9ccb707ced9015166fbded5c97c6991b6/contracts/farming/LPFarming.sol#L190
Vulnerability details
Impact
LpFarming.sol
reward will be locked in the farming, when user execute a direct transfer with lpToken to farm without using deposit
Proof of Concept
"pls add this test to LpFarming.ts to check"
In the test above, the attacker transfers 100 lpToken to the farm without using deposit function, and alice deposit 100 lpToken. Because the contract uses
pool.lpToken.balanceOf(address(this))
to get the total supply of lpToken in the pool, it will sum up 100 lpToken of attacker and 100 lpToken of alice. This will lead to the situation where Alice will only be able to claim 500 token (at epoch.endBlock), the rest will be locked in the pool forever. Not only with this pool, it also affects the following, a part of the reward will be locked in the pool when the farm end.Tools Used
typescript
Recommended Mitigation Steps
Declare a new variable
totalLPSupply
to the structPoolInfo
, and use it instead ofpool.lpToken.balanceOf(address(this))