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

Potential security issues in `init` function

Summary

The init function in InitMigrateUnripeBeanEthToBeanSteth serves as the initializer for the migration process of Unripe Bean:Eth underlying tokens to Bean:Steth within a decentralized protocol. It does the following things:

  • The init function starts by deleting the wellOracleSnapshots associated with the Bean:Eth well, effectively turning off Bean:Eth minting.

  • It sets a future season number (beanEthStartMintingSeason) at which Bean:Eth minting will resume, allowing time for other processes like the Multi Flow Pump to catch up.

  • It also whitelists the Bean:WstETH token for use within the protocol. It configures parameters related to the Bean:WstETH well, such as the initial gauge points and the optimal percent deposited for the Bean:WstETH token.

  • It updates the optimal percent deposited for the Bean:Eth well. This likely adjusts certain parameters to optimize the protocol's performance or balance its economic incentives.

  • It also initiates the migration process for the Bean:WstETH well by calling the LibFertilizer:beginBarnRaiseMigration. This likely sets the stage for further actions related to the migration.

init function is typically called during protocol deployment, and it's often assumed that this process is handled securely. However, it's essential to consider potential security vulnerabilities, even during deployment, as they could lead to unexpected behavior or exploitation if left unchecked.

Vulnerability Details

The primary issue with the init function is the lack of access control. Without access control, any external account or contract can call the init function, potentially leading to unauthorized changes in the system's state or behavior. Since the init function is responsible for crucial actions such as migrating underlying tokens and updating system parameters, unauthorized access could have severe consequences.

See the following code:

function init() external {
// Turn off Bean:Eth Minting while Multi Flow Pump catches up
delete s.wellOracleSnapshots[C.BEAN_ETH_WELL];
s.season.beanEthStartMintingSeason = s.season.current + BEAN_ETH_PUMP_CATCH_UP_SEASONS;
LibWhitelist.whitelistToken(
C.BEAN_WSTETH_WELL,
BDVFacet.wellBdv.selector,
STALK_ISSUED_PER_BDV,
0, // No need to set Stalk issued per BDV
0x01,
IGaugePointFacet.defaultGaugePointFunction.selector,
ILiquidityWeightFacet.maxWeight.selector,
BEAN_WSTETH_INITIAL_GAUGE_POINTS,
OPTIMAL_PERCENT_DEPOSITED_BDV
);
LibWhitelist.updateOptimalPercentDepositedBdvForToken(
C.BEAN_ETH_WELL,
MAX_PERCENT_DEPOSITED_BDV - OPTIMAL_PERCENT_DEPOSITED_BDV
);
LibFertilizer.beginBarnRaiseMigration(C.BEAN_WSTETH_WELL);
}

Impact

If an unauthorized entity calls the init function, several negative outcomes could occur:

  • Unauthorized migration of underlying tokens: The migration process may proceed without proper authorization, leading to unexpected transfers of assets.

  • Manipulation of system parameters: Unauthorized changes to system parameters, such as gauge points or percent deposited values, could disrupt the functioning of the protocol or result in economic imbalances.

  • Loss of funds or assets: Malicious actors could exploit vulnerabilities introduced by unauthorized calls to the init function to steal funds or manipulate asset distributions.

Tools Used

Manual Review

Recommendations

Add an access control mechanism to restrict the execution of the init function to authorized accounts or contracts. This can be achieved using modifiers such as onlyOwner from OpenZeppelin's Ownable contract or by defining custom access control logic tailored to the protocol's requirements. Also Ensure that the deployment process follows best practices for security, including verifying contract addresses and permissions before initiating transactions. Use multi-signature wallets or other secure mechanisms to authorize deployment transactions.

Updates

Lead Judging Commences

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

Init access control

Support

FAQs

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