Closed sherlock-admin3 closed 6 months ago
1 comment(s) were left on this issue during the judging contest.
panprog commented:
medium, dup of #296, allows to distribute almost entire principal as if it's yield, leaving the locker with almost no funds. Since
forwardYield
will usually be called by keepers, who will use flashbots thus making frontrunning out of scope, this is medium. User can still callforwardYield
but only if keeper didn't call it in the 12 hours prior to end of period, so this requires additional conditions.
SilverChariot
high
OCL_ZVE
basis can be manipulated leading to loss of fundsSummary
OCL.fetchBasis() can be manipulated to return a wrong value by executing a swap right before it's called.
Vulnerability Detail
The
fetchBasis()
function returns the amount ofpairAssets
that's redeemable for 1 unit of LP tokens. It does so by multiplying the pool's pairAsset balance by the ratiolpOwned/totalLp
. The contract uses it to retrieve the amount of earned fees inpairAsset
.The problem is that
IERC20(pairAsset).balanceOf(pool)
can easily be manipulated by executing a swap beforefetchBasis()
is called. If the attacker wants to decrease the basis, they would swapZVE for pairAsset
, and if they want to increase the basis, they would swappairAsset for ZVE
. This wrong accounting can lead to severe consequences.An attacker can frontrun
forwardYield()
by providing a large amount ofpairAsset
. This will make the following if statement execute:_forwardYield
calculates the amount of LP tokens to be burned, which is equal to the difference between the manipulated amount and the stored basis (ignoring thecompoundingRateBIPS
for simplicity). Therefore, the attacker has control over how many of the assets in the UNI/SUSHI pool will be withdrawn and sent to theYDL
for distributing. This can result in massive losses for theOCL_ZVE
.There also exist the other case - where an attacker makes
fetchBasis
return a small number to stop yield distribution, but I think the other case is more severe.Impact
Stealing funds from the UNI/SUSHI pool if basis is increased. If the basis is decreased, other problems will emerge, one of which is the ability to stop yield distribution.
Code Snippet
POC to add to Test_OCL_ZVE.sol
First add this interface
Then, put this function in the test file.
Tool used
Foundry
Recommendation
The whole fee tracking mechanism has to be redesigned.
Duplicate of #296