Skip to content
Business logic Audit finding Intermediate

AdpaterBase.harvest should be called before deposit and withdraw

rvierdiiev Follow with bin2chen

Originally disclosed on Code4rena

Submitted by rvierdiiev, also found by bin2chen

https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/adapter/abstracts/AdapterBase.sol#L438-L450

https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/adapter/abstracts/AdapterBase.sol#L162

https://github.com/code-423n4/2023-01-popcorn/blob/main/src/vault/adapter/abstracts/AdapterBase.sol#L232

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


The original report as published on Code4rena, by rvierdiiev. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by rvierdiiev

View all

72 more disclosed reports, best first.

More from Popcorn contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.