Skip to content
Access control Audit finding Intermediate

Cap Bypass in AlchemistAllocator.deallocate() Allows Over-Deallocation Beyond Computed Limits

The deallocate function in AlchemistAllocator computes an adjusted cap limit but does not enforce it before calling vault.deallocate, allowing an operator to deallocate more than the cap allows. An attacker with operator privileges could over-deallocate funds, potentially draining strategies beyond risk parameters.

pxng0lin Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

58642 sc low cap bypass in alchemistallocator deallocate allows over deallocation beyond computed limits

#58642 [SC-Low] Cap Bypass in `AlchemistAllocator.deallocate()` Allows Over-Deallocation Beyond Computed Limits

Submitted on Nov 3rd 2025 at 19:01:07 UTC by @pxng0lin for Audit Comp | Alchemix V3

Description

Brief / Intro

AlchemistAllocator.deallocate() computes adjusted cap limits based on absoluteCap, relativeCap, and daoTarget but fails to enforce them before calling vault.deallocate(). The deallocate() function computes an adjusted cap limit but fails to enforce it with require(amount <= adjusted), allowing over-deallocation.

While oldAllocation is correctly passed for vault state updates, the unused adjusted computation implies incomplete safety logic—caps are fetched and calculated but ignored, creating a configuration mismatch where governance-set limits are bypassed. Allowing admin/operators to deallocate amounts exceeding the intended caps, potentially draining strategies beyond risk management parameters.

Details

  • The function calculates adjusted = absoluteCap < relativeCap ? absoluteCap : relativeCap and further adjusts for operators with daoTarget.
  • However, no validation ensures amount <= adjusted before proceeding to vault.deallocate(adapter, oldAllocation, amount).
  • This creates a mismatch between the computed safety logic and actual execution, allowing unrestricted deallocations.

Impact

  • Direct effect: Strategies can be deallocated beyond their computed caps, leading to over-exposure or fund drains.
  • Scope: Admin or authorised operators can trigger this; affects any strategy with set caps. While admins have full rights and may bypass intentionally, operators are intended to be limited—making the lack of enforcement a delegation failure.
  • Funds at risk: Potential loss of allocated funds if deallocations exceed intended limits.

Risk Breakdown

  • **Severity: Critical, configuration bypass in allocation management leads to protocol insolvency.
  • Exploit difficulty: Low; requires admin/operator privileges.
  • Reach: All strategies; repeated over-deallocations impacts the entire allocation system.

Recommendation

Add validation before calling vault.deallocate():

Solidity
require(amount <= adjusted, "Deallocation exceeds adjusted cap");

This enforces the computed cap limits.

References

  • Source file: src/AlchemistAllocator.sol
  • Prior audit scan: reports/cantina_competition_alchemix_may2025.pdf (checked; no duplicate finding)

Proof of Concept

Proof of Concept

  • Foundry test: testDeallocateExceedsCap()
  • Add the following test to the existing test suite: src/test/AlchemistAllocator.t.sol
  • Run the following command in the terminal forge t --mt testDeallocateExceedsCap -vvv
  • The test sets absolute cap to 25 ether, allocates 50 ether as operator, then deallocates 50 ether (exceeding the 25 ether adjusted cap), showing the bypass succeeds.

Test Code

    function testDeallocateExceedsCap() public {
        // Step 1: fund and allocate 50 ether while cap is the default 200 ether
        _magicDepositToVault(address(vault), user1, 100 ether);
        vm.startPrank(admin);
        allocator.allocate(address(mytStrategy), 50 ether);
        vm.stopPrank();

        bytes32 allocationId = mytStrategy.adapterId();
        uint256 initialAllocation = vault.allocation(allocationId);
        emit log_named_uint("allocation before cap reduction", initialAllocation);
        assertEq(initialAllocation, 50 ether);

        // Step 2: governance reduces the absolute cap down to 25 ether
        vm.startPrank(curator);
        bytes memory idData = mytStrategy.getIdData();
        _vaultSubmitAndFastForward(abi.encodeCall(IVaultV2.decreaseAbsoluteCap, (idData, 25 ether)));
        vault.decreaseAbsoluteCap(idData, 25 ether);
        vm.stopPrank();

        uint256 reducedCap = vault.absoluteCap(allocationId);
        emit log_named_uint("absolute cap after reduction", reducedCap);
        assertEq(reducedCap, 25 ether);

        // Step 3: operator is still able to deallocate the full 50 ether (cap bypass)
        vm.startPrank(operator);
        allocator.deallocate(address(mytStrategy), 50 ether);
        vm.stopPrank();

        uint256 finalAllocation = vault.allocation(allocationId);
        emit log_named_uint("allocation after operator deallocation", finalAllocation);
        assertEq(finalAllocation, 0);
    }

Result

Shell
[PASS] testDeallocateExceedsCap() (gas: 716870)
Logs:
  allocation before cap reduction: 50000000000000000000
  absolute cap after reduction: 25000000000000000000
  allocation after operator deallocation: 0

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

Impact

An operator could deallocate amounts exceeding the intended caps, potentially draining strategies beyond risk management parameters.

What the attacker needed

Operator privileges

How it was found

  1. Fund and allocate 50 ether while the cap is 200 ether.
  2. Governance reduces the absolute cap to 25 ether.
  3. Operator deallocates the full 50 ether, exceeding the 25 ether cap.

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.

This is a smart contract bug where a function calculates a safety limit but forgets to check it before moving funds. Someone with special permissions (an operator) can move more money than the limit allows, which could drain funds from a strategy.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by pxng0lin

View all

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

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.