https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/main/protocol/contracts/libraries/Minting/LibMinting.sol#L20
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/main/protocol/contracts/libraries/Minting/LibWellMinting.sol#L56
https://github.com/Cyfrin/2024-05-beanstalk-the-finale/blob/main/protocol/contracts/libraries/Minting/LibWellMinting.sol#L74
The LibMinting.sol:checkForMaxDeltaB
unsafely cast the totalSupply()
a uint256 number to int256, will lead to arithemetic overflow when the totalSupply() / MAX_DELTA_B_DENOMINATOR) > type(int256).max
, this overflow won't revert as it will fail silently because on the unsafe casting.
Since Bean is minting to meet market demand the totalSupply()
of bean can go above MAX_DELTA_B_DENOMINATOR * type(int256).max
.
The LibWellMinting.sol:capture
function depends on the LibMinting.sol:checkForMaxDeltaB
, and the LibWellMinting.sol:capture
is used to calculate the DeltaB in a particular well.
Delta B will be incorrectly calculated which can lead to unexpected behavior.
The LibWellMinting.sol:check
is also affected, there will be errors in calculating SeasonGettersFacet.sol:poolDeltaB
and SeasonGettersFacet.sol:totalDeltaB
.
Manual Analysis
set the maximum bean that can be minted to be less than type(int256).max
.
Use safeCast in LibMinting.sol:checkForMaxDeltaB
.
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.