Conversion is one of the mechanisms Beanstalk uses in maintaining the peg. For conversion to be effective in maintaining the peg, Beanstalk set some rules when conversion can be carried out.
For example when converting BEAN:3CRV LP to BEAN, requires a condition that deltaB
< 0.
https://docs.bean.money/almanac/peg-maintenance/convert
The root cause of this Vulnerability is that the convert function doesn't check for deltaB
before carrying out the conversion. So users can convert their BEAN:3CRV LP to BEAN, even when there is excess BEAN in the market. This will reduce the price of BEAN.
Other Pools are also affected by this vulnerability.
Add the code below to https://github.com/Cyfrin/2024-02-Beanstalk-1/blob/main/protocol/test/ConvertCurve.test.js#L706
Run the code with the following command
On the test we can see that, the total deltaB
before and after the conversion was 0, which violates the rule that deltaB
< 0, for the conversion to work. But the conversion was done successfully.
Loss of Peg due to excess bean
Manual Analysis
Add checks in LibCovert.sol::convert
to ensure that the conversion conditions are met before carrying out the conversion. For example deltaB
< 0, before converting from BEAN:3CRV LP to BEAN.
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.