Pipeline Convert is a way to convert Silo deposits from one token to another while not losing Grown Stalk and potentially increasing final BDV.
Problem is that it doesn't handle case where final BDV is less than before Pipeline Convert. Because of issue it doesn't decrease Grown Stalk.
It allows users to just withdraw part of their deposit without Grown Stalk penalty.
Let's take a look on pipelineConvert()
. It:
Removes deposits from account
Execute Pipeline Convert logic
Creates deposits to account with certain BDV and Grown Stalk which are calculated inside step 2
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/beanstalk/silo/PipelineConvertFacet.sol#L62-L110
Let's dive into step 2. It performs AdvancedFarmCalls and applies penalty to newGrownStalk
based on caps and deltaB disbalance.
And in step 3 it calculates new Stem based on Grown Stalk it should produce:
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/libraries/Silo/LibTokenSilo.sol#L545-L555
Finally here is attack vector:
Assume Attacker has Silo deposit of 100e6 Bean with Stem 4990e6. Current stemTip = 5000e6
, it means his Grown Stalk is (5000e6 - 4990e6) * 100e6 / 1e6 = 1000e6
In AdvancedFarmCalls during PipelineConvert Attacker just withdraws 99e6 Beans (converts Bean to Bean). It can only slightly be penalised based on cap exceed, penalization doesn't matter so assume penalization doesn't happen
It calculates stem for deposit of 1e6 Bean so that it produced 1000e6 Stalk. As a result user has deposit of 1e6 Bean with stem = 5000e6 - 1000e6 * 1e6 / 1e6 = 4000e6
.
As you can see his Grown Stalk was not decreased while user just performed withdrawal via PipelineConvert.
Users can withdraw significant part of their deposit without losing Grown Stalk. And repeat it again and again. This allows to have big amount of Stalk without depositing much to Silo.
Such attacker will steal Roots from fair users without risk. That's because he can make huge deposit for little time to gain huge amount of Stalk and Roots, and then withdraw that huge deposit without Grown Stalk penalization (as far as convert cap allows it).
Manual Review
Decrease Grown Stalk proportionally to decrease of BDV:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.