Skip to content
DoS Audit finding Intermediate

It is possible to prevent lowering the deposit cap by front running

The setDepositCap function requires the new cap to be at least the contract's current token balance, so an attacker can front-run an admin who is lowering the cap by depositing enough tokens to exceed the intended new cap, causing the admin's transaction to revert. This prevents the admin from ever decreasing the deposit cap, a partial denial of service.

PotEater Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

57208 sc insight it is possible to prevent lowering the deposit cap by front running

Submitted on Oct 24th 2025 at 11:46:06 UTC by @PotEater for Audit Comp | Alchemix V3

Description

Brief/Intro

The function setDepositCap can be DoS'd by front-running when setting the deposit cap to a lower value.

Vulnerability Details

The function setDepositCap implements a check that ensures the depositCap is always >= IERC20(myt).balanceOf(address(this)));

This makes the function vulnerable to a front-running/griefing attack where the attacker can simply front-run the admin, depositing a huge amount of tokens into the contract so it hits the deposit cap.

Now when the admin tx completes, it will revert, because the input value is lower than the contract's MYT balance. After that, the attacker can freely withdraw the tokens immediately without any restrictions or fees. Increasing likelihood of this griefing attack and creating ideal conditions.

Impact Details

The impact is partial Denial of Service. The admin would be only able to increase the deposit cap, not decrease.

References

https://github.com/alchemix-finance/v3-poc/blob/a192ab313c81ba3ab621d9ca1ee000110fbdd1e9/src/AlchemistV3.sol#L237

Proof of Concept

Proof of Concept

Add this function to the AlchemistV3.t.sol test file:

PoC:

Solidity
    function test_PoC() external {
        // A: admin calls setDepositCap

        uint256 amount = 101e18;
        vm.startPrank(address(0xbeef));
        SafeERC20.safeApprove(address(vault), address(alchemist), amount + 100e18);

        // B: Attacker front-runs the admin and deposits tokens

        alchemist.deposit(amount, address(0xbeef), 0);
        vm.stopPrank();

        vm.prank(address(0xdead));
        vm.expectRevert();

        // C: Now admin tx completes, but reverts, because attacker front-ran
        alchemist.setDepositCap(100e18);

        // D: Now the attacker withdraws his tokens, remaining prepared for another front-run
        vm.prank(address(0xbeef));
        alchemist.withdraw(amount, address(0xbeef), 1);
    }

The original report as published on Immunefi, by PotEater. 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

The setDepositCap function checks the new cap against the contract's live token balance, which an attacker can inflate just before the admin's transaction.

Impact

The admin can only increase the deposit cap, not decrease it, causing a partial denial of service.

What the attacker needed

Attacker can front-run admin transactions; attacker holds enough tokens to exceed the new cap

How it was found

  1. The admin prepares a transaction to lower the deposit cap.
  2. The attacker front-runs by depositing enough tokens to exceed the intended new cap.
  3. The admin's setDepositCap transaction reverts because the new cap is below the contract's balance.
  4. The attacker withdraws the deposited tokens, ready to repeat the attack.

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 deposit cap is a limit on how many tokens a contract will accept. The contract only lets the admin lower that limit if the contract's current token balance is already below the new limit. An attacker can quickly deposit tokens just before the admin's transaction, pushing the balance above the new limit so the admin's change fails. The attacker can then withdraw their tokens, ready to repeat the trick.

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 PotEater

View all

13 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.