KillSwitch early-return in strategy causes vault-to-adapter asset leakage, mis-accounting, and deallocation DOS
When a strategy's killSwitch is enabled, its allocate() and deallocate() functions return early without moving or approving tokens, even though the vault has already sent assets to the adapter. This strands funds on the adapter, hides them from realAssets(), and makes later deallocations revert, causing mis-accounting and a denial of service on exits.
Originally disclosed on Immunefi
- Disclosed after under an hour
58035 sc high killswitch early return in strategy causes vault to adapter asset leakage mis accounting and deallocation dos
Submitted on Oct 30th 2025 at 06:43:50 UTC by @IronsideSec for Audit Comp | Alchemix V3
- Report ID: #58035
- Report Type: Smart Contract
- Report severity: High
- Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/MYTStrategy.sol
- Impacts:
- Permanent freezing of funds
Description
Brief/Intro
When killSwitch is enabled on strategies inheriting MYTStrategy, allocate() returns early without refunding tokens. Because the vault transfers assets to the adapter before invoking allocate(), assets are stranded on the adapter, realAssets() excludes them, allocations remain unchanged, and subsequent deallocations revert (no approvals). This creates an immediate asset mismatch, eventual realized loss on next accrual, and a denial-of-service on exiting via deallocate.
Vulnerability Details
- The vault sends assets to the adapter before calling
allocate():
572:589:lib/vault-v2/src/VaultV2.sol
SafeERC20Lib.safeTransfer(asset, adapter, assets);
(bytes32[] memory ids, int256 change) = IAdapter(adapter).allocate(data, assets, msg.sig, msg.sender);
// ... caps checks using 'change' ...
- Strategy
allocate()returns early underkillSwitch, but does not refund:
113:121:src/MYTStrategy.sol
if (killSwitch) {
return (ids(), int256(0));
}
require(assets > 0, "Zero amount");
uint256 oldAllocation = abi.decode(data, (uint256));
uint256 amountAllocated = _allocate(assets);
// ...
- Strategy
deallocate()also early-returns underkillSwitch, never setting approvals required by the vault’s subsequenttransferFrom:
130:145:src/MYTStrategy.sol
if (killSwitch) {
return (ids(), int256(0));
/* ... */
}
require(assets > 0, "Zero amount");
uint256 oldAllocation = abi.decode(data, (uint256));
uint256 amountDeallocated = _deallocate(assets);
// ...
- The example strategy reports only ERC4626 position as
realAssets()and ignores idle tokens stranded on the adapter:
43:45:src/strategies/mainnet/PeapodsUSDC.sol
function realAssets() external view override returns (uint256) {
return vault.convertToAssets(vault.balanceOf(address(this)));
}
- Proof-of-concept (non-reverting) shows:
- Vault calls
allocate()→ assets move to adapter. killSwitchearly-return → allocation unchanged.- Adapter holds raw USDC;
realAssets()remains 0. - Vault’s token balance decreases exactly by the allocated amount.
- Vault calls
69:109:src/test/strategies/PeapodsUSDCStrategy.t.sol
function test_killSwitch_allocate_leaks_assets_and_misaccounts_no_revert() public {
uint256 amountToAllocate = 1_000 * 10 ** testConfig.decimals;
vm.prank(admin);
IMYTStrategy(strategy).setKillSwitch(true);
bytes32 id = IMYTStrategy(strategy).adapterId();
uint256 initialVaultTokenBal = TokenUtils.safeBalanceOf(USDC, vault);
uint256 initialAdapterTokenBal = TokenUtils.safeBalanceOf(USDC, strategy);
uint256 initialAlloc = IVaultV2(vault).allocation(id);
uint256 initialRealAssets = IMYTStrategy(strategy).realAssets();
assertEq(initialAdapterTokenBal, 0, "adapter start bal");
assertEq(initialRealAssets, 0, "realAssets start");
assertEq(initialAlloc, 0, "alloc start");
vm.startPrank(allocator);
IVaultV2(vault).allocate(strategy, abi.encode(initialAlloc), amountToAllocate);
vm.stopPrank();
assertEq(TokenUtils.safeBalanceOf(USDC, strategy), amountToAllocate, "adapter raw assets");
assertEq(IMYTStrategy(strategy).realAssets(), 0, "realAssets still zero");
assertEq(IVaultV2(vault).allocation(id), initialAlloc, "alloc unchanged");
assertEq(
TokenUtils.safeBalanceOf(USDC, vault),
initialVaultTokenBal - amountToAllocate,
"vault token bal decreased"
);
}
Why this is dangerous:
- Funds are effectively stuck on the adapter until owner action, and vault exits via
deallocate()revert due to missing approvals. realAssets()excludes the stranded tokens, so the nextaccrueInterest()realizes a loss (share price drop) despite funds not actually being deployed.- Allocations and caps remain inconsistent (no increase in allocation despite asset movement), undermining vault risk controls.
Impact Details
- Loss realization: Next accrual sets
totalAssetsto a value excluding stranded tokens → share price decreases, harming depositors. - Exit DOS: Vault
deallocate()reverts (adapter didn’t approve), preventing liquidity retrieval during emergency. - Allocation/cap inconsistency: Allocations unchanged while assets moved, weakening risk caps and accounting invariants.
- Governance/safety friction: Enabling
killSwitch(intended for emergencies) paradoxically leaks funds to the adapter and blocks emergency exits.
Severity: High.
Recommended Remediation
- In
allocate()whenkillSwitch == true, refund immediately to the vault and return zero change:
if (killSwitch) {
address asset_ = IVaultV2(address(MYT)).asset();
IERC20(asset_).transfer(msg.sender, assets); // msg.sender is the vault
return (ids(), int256(0));
}
- In
deallocate()whenkillSwitch == true, approve the vault to pull and return the correct negative change (or avoid early-return and perform approvals first):
if (killSwitch) {
address asset_ = IVaultV2(address(MYT)).asset();
IERC20(asset_).approve(msg.sender, assets);
uint256 oldAllocation = abi.decode(data, (uint256));
uint256 newAllocation = oldAllocation - assets;
return (ids(), int256(newAllocation) - int256(oldAllocation));
}
- Count idle tokens in
realAssets()to avoid loss realization when funds are temporarily held idle on the adapter (strategy-specific):
function realAssets() external view override returns (uint256) {
return vault.convertToAssets(vault.balanceOf(address(this)))
+ TokenUtils.safeBalanceOf(address(usdc), address(this));
}
References
- Vault transfers then calls
allocate:
572:589:lib/vault-v2/src/VaultV2.sol
SafeERC20Lib.safeTransfer(asset, adapter, assets);
(bytes32[] memory ids, int256 change) = IAdapter(adapter).allocate(data, assets, msg.sig, msg.sender);
// ...
- Strategy
allocate()killSwitch early-return:
113:121:src/MYTStrategy.sol
if (killSwitch) {
return (ids(), int256(0));
}
// ...
- Strategy
deallocate()killSwitch early-return:
130:145:src/MYTStrategy.sol
if (killSwitch) {
return (ids(), int256(0));
/* ... */
}
// ...
- Strategy
realAssets()excludes idle:
43:45:src/strategies/mainnet/PeapodsUSDC.sol
function realAssets() external view override returns (uint256) {
return vault.convertToAssets(vault.balanceOf(address(this)));
}
- PoC test (non-reverting, calls
VaultV2.allocate()):
69:109:src/test/strategies/PeapodsUSDCStrategy.t.sol
function test_killSwitch_allocate_leaks_assets_and_misaccounts_no_revert() public {
// ...
}
Link to Proof of Concept
https://gist.github.com/IronsideSec/52387980717c94bdd092cfa847883fce
Proof of Concept
Proof of Concept
- create a file src/test/PermissionedProxy.t.sol and paste the POC from gist : https://gist.github.com/IronsideSec/52387980717c94bdd092cfa847883fce
- then run forge t --mt test_killSwitch_allocate_leaks_assets_and_misaccounts_no_revert -vvvv
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 killSwitch early-return paths in allocate() and deallocate() skip the token refund and approval steps that the vault's transfer-then-call flow depends on.
Impact
Funds could be stuck on the adapter until the owner acts, the next accrual may realise a loss through a share price drop, and vault deallocate() reverts, blocking emergency exits.
What the attacker needed
Admin enables killSwitch; allocator calls vault allocate()
The fix
The strategy should refund assets to the vault in allocate() under killSwitch, approve the vault in deallocate() under killSwitch, and count idle tokens in realAssets().
How it was found
- Enable the killSwitch on the strategy as the admin.
- Call the vault's allocate() for the strategy as the allocator.
- Observe the adapter now holds the raw tokens while realAssets() stays zero and the allocation is unchanged.
- Observe the vault's token balance decreased by the allocated amount.
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 vault passes money to a strategy contract, which is meant to invest it. A safety switch called killSwitch is supposed to stop the strategy, but here it makes the strategy return without doing anything, so the money sits in the wrong place and the vault's records no longer match reality. Later attempts to pull the money back fail, so users could be unable to withdraw.
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.