Closed sherlock-admin4 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.
0xvj
high
forwardYield function can be sandwiched to make it distribute more yield than intended
Summary
In
OCE_ZVE
contract yield is distributed based on thebasis
returned by thefetchBasis
function , which can be manipulated by an attacker by sandwiching theforwardYield
call to make the locker distribute more yield than intended.Vulnerability Detail
In
forewardYield
function , yield that needs to be distributed to YDL is calculated based on basis , which is the pro-rata amount of pairAsset in the pool for the lp tokens owned by the locker. But an attacker can manipulate the amount of pairAsset in the liquidity pool due to whichlpBurnable
will be calculated to a high value than intended value and more yield will be distributed to the user.Attack steps:
forwardYield
which calculates thelpBurnable
value based on pairAsset amount in the pool. As the pairAsset is inflated herelpBurnable
value will also be inflated.As the forwardYield function can be called by anyone (if block.timestamp > nextYieldDistribution) an attacker easily carry this sandwich attack using a smart contract instead of doing a sandwich attack by paying higher gas price.
Impact
More yield will be distributed to YDL than intended amount which will cause loss to the protocol.
Code Snippet
https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/lockers/OCL/OCL_ZVE.sol#L316-L318
Tool used
Manual Review
Recommendation
Consider changing the yield distribution mechanism.
Duplicate of #296