Skip to content
DoS Audit finding Intermediate

Malicious user can prevent buying back OLAS token via Slipstream

The buy-back swap router refunds any ETH held by the pool contract to the caller after each swap, but the protocol's proxy cannot receive ETH, so the refund reverts and the whole buy-back fails. An attacker can front-run the buy-back by sending a small amount of ETH to the pool, causing the protocol's buy-back to revert and preventing OLAS tokens from being bought back and burned.

mrMorningstar Follow with Aristos

Originally disclosed on Code4rena

Submitted by mrMorningstar, also found by Aristos

autonolas-tokenomics/blame/bbec5ac12721a62672fb7a5ffba5c40f5a46d8cb/contracts/utils/BuyBackBurner.sol #L70

Whenever buying back olas occurs via Slipstream V3 it goes through buyBack first:

function buyBack(address secondToken, uint256 secondTokenAmount, int24 feeTierOrTickSpacing) external virtual {
        // Reentrancy guard
        if (_locked > 1) {
            revert ReentrancyGuard();
        }
        _locked = 2;

        // Get token balance
        uint256 balance = IERC20(secondToken).balanceOf(address(this));

        // Adjust second token amount, if needed
        if (secondTokenAmount == 0 || secondTokenAmount > balance) {
            secondTokenAmount = balance;
        }

        if (secondTokenAmount == 0) {
            revert ZeroValue();
        }

        // Record msg.sender activity
        mapAccountActivities[msg.sender]++;

        // Buy OLAS
        uint256 olasAmount = _buyOLAS(secondToken, secondTokenAmount, feeTierOrTickSpacing);

        emit BuyBack(secondToken, secondTokenAmount, olasAmount);

        // Get OLAS contract balance
        olasAmount = IERC20(olas).balanceOf(address(this));

        // Transfer OLAS to bridge2Burner contract
        IERC20(olas).transfer(bridge2Burner, olasAmount);

        emit TokenTransferred(bridge2Burner, olasAmount);

        _locked = 1;
    }

Then _buyOLAS is called:

  function _buyOLAS(address secondToken, uint256 secondTokenAmount, int24 feeTierOrTickSpacing)
        internal
        virtual
        returns (uint256 olasAmount)
    {
        address localOlas = olas;

        address[] memory tokens = new address[](2);
        (tokens[0], tokens[1]) = (secondToken > localOlas) ? (localOlas, secondToken) : (secondToken, localOlas);

        // Get factory from LiquidityManager
        // Actual factoryV3 is fetched from LiquidityManager, since LiquidityManager is proxy and factory might change
        address factoryV3 = ILiquidityManager(liquidityManager).factoryV3();

        // Get V3 pool from liquidity manager
        address pool = getV3Pool(factoryV3, tokens, feeTierOrTickSpacing);

        // Check for whitelisted pool address
        if (!mapV3Pools[pool]) {
            revert UnauthorizedPool(pool);
        }

        // Apply slippage protection
        ILiquidityManager(liquidityManager).checkPoolAndGetCenterPrice(pool);

        // Perform swap to OLAS
        olasAmount = _performSwap(secondToken, secondTokenAmount, feeTierOrTickSpacing);
    }

Then it will invoke _performSwap on BuyBackBurnerBalancer.sol:

    /// @dev Performs swap for OLAS on Slipstream CL DEX.
    /// @param secondToken Second token address.
    /// @param secondTokenAmount Second token amount.
    /// @param tickSpacing Tick spacing.
    /// @return olasAmount Obtained OLAS amount.
    function _performSwap(address secondToken, uint256 secondTokenAmount, int24 tickSpacing)
        internal
        virtual
        override
        returns (uint256 olasAmount)
    {
        IERC20(secondToken).approve(swapRouter, secondTokenAmount);

        ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
            tokenIn: secondToken,
            tokenOut: olas,
            tickSpacing: tickSpacing,
            recipient: address(this),
            deadline: block.timestamp,
            amountIn: secondTokenAmount,
            amountOutMinimum: 1,
            sqrtPriceLimitX96: 0
        });

        // Swap tokens
        olasAmount = ISwapRouter(swapRouter).exactInputSingle(params);
    }

The function will try to swap secondToken for olas token via exactInputSingle:

function exactInputSingle(ExactInputSingleParams calldata params)
        external
        payable
        override
        checkDeadline(params.deadline)
        returns (uint256 amountOut)
    {
        amountOut = exactInputInternal(
            params.amountIn,
            params.recipient,
            params.sqrtPriceLimitX96,
            SwapCallbackData({
                path: abi.encodePacked(params.tokenIn, params.tickSpacing, params.tokenOut),
                payer: msg.sender
            })
        );
        require(amountOut >= params.amountOutMinimum, "Too little received");
        refundETH();
    }

As we can see after swap is succesfully executed the function will invoke refundETH to send back any eth that is in the contract (it is not neccesarry that eth is provided by the caller of the swap function):

function refundETH() public payable override nonReentrant {
        if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance);
    }

The function uses safeTransferETH which will send all eth balance to the msg.sender (BuyBackBurnerBalancer aka BuyBackBurnerProxy in our case):

    function safeTransferETH(address to, uint256 value) internal {
        (bool success,) = to.call{value: value}(new bytes(0));
        require(success, "STE");
    }

So how this can be exploited ?

The exploit is very simple.

Malicious user can frontrun buyBack function and transfer some eth to the pool on Slipstream.

After protocol swap occur since eth balance would be bigger than 0 the function will try to send all available eth to our protocol and since BuyBackBurnerBalancer does not have functionality to receive eth the swap will revert with STE error. Which is proved in PoC below.

The fallback in BuyBackBurnerProxy is not enough which I will explain below and also prove in the PoC provided.

Let’s go step by step:

  1. safeTransferETH does to.call{value: value}(new bytes(0)) — i.e. an external call to the proxy with empty calldata and non-zero value. This is an ordinary ETH transfer + external call.
  2. The EVM delivers that call to the proxy address. The proxy has a fallback() external payable, so it accepts the external call and starts executing its fallback.
  3. Inside the proxy fallback protocol do an assembly delegatecall into the implementation, forwarding the same calldata (empty) and the same msg.value.
  4. Because the incoming calldata is empty, the implementation’s fallback/receive handler is what gets executed by the delegatecall.
  5. Since implementation does not define a receive() or a payable fallback(), so the Solidity-generated behavior for an empty-calldata call with non-zero msg.value is to revert. Thus the delegatecall fails (returns false).
  6. The proxy fallback sees the delegatecall failed and therefore reverts.
  7. Because the proxy reverted, the original to.call{value:…} in safeTransferETH returns success == false, and require(success, “STE”) triggers a revert in safeTransferETH. The transfer fails and no ETH is credited anywhere.

The malicious user can just call refundETH since it is public to get back his ETH after successfully prevented swap and therefore buying back olas token for the protocol so the attack will be at no significant cost to him and he can keep that repeating.

Impact:

Buying back olas token and transferring it to Bridge2Burner will be impossible and DoS-ed.

Recommended mitigation steps

In order to prevent this type of attack add receive or fallback functions to the implementation.

Proof of Concept

View detailed Proof of Concept


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

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 implementation contract behind the proxy lacks a receive or payable fallback function, so the router's ETH refund call reverts and the buy-back transaction fails.

Impact

Buying back OLAS and transferring it to Bridge2Burner can be repeatedly blocked, causing a denial of service at little cost to the attacker.

What the attacker needed

Attacker can front-run the buy-back transaction; small amount of ETH for the front-run; buy-back routed through Slipstream

The fix

The implementation contract should add a receive or payable fallback function so it can accept ETH refunds.

How it was found

  1. Attacker front-runs the buy-back transaction and sends ETH to the Slipstream pool contract.
  2. The protocol's buy-back swap executes and the router calls refundETH because the pool now holds ETH.
  3. refundETH sends the ETH to the proxy, whose fallback delegatecalls the implementation with empty calldata and non-zero value.
  4. The implementation has no receive or payable fallback, so the delegatecall reverts and the proxy reverts.
  5. safeTransferETH sees the failed call and reverts with STE, undoing the swap.
  6. Attacker calls the public refundETH to recover the ETH, making the attack cheap to repeat.

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.

A smart contract can hold and send 'ETH', the currency of the Ethereum network. Here the swap router tries to send leftover ETH back to the protocol's contract, but that contract has no way to accept ETH, so the transfer fails and the whole buy-back transaction is undone. An attacker can make this happen on purpose by sending a tiny amount of ETH to the router first, which blocks the protocol from buying back its own token.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by mrMorningstar

View all

6 more disclosed reports, best first.

More from Olas

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.