Skip to content
Business logic Audit finding Beginner

AlchemistTokenVault::deposit() should use safeTransferFrom() instead of transferFrom(); AlchemistTokenVault::withdraw() should use safeTransfer() instead of transfer()

The vault calls the standard ERC20 transfer and transferFrom functions without checking their return value, and some tokens such as USDT do not return a boolean from these calls. An attacker cannot steal funds, but deposits and withdrawals with such tokens revert, making those tokens unusable in the vault.

joicygiore Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

56368 sc insight alchemisttokenvault deposit should use safetransferfrom instead of transferfrom alchemisttokenvault withdraw should use safetransfer instead of transfer

Submitted on Oct 15th 2025 at 07:08:20 UTC by @joicygiore for Audit Comp | Alchemix V3

Description

Brief/Intro

The ERC20.transfer() and ERC20.transferFrom() functions return a boolean value indicating whether the operation succeeded. Callers must check this return value to ensure that the transfer actually succeeded. Some tokens do not revert on failure and instead return false.

Vulnerability Details

As marked with @>, some tokens (e.g., USDT, BNB) do not fully implement the EIP20 standard. Their transfer or transferFrom functions return void instead of a boolean. Calling these functions using the standard ERC20 function signature will always result in a revert.

JavaScript
    // AlchemistTokenVault::deposit()
    function deposit(uint256 amount) external {
        _checkNonZeroAmount(amount);
@>        IERC20(token).transferFrom(msg.sender, address(this), amount);
        emit Deposited(msg.sender, amount);
    }

    // AlchemistTokenVault::withdraw()
    function withdraw(address recipient, uint256 amount) external override onlyAuthorized {
        _checkNonZeroAddress(recipient);
        _checkNonZeroAmount(amount);


@>        IERC20(token).transfer(recipient, amount);
        emit Withdrawn(recipient, amount);
    }

Impact Details

For tokens that do not comply with the latest EIP20 standard (e.g., USDT, BNB), even if the transfer returns false, the contract may consider it successful, resulting in failed operations. This makes such tokens unusable within the protocol.

References

https://github.com/alchemix-finance/v3-poc/blob/b2e2aba046c36ff5e1db6f40f399e93cd2bdaad0/src/AlchemistTokenVault.sol#L26-L43

Proof of Concept

Proof of Concept

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

JavaScript
    import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

    function test_poc_AlchemistTokenVault() public {
        address depositor = makeAddr("depositor");
        uint256 amount = 1000e6;

        vm.createSelectFork(vm.envString("MAINNET_RPC_URL"));
        
        address usdt = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
        
        vm.prank(owner);
        vault = new AlchemistTokenVault(usdt, alchemist, owner);

        // Uniswap: USDT pool
        address usdtWhale = 0x5754284f345afc66a98fbB0a0Afe71e0F007B949;
        vm.prank(usdtWhale);
        IERC20(usdt).safeTransfer(depositor, amount); 
        assertEq(IERC20(usdt).balanceOf(depositor), amount);


        vm.startPrank(depositor);
        IERC20(usdt).forceApprove(address(vault), amount);
        vm.expectRevert();
        vault.deposit(amount);  // ❌ Call reverts
        vm.stopPrank();
        assertEq(IERC20(usdt).balanceOf(address(vault)), 0);
    }

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 contract uses the plain IERC20 transfer and transferFrom interfaces instead of a safe wrapper that tolerates tokens which do not return a boolean.

Impact

Tokens that do not return a boolean, such as USDT, cannot be deposited or withdrawn, so the vault is unable to operate with them.

What the attacker needed

Vault configured with a non-standard ERC20 token

The fix

The deposit and withdraw functions should use SafeERC20's safeTransferFrom and safeTransfer so that tokens with non-standard return values work correctly.

How it was found

  1. Deploy the vault with USDT as the token.
  2. Give a depositor some USDT and approve the vault to spend it.
  3. Call deposit with the amount and observe that the call reverts.

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.

ERC20 is a common standard for tokens on Ethereum. The standard says transfer functions should return true or false to say whether the transfer worked, but some popular tokens like USDT return nothing at all. If a contract calls them expecting a true/false answer, the call fails, so the vault cannot accept or send those tokens.

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

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.