AlchemistAllocator::allocate() and deallocate() do not enforce cap checks as intended
The allocate and deallocate functions in AlchemistAllocator calculate an adjusted cap value but never use it to limit the amount passed to the vault. An admin or operator could therefore allocate or deallocate more than the vault's absolute or relative caps allow.
Originally disclosed on Immunefi
- Disclosed after under an hour
56451 sc low alchemistallocator allocate and deallocate do not enforce cap checks as intended
Submitted on Oct 16th 2025 at 07:17:52 UTC by @joicygiore for Audit Comp | Alchemix V3
- Report ID: #56451
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/AlchemistAllocator.sol
- Impacts:
Description
Brief/Intro
The allocate() and deallocate() functions compute an adjusted value, but it is never used to enforce limits on the amount being allocated or deallocated. This may allow bypassing vault caps.
Vulnerability Details
In the following code snippets (marked with @>), adjusted is only calculated in memory and not applied to the actual allocation or deallocation:
// AlchemistAllocator::allocate()
function allocate(address adapter, uint256 amount) external {
// SNIP...
uint256 daoTarget = type(uint256).max;
@> uint256 adjusted = absoluteCap > relativeCap ? absoluteCap : relativeCap;
if (msg.sender != admin) {
// caller is operator
@> adjusted = adjusted > daoTarget ? adjusted : daoTarget;
}
// pass the old allocation to the adapter
bytes memory oldAllocation = abi.encode(vault.allocation(id));
vault.allocate(adapter, oldAllocation, amount);
}
// AlchemistAllocator::deallocate()
function deallocate(address adapter, uint256 amount) external {
// SNIP...
uint256 daoTarget = type(uint256).max;
@> uint256 adjusted = absoluteCap < relativeCap ? absoluteCap : relativeCap;
if (msg.sender != admin) {
// caller is operator
@> adjusted = adjusted < daoTarget ? adjusted : daoTarget;
}
// pass the old allocation to the adapter
bytes memory oldAllocation = abi.encode(vault.allocation(id));
vault.deallocate(adapter, oldAllocation, amount);
}
Impact Details
- Vault caps are not enforced, potentially allowing allocations or withdrawals to exceed design limits;
- Because calls require admin/operator privileges, the exploitable risk is limited, but it still constitutes a security best practices issue.
References
Caps: The funds allocation of the vault is constrained by an id-based caps system. An id is an abstract identifier for a common risk factor of some markets (a collateral, an oracle, a protocol, etc.). Allocation on markets with a common id is limited by absolute caps and relative caps. Note that relative caps are "soft" because they are not checked on withdrawals, they only constrain new allocations.
Proof of Concept
Proof of Concept
Add the following test to src/test/AlchemistAllocator.t.sol and run it:
function test_poc_Deallocate() public {
_magicDepositToVault(address(vault), user1, 150 ether);
vm.startPrank(admin);
allocator.allocate(address(mytStrategy), 150 ether);
bytes32 allocationId = mytStrategy.adapterId();
uint256 allocation = vault.allocation(allocationId);
uint256 absoluteCap = vault.absoluteCap((allocationId));
uint256 relativeCap = vault.relativeCap((allocationId));
require(allocation == 150 ether);
uint256 adjusted = absoluteCap < relativeCap ? absoluteCap : relativeCap;
// adjusted is only calculated, not enforced
assertEq(adjusted, 1 ether);
// execute deallocation exceeding adjusted amount ❌
allocator.deallocate(address(mytStrategy), adjusted * 150);
allocation = vault.allocation(allocationId);
(uint256 newTotalAssets, uint256 performanceFeeShares, uint256 managementFeeShares) = vault.accrueInterestView();
uint256 mytStrategyYieldTokenBalance = IMockYieldToken(mockStrategyYieldToken).balanceOf(address(mytStrategy));
uint256 mytStrategyYieldTokenRealAssets = mytStrategy.realAssets();
// verify all state state changes that happen after a deallocation
assertEq(mytStrategyYieldTokenBalance, 0);
assertEq(mytStrategyYieldTokenRealAssets, 0);
assertEq(newTotalAssets, 150 ether);
assertEq(performanceFeeShares, 0);
assertEq(managementFeeShares, 0);
assertEq(vault._totalAssets(), 150 ether);
assertEq(vault.firstTotalAssets(), 150 ether);
assertEq(allocation, 0);
vm.stopPrank();
}
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
Impact
Vault caps are not enforced, so allocations or withdrawals could exceed design limits, though the risk is limited because the calls require admin or operator privileges.
What the attacker needed
Admin or operator privileges
The fix
The functions should compare the requested amount against the adjusted cap and revert or clamp the amount before calling the vault.
How it was found
- Deposit funds into the vault as a user.
- As admin, allocate an amount to a strategy.
- Read the allocation, absolute cap and relative cap, and compute the adjusted cap.
- Call deallocate with an amount larger than the adjusted cap.
- Observe that the deallocation succeeds and the allocation becomes zero.
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 has caps that limit how much money can be put into or taken out of a particular strategy. The code works out the correct limit but then forgets to check the requested amount against it, so someone with special permissions can move more money than the rules allow.
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.