Skip to content
$1,000,000 in security audit grants are live now, Apply here →

Security review · March 2025

Berachain Cauldron

for Abracadabra Money

Guardian's review of Berachain Cauldron for Abracadabra Money, published March 2025. The report records 14 findings, including 2 medium and 12 low.

Published
Review window
March 17 to 19, 2025
Language
Solidity
Chains
Berachain
Sector
Lending, Yield and vaults
  • 0 Critical
  • 0 High
  • 2 Medium
  • 12 Low
  • 0 Informational

14 acknowledged

Findings 14

  1. M-01 Medium Reward Distributions Can Be Sandwiched Sandwich Attack Acknowledged
    Location
    MagicInfraredVault.sol

    Description

    The MagicInfraredVault’s distributeRewards function increases the _totalAssets value immediately upon execution. This immediate increment creates an opportunity for sandwich attack arbitrage, especially when rewards are substantial. Attackers can monitor the mempool, identify pending reward distribution transactions, and frontrun or backrun them to profit instantly without holding the vault exposure equivalent to genuine vault depositors who provided capital to generate the rewards. Even if a private RPC is used, preliminary transactions such as harvest might signal an impending reward distribution, indirectly informing attackers of upcoming profitable trades. While such indirect signals may not guarantee profit, they still significantly increase the likelihood of arbitrage opportunities.

    Recommendation

    Be sure to use a private RPC to call the distributeRewards function. Otherwise be sure to keep the reward distributions small and infrequent. A more long term solution is to consider refactoring the reward distribution logic so that the totalAssets increment is gradual rather than instantaneous.

  2. M-02 Medium Reward Distributions Can Be Sandwiched Sandwich Attack Acknowledged
    Location
    MagicInfraredVault.sol

    Description

    The MagicInfraredVault’s distributeRewards function increases the _totalAssets value immediately upon execution. This immediate increment creates an opportunity for sandwich attack arbitrage, especially when rewards are substantial. Attackers can monitor the mempool, identify pending reward distribution transactions, and frontrun or backrun them to profit instantly without holding the vault exposure equivalent to genuine vault depositors who provided capital to generate the rewards. Even if a private RPC is used, preliminary transactions such as harvest might signal an impending reward distribution, indirectly informing attackers of upcoming profitable trades. While such indirect signals may not guarantee profit, they still significantly increase the likelihood of arbitrage opportunities.

    Recommendation

    Be sure to use a private RPC to call the distributeRewards function. Otherwise be sure to keep the reward distributions small and infrequent. A more long term solution is to consider refactoring the reward distribution logic so that the totalAssets increment is gradual rather than instantaneous.

  3. L-01 Low BEX Vault Can Be Paused Causing A DoS DoS Acknowledged
    Location
    BexLib.sol

    Description

    Within the BEX Vault contract, the joinPool function contains the whenNotPaused modifier. Consequently, whenever the Vault is paused, calls to joinPool revert, effectively blocking any functionality that relies on depositing tokens (joining) into the pool. However, the exitPool function has no such pause check and continues to work even if the BEX Vault is paused. In the MagicBexVaultLevSwapper (particularly the swap function) and the MagicBexVaultHarvester (the run function), both rely on BexLib.joinPool to complete their flows:

    • MagicBexVaultLevSwapper.swap needs to join the BEX pool after swapping MIM for underlying tokens.
    • MagicBexVaultHarvester.run must join the BEX pool to compound yield after swapping reward tokens. Because the BEX Vault can be paused at any time, any calls to joinPool will fail while paused. That means both MagicBexVaultLevSwapper.swap and MagicBexVaultHarvester.run revert under pause conditions, causing a Denial of Service for those functions.

    Recommendation

    Document that if the BEX Vault is paused, MagicInfraredVault depositors will not be able to receive any yield.

  4. L-02 Low MINIMUM_SHARE Requirement May Block Swaps DoS Acknowledged
    Location
    MagicBexVaultSwapper.sol: 49, MagicBexVaultLevSwapper.sol: 49

    Description

    When one of the two swappers used in the liquidation function of the Cauldron receives the collateral tokens, it's withdrawing them from the DegenBox. When withdrawing, the degenbox has a requirement that the shares after the withdrawal must be at least MINIMUM_SHARE_BALANCE (or 1000), unless it's a full withdrawal. Because of this, there may be some situations where the swapper is trying to withdraw an amount which triggers this revert and result in a failed liquidation.

    Recommendation

    The swapper parameter in CauldronV4.liquidate is permissionless, so if a liquidation fails because of this, a different swapper can be provided. Therefore, it's enough to document the issue as a potential behavior.

  5. L-03 Low Swapper Approvals Are Unrestricted Warning Acknowledged
    Location
    MagicBexVaultSwapper.sol; MagicBexVaultLevSwapper.sol

    Description

    The MagicBexVaultSwapper.swap and MagicBexVaultLevSwapper.swap functions are permissionless which allows giving an approval to whatever to address the callers wants.

    Recommendation

    Document this.

  6. L-04 Low Unset exchangeRouter Address In Harvester Contracts Warning Acknowledged
    Location
    MagicBexVaultHarvester.sol, MagicKodiakVaultHarvester.sol

    Description

    The exchangeRouter address, intended for token swaps during the reward harvesting process, is currently unset (zero address) in the harvester contracts. An unset or incorrect exchangeRouter address will prevent swaps from executing correctly, causing reward harvesting operations to fail disabling the rewards distribution.

    Recommendation

    Ensure the exchangeRouter address is properly set to a valid router.

  7. L-05 Low Potential Pending Rewards in MagicInfraredVault Warning Acknowledged
    Location
    MagicInfraredVault.sol

    Description

    The run function in the MagicBexVaultHarvester can be called by the owner or an address with the operator role to harvest rewards from the staking contract and distribute them to the vault. However, users can also call the getRewardForUser function in the InfraredVault contract, specifying the MagicInfraredVault contract’s address. This leads to an unfinished sequence where rewards are transferred to the MagicInfraredVault contract but are not harvested until run is called next on the MagicBexVaultHarvester. As a result, these rewards may not be properly accounted for when determining the swap parameters.

    Recommendation

    Ensure that the run function parameters account for any pending rewards in the MagicInfraredVault contract to maintain accurate swap calculations.

  8. L-06 Low Vault Contribution May Not Be Rewarded Warning Acknowledged
    Location
    MagicInfraredVault.sol

    Description

    When the InfraredVault accumulates rewards in the RewardVault, the InfraredVault.notiyfyRewardAmount() function is called to update the reward rate. Because of this design some users may not be properly rewarded for their contributions. For example,

    • rewardDuration in RewardVault is 7 days
    • only staker in RewardVault is InfraredVault and only staker in InfraredVault is MagicInfraredVault
    • user A and user B deposit equal amount of LP in the MagicInfraredVault
    • These are staked in the RewardVault on the behalf of InfraredVault
    • The RewardVault receives 600 BGT in rewards
    • After one week passes the rewards are claimed and notified to the InfraredVault
    • Reward distribution in InfraredVault has just began
    • If user B leaves the MagicVault they won't receive any additional rewards (even if harvest is called before the withdraw) even if he contributed for them

    Recommendation

    In the above example, the user loses rewards for the whole rewardPeriod in the RewardVault. There is no perfect solution to this as it's the way Infrared operates. Calling harvest() frequently is one way to reduce the losses because each harvest() claims the rewards from the RewardVault to InfraredVault. You can do that and also document this behavior so users are aware of it.

  9. L-07 Low Withdrawing Users Lose Unharvested Rewards Warning Acknowledged
    Location
    MagicInfraredVault.sol

    Description

    Withdrawers lose their rewards which have accumulated between the previous Harvester.run call and the current moment because at the time of the next Harvester.run call, their balance will be reduced.

    Recommendation

    Make sure to harvest the rewards frequently.

  10. L-08 Low New Reward Tokens Require More Approvals Warning Acknowledged
    Location
    MagicBexVaultHarvester.sol, MagicKodiakVaultHarvester.sol

    Description

    New reward tokens may be added to the Infrared vault with the addReward function. These reward tokens will require additional approvals to be made to the exchangeRouter contract.

    Recommendation

    Currently this can be achieved by using the setExchangeRouter function to set the same exchangeRouter implementation in order to approve all new tokens. Be aware that this scenario may arise.

  11. L-09 Low Incompatibility With fee-on-transfer Tokens Warning Acknowledged
    Location
    Global

    Description

    All the contracts assume that tokens do not apply transfer fees or rebases. Tokens that implement fees upon transfers (commonly referred to as “fee-on-transfer tokens”) or other mechanics like rebasing would lead to incorrect balance calculations, breaking core functionality.

    Recommendation

    Explicitly document that fee-on-transfer tokens are not supported or enforce restrictions to disallow fee-on-transfer and rebasing tokens.

  12. L-10 Low Dangling Approvals If Reward Tokens Are Removed Warning Acknowledged
    Location
    MagicBexVaultHarvester.sol, MagicKodiakVaultHarvester.sol

    Description

    In the setExchangeRouter function the approvals are removed for all existing reward tokens from the previous exchangeRouter contract. However if a reward is removed from the infrared vault with the removeReward function then this token approval will not be removed from the previous exchangeRouter upon the next exchangeRouter update.

    Recommendation

    Consider adding an additional function to remove targeted approvals from an existing or past exchangeRouter contract for cases where the reward tokens are updated.

  13. L-11 Low MagicInfraredVault’s Harvest Logic Breaks if Reward Token Matches the Underlying Asset Logical Error Acknowledged
    Location
    MagicInfraredVault.sol

    Description

    Within the MagicInfraredVault contract, the harvest function collects reward tokens from staking.getAllRewardTokens, swaps them via aggregator calls, and then re‐deposits them as the Vault’s underlying asset (_asset). If the staking contract unexpectedly returns a reward token that is exactly the same address as _asset, the assets would be sent to the harvester and they would be wrongly seen as rewards as in the distributeRewards call the following update would be performed: _totalAssets += amount;. The code does not check that each reward token differs from the main _asset. If _asset appears among the reward tokens, the logic within the harvest and distributeRewards functions will malfunction, causing broken harvesting flows and incorrect accounting.

    Recommendation

    MagicInfraredVault should explicitly validate that none of the tokens in staking.getAllRewardTokens equals _asset.

  14. L-12 Low Unset exchangeRouter Address In Harvester Contracts Warning Acknowledged
    Location
    MagicBexVaultHarvester.sol, MagicKodiakVaultHarvester.sol

    Description

    The exchangeRouter address, intended for token swaps during the reward harvesting process, is currently unset (zero address) in the harvester contracts. An unset or incorrect exchangeRouter address will prevent swaps from executing correctly, causing reward harvesting operations to fail disabling the rewards distribution.

    Recommendation

    Ensure the exchangeRouter address is properly set to a valid router.

More from Abracadabra Money

All 19 reports
  1. MagicGLP Upgrade

    11 findings1 high 11 findings: 1 high, 10 low
  2. PurrSwap Aerodrome

    105 findings9 high 105 findings: 9 high, 23 medium, 45 low, 28 informational
  3. PurrSwap ve33

    74 findings5 critical · 10 high 74 findings: 5 critical, 10 high, 20 medium, 39 low
  4. Hyperliquid OFT Deployment

    3 findings 3 findings: 1 low, 2 informational

Put your code through the same review.

This review started with a conversation about scope. Tell us what you are building and we will plan yours with you.

Get a quote