DeFiHardhat
35,000 USDC
View results
Submission Details
Severity: low
Invalid

Well Minting Oracle not initialized in `LibWellMinting.check()`

Summary

The LibWellMinting.check() returns the time weighted average delta B in a given Well since the last Sunrise. It snapshots the current cumulative reserves and then checks if If the length of the stored Snapshot for a given Well is 0 before proceeding to calculates the time weighted average delta B since the input snapshot for a given Well address.

Vulnerability Details

  • https://github.com/Cyfrin/2024-04-beanstalk-2/blob/27ff8c87c9164c1fbff054be5f22e56f86cdf127/protocol/contracts/libraries/Minting/LibWellMinting.sol#L57-L70

function check(
address well
) external view returns (int256 deltaB) {
bytes memory lastSnapshot = LibAppStorage
.diamondStorage()
.wellOracleSnapshots[well];
// If the length of the stored Snapshot for a given Well is 0,
// then the Oracle is not initialized.
if (lastSnapshot.length > 0) {
(deltaB, , , ) = twaDeltaB(well, lastSnapshot);
}
deltaB = LibMinting.checkForMaxDeltaB(deltaB);
}

If the length of the stored Snapshot for a given Well is 0, then the Oracle is not initialized.
However, this case is not handled by the check() function which ought to initialize the Well Minting Oracle.

Impact

The Well Minting Oracle will not be initialized.

Tools Used

Manual Review

Recommendations

Add an else clause to handle this case:

function check(
address well
) external view returns (int256 deltaB) {
bytes memory lastSnapshot = LibAppStorage
.diamondStorage()
.wellOracleSnapshots[well];
// If the length of the stored Snapshot for a given Well is 0,
// then the Oracle is not initialized.
if (lastSnapshot.length > 0) {
(deltaB, , , ) = twaDeltaB(well, lastSnapshot);
} else {
initializeOracle(well); // @audit Handled
}
deltaB = LibMinting.checkForMaxDeltaB(deltaB);
}
Updates

Lead Judging Commences

giovannidisiena Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice
Assigned finding tags:

Informational/Invalid

Support

FAQs

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