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
Findings 14
-
M-01 Medium Reward Distributions Can Be Sandwiched Sandwich Attack Acknowledged
Description
The
MagicInfraredVault’sdistributeRewardsfunction increases the_totalAssetsvalue 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 asharvestmight 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
distributeRewardsfunction. 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 thetotalAssetsincrement is gradual rather than instantaneous. -
M-02 Medium Reward Distributions Can Be Sandwiched Sandwich Attack Acknowledged
Description
The
MagicInfraredVault’sdistributeRewardsfunction increases the_totalAssetsvalue 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 asharvestmight 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
distributeRewardsfunction. 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 thetotalAssetsincrement is gradual rather than instantaneous. -
L-01 Low BEX Vault Can Be Paused Causing A DoS DoS Acknowledged
Description
Within the BEX Vault contract, the
joinPoolfunction contains thewhenNotPausedmodifier. Consequently, whenever the Vault is paused, calls tojoinPoolrevert, effectively blocking any functionality that relies on depositing tokens (joining) into the pool. However, theexitPoolfunction has no such pause check and continues to work even if the BEX Vault is paused. In theMagicBexVaultLevSwapper(particularly theswapfunction) and theMagicBexVaultHarvester(therunfunction), both rely onBexLib.joinPoolto complete their flows:MagicBexVaultLevSwapper.swapneeds to join the BEX pool after swapping MIM for underlying tokens.MagicBexVaultHarvester.runmust join the BEX pool to compound yield after swapping reward tokens. Because the BEX Vault can be paused at any time, any calls tojoinPoolwill fail while paused. That means bothMagicBexVaultLevSwapper.swapandMagicBexVaultHarvester.runrevert under pause conditions, causing a Denial of Service for those functions.
Recommendation
Document that if the BEX Vault is paused,
MagicInfraredVaultdepositors will not be able to receive any yield. -
L-02 Low
MINIMUM_SHARERequirement May Block Swaps DoS AcknowledgedDescription
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, thedegenboxhas a requirement that the shares after the withdrawal must be at leastMINIMUM_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
swapperparameter inCauldronV4.liquidateis 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. -
L-03 Low Swapper Approvals Are Unrestricted Warning Acknowledged
Description
The
MagicBexVaultSwapper.swapandMagicBexVaultLevSwapper.swapfunctions are permissionless which allows giving an approval to whatever to address the callers wants.Recommendation
Document this.
-
L-04 Low Unset exchangeRouter Address In Harvester Contracts Warning Acknowledged
Description
The
exchangeRouteraddress, intended for token swaps during the reward harvesting process, is currently unset (zero address) in the harvester contracts. An unset or incorrectexchangeRouteraddress will prevent swaps from executing correctly, causing reward harvesting operations to fail disabling the rewards distribution.Recommendation
Ensure the
exchangeRouteraddress is properly set to a valid router. -
L-05 Low Potential Pending Rewards in MagicInfraredVault Warning Acknowledged
Description
The run function in the
MagicBexVaultHarvestercan 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 theMagicInfraredVaultcontract’s address. This leads to an unfinished sequence where rewards are transferred to theMagicInfraredVaultcontract but are not harvested until run is called next on theMagicBexVaultHarvester. 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
MagicInfraredVaultcontract to maintain accurate swap calculations. -
L-06 Low Vault Contribution May Not Be Rewarded Warning Acknowledged
Description
When the
InfraredVaultaccumulates rewards in theRewardVault, theInfraredVault.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
RewardVaultis 7 days - only staker in
RewardVaultisInfraredVaultand only staker inInfraredVaultisMagicInfraredVault - user A and user B deposit equal amount of LP in the
MagicInfraredVault - These are staked in the
RewardVaulton the behalf ofInfraredVault - The
RewardVaultreceives 600 BGT in rewards - After one week passes the rewards are claimed and notified to the
InfraredVault - Reward distribution in
InfraredVaulthas 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 wayInfraredoperates. Callingharvest()frequently is one way to reduce the losses because eachharvest()claims the rewards from theRewardVaulttoInfraredVault. You can do that and also document this behavior so users are aware of it. - rewardDuration in
-
L-07 Low Withdrawing Users Lose Unharvested Rewards Warning Acknowledged
Description
Withdrawers lose their rewards which have accumulated between the previous
Harvester.runcall and the current moment because at the time of the nextHarvester.runcall, their balance will be reduced.Recommendation
Make sure to harvest the rewards frequently.
-
L-08 Low New Reward Tokens Require More Approvals Warning Acknowledged
Description
New reward tokens may be added to the Infrared vault with the
addRewardfunction. These reward tokens will require additional approvals to be made to theexchangeRoutercontract.Recommendation
Currently this can be achieved by using the
setExchangeRouterfunction to set the sameexchangeRouterimplementation in order to approve all new tokens. Be aware that this scenario may arise. -
L-09 Low Incompatibility With fee-on-transfer Tokens Warning Acknowledged
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.
-
L-10 Low Dangling Approvals If Reward Tokens Are Removed Warning Acknowledged
Description
In the
setExchangeRouterfunction the approvals are removed for all existing reward tokens from the previousexchangeRoutercontract. However if a reward is removed from the infrared vault with theremoveRewardfunction then this token approval will not be removed from the previousexchangeRouterupon the nextexchangeRouterupdate.Recommendation
Consider adding an additional function to remove targeted approvals from an existing or past
exchangeRoutercontract for cases where the reward tokens are updated. -
L-11 Low MagicInfraredVault’s Harvest Logic Breaks if Reward Token Matches the Underlying Asset Logical Error Acknowledged
Description
Within the
MagicInfraredVaultcontract, theharvestfunction collects reward tokens fromstaking.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 thedistributeRewardscall the following update would be performed:_totalAssets += amount;. The code does not check that each reward token differs from the main_asset. If_assetappears among the reward tokens, the logic within the harvest anddistributeRewardsfunctions will malfunction, causing broken harvesting flows and incorrect accounting.Recommendation
MagicInfraredVaultshould explicitly validate that none of the tokens instaking.getAllRewardTokensequals_asset. -
L-12 Low Unset exchangeRouter Address In Harvester Contracts Warning Acknowledged
Description
The
exchangeRouteraddress, intended for token swaps during the reward harvesting process, is currently unset (zero address) in the harvester contracts. An unset or incorrectexchangeRouteraddress will prevent swaps from executing correctly, causing reward harvesting operations to fail disabling the rewards distribution.Recommendation
Ensure the
exchangeRouteraddress is properly set to a valid router.
No findings match.
More from Abracadabra Money
All 19 reports-
MagicGLP Upgrade
11 findings1 high 11 findings: 1 high, 10 low -
PurrSwap Aerodrome
105 findings9 high 105 findings: 9 high, 23 medium, 45 low, 28 informational -
PurrSwap ve33
74 findings5 critical · 10 high 74 findings: 5 critical, 10 high, 20 medium, 39 low -
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.
