DeFiHardhatFoundry
250,000 USDC
View results
Submission Details
Severity: high
Valid

Grown Stalk is incorrectly calculated in ReseedSilo

Summary

ReseedSilo migrates Silo deposits. It calculates stalk associated with deposits' owner by combining 2 types of Stalk: reward Stalk and Stalk issued during deposit.

Problem is that during reward Stalk calculation it overestimates actual amount by 1e6 times.

Vulnerability Details

Here you can see in ReseedSilo it multiplies stem delta and BDV:
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/beanstalk/init/reseed/L2/ReseedSilo.sol#L132

accountStalk += uint96(siloDeposit.stemTip - stem) * deposits.dd[j].bdv;

However stem already represents Stalk amount issued per BDV, i.e. per 1e6 BDV. For example if stem delta is 5.4e6 and BDV is 10e6, it should calculate 54e6 Stalk.

You can find correct implementation in old part of Beanstalk:
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/df2dd129a878d16d4adc75049179ac0029d9a96b/protocol/contracts/libraries/Silo/LibSilo.sol#L650-L669

function stalkReward(
int96 startStem,
int96 endStem,
uint128 bdv
) internal pure returns (uint256) {
uint128 reward = uint128(uint96(endStem.sub(startStem))).mul(bdv).div(PRECISION);
return reward;
}

Impact

ReseedSilo overestimates migrated Stalk by 1e6 times. It means new deposits will give too low Stalk compared to migrated, it completely breaks governance because Stalk is governance token.

Additionally migrated deposits will steal all the Beans from new depositors distributed to Silo at the start of the season

Tools Used

Manual Review

Recommendations

- accountStalk += uint96(siloDeposit.stemTip - stem) * deposits.dd[j].bdv;
+ accountStalk += uint96(siloDeposit.stemTip - stem) * deposits.dd[j].bdv / 1e6;
Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

L2ContractMigrationFacet migrates incorrect amount of Stalk should be divided by 1e6

Appeal created

T1MOH Submitter
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

ReseedSilo migrates incorrect amount of Stalk should be divided by 1e6

inallhonesty Lead Judge 12 months ago
Submission Judgement Published
Validated
Assigned finding tags:

ReseedSilo migrates incorrect amount of Stalk should be divided by 1e6

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.