AdpaterBase.harvest should be called before deposit and withdraw
rvierdiiev Follow with bin2chen
Originally disclosed on Code4rena
Submitted by rvierdiiev, also found by bin2chen
Impact
AdpaterBase.harvest should be called before deposit and withdraw.
Proof of Concept
Function harvest is called in order to receive yields for the adapter. It calls strategy, which handles that process. Depending on strategy it can call strategyDeposit function in order to deposit earned amount through the adaptor.
That actually means that in case if totalAssets was X before harvest call, then after it becomes X+Y, in case if Y yields were earned by adapter and strategy deposited it. So for the same amount of shares, user can receive bigger amount of assets.
When user deposits or withdraws, then harvest function is called, but it’s called after shares amount calculation.
Because of that, in case of deposit, all previous depositors lose some part of yields as they share it with new depositor.
And in case of withdraw, user loses his yields.
Tools Used
VS Code
Recommended Mitigation Steps
Call harvest before shares amount calculation.
RedVeil (Popcorn) acknowledged
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity business logic bug in Popcorn contest. Code4rena made it public on 7 September 2023. Found in the 2023-01-popcorn audit contest (finding M-25), also found by 1 other warden.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.