Skip to content
Business logic Audit finding Intermediate

The rebalancing system is broken when everclear bridge contract is used

The EverclearBridge contract approves only the transfer amount for the FeeAdapter, but the FeeAdapter attempts to pull both the amount and the fee, causing a revert due to insufficient allowance. This makes all cross-chain rebalancing operations using EverclearBridge fail.

0xmechanic Follow with 10ap17, Angry_Mustache_Man and 10 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-07-malda-judging/issues/304

Found by

0xmechanic, 10ap17, Angry_Mustache_Man, Cybrid, ExtraCaterpillar, PeterSR, ZanyBonzy, bube, bulgari, dan__vinci, elolpuer, farismaulana, oxwhite

Summary

The sendMsg in EverclearBridge contract only approves the transfer amount (not including the fee) for the FeeAdapter when calling newIntent. However, the FeeAdapter attempts to pull both the amount and the fee from the bridge contract. This results in a revert due to insufficient allowance causing cross-chain rebalancing to fail.

Root Cause

The root case stem from a mismatch between the approved amount and the actual amount required by the FeeAdaptor.

The sendMsg() in everclearBridge.sol is as follows:

Solidity
 function sendMsg(
        uint256 _extractedAmount,
        address _market,
        uint32 _dstChainId,
        address _token,
        bytes memory _message,
        bytes memory // unused
    ) external payable onlyRebalancer {
        IntentParams memory params = _decodeIntent(_message);

        require(params.inputAsset == _token, Everclear_TokenMismatch());
        require(_extractedAmount >= params.amount, BaseBridge_AmountMismatch());

        uint256 destinationsLength = params.destinations.length;
        require(destinationsLength > 0, Everclear_DestinationsLengthMismatch());

        bool found;
        for (uint256 i; i < destinationsLength; ++i) {
            if (params.destinations[i] == _dstChainId) {
                found = true;
                break;
            }
        }
        require(found, Everclear_DestinationNotValid());

        if (_extractedAmount > params.amount) {
            uint256 toReturn = _extractedAmount - params.amount;
 @>           IERC20(_token).safeTransfer(_market, toReturn);//@audit-info the excess is sent back to the market
            emit RebalancingReturnedToMarket(_market, toReturn, _extractedAmount);
        }

 @>       SafeApprove.safeApprove(params.inputAsset, address(everclearFeeAdapter), params.amount);//@audit approve is done for amount
        (bytes32 id,) = everclearFeeAdapter.newIntent(
            params.destinations,
            params.receiver,
            params.inputAsset,
            params.outputAsset,
            params.amount,
            params.maxFee,
            params.ttl,
            params.data,
            params.feeParams
        );
        emit MsgSent(_dstChainId, _market, params.amount, id);
    }

The newIntent method in feeAdaptor contract is defined as:

Solidity
/// @inheritdoc IFeeAdapter
  function newIntent(
    uint32[] memory _destinations,
    bytes32 _receiver,
    address _inputAsset,
    bytes32 _outputAsset,
    uint256 _amount,
    uint24 _maxFee,
    uint48 _ttl,
    bytes calldata _data,
    IFeeAdapter.FeeParams calldata _feeParams
  ) external payable returns (bytes32 _intentId, IEverclear.Intent memory _intent) {
    // Transfer from caller
@>    _pullTokens(msg.sender, _inputAsset, _amount + _feeParams.fee);//@audit amount+fee is pulled from bridge contract

    // Create intent
    (_intentId, _intent) =
      _newIntent(_destinations, _receiver, _inputAsset, _outputAsset, _amount, _maxFee, _ttl, _data, _feeParams);
  }

As shown, _amount + _feeParams.fee is pulled from bridge contract, which will result in revert as the approve was done only for the specified amount.

Internal Pre-conditions

There is an imbalance and sendMsg is invoked in the rebalancer contract.

External Pre-conditions

Market B requires rebalancing Assets are available in Market A

Attack Path

  1. Market A on X chain has 12,000 USDC extractable value.
  2. Market B on Y chain needs 10,000 USDC.
  3. The sendMsg() function is invoked in the Rebalancer contract with _amount = 12,000 USDC.
  4. The 12,000 USDC is sent to the EverclearBridge contract. Since the extracted amount is greater than the amount specified in the message, the excess 2,000 USDC is sent back to Market A.
  5. The FeeAdaptor contract is approved for only 10,000 USDC.
  6. The newIntent() function is called on the FeeAdaptor. This function attempts to pull 10,000 USDC + fee, but it reverts due to insufficient approval.

As result, the rebalancing will not succeed.

Additinal Notes: According to the FeeAdaptor and Spoke contract logic in everclear platform, the fee is not deducted from the specified transfer amount but instead added on top during token transfer. Therefore, the fee cannot be zero, and any under-approval results in failure. If the fee were instead deducted from the approved amount, Market B would receive less than 10,000 USDC, potentially leading to issues like insufficient liquidity.

Impact

All cross-chain rebalancing operations using EverclearBridge will fail.

PoC

See the function flow and contract state change given above

Mitigation

Update the allowance logic in EverclearBridge to approve enough amount for the FeeAdapter.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/malda-protocol/malda-lending/pull/114/files

CergyK

Fix looks good

The original report as published on Sherlock, by 0xmechanic. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The bridge approved only the transfer amount, but the fee adapter attempted to pull the transfer amount plus the fee, causing an allowance mismatch.

Impact

All cross-chain rebalancing operations using EverclearBridge will fail.

What the attacker needed

Market B requires rebalancing; Assets available in Market A; Rebalancer invokes sendMsg

The fix

The allowance logic in EverclearBridge should be updated to approve enough amount for the FeeAdapter; the protocol team fixed this issue in a pull request.

How it was found

  1. Market A on chain X has 12,000 USDC available for rebalancing.
  2. Market B on chain Y needs 10,000 USDC.
  3. The rebalancer calls sendMsg with an extracted amount of 12,000 USDC.
  4. The excess 2,000 USDC is returned to Market A, leaving 10,000 USDC in the bridge.
  5. The bridge approves the FeeAdapter for only 10,000 USDC.
  6. The FeeAdapter tries to pull 10,000 USDC plus the fee, but the transaction reverts due to insufficient allowance.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When one contract wants another to move tokens on its behalf, it must first give permission (an allowance). Here, the bridge gave permission for only part of the tokens that the fee adapter tried to take, so the transfer failed. As a result, moving funds between chains through this bridge did not work.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Malda

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.