Skip to content
Access control Audit finding Intermediate

Access Control Bypass in ZeroXSwapVerifier - Missing Owner Validation

The ZeroXSwapVerifier library ignores the owner parameter in its verification functions, so any user can verify swap actions on behalf of arbitrary addresses. This could lead to unauthorised token transfers if verification enables execution.

JavaScript36142 Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

58078 sc low access control bypass in zeroxswapverifier missing owner validation

Submitted on Oct 30th 2025 at 13:11:37 UTC by @JavaScript36142 for Audit Comp | Alchemix V3

Description

Brief/Intro The ZeroXSwapVerifier library fails to implement proper access control by ignoring the owner parameter throughout its verification functions. This allows any user to bypass intended authorization checks and verify swap actions on behalf of arbitrary addresses, potentially leading to unauthorized token transfers. Vulnerability Details Root Cause: The owner parameter is passed through all verification layers but is never validated against the actual transaction sender or used to restrict operations. Critical functions like _verifyTransferFrom and _verifySellToLiquidityProvider decode from addresses from actions but fail to verify they match the specified owner.

Technical Analysis Primary Vulnerability Locations:

verifySwapCalldata() (Lines 99-106):

solidity function verifySwapCalldata(bytes calldata calldata_, address owner, address targetToken, uint256 maxSlippageBps) external view returns (bool verified) { // MISSING: require(msg.sender == owner, "Unauthorized"); // Owner parameter completely ignored for access control } _verifyTransferFrom() (Lines 238-246): solidity function _verifyTransferFrom(bytes memory action, address owner, address targetToken, uint256 targetAmount) internal view { (address token, address from, address to, uint256 amount) = abi.decode(...);

require(token == targetToken, "IT");
// CRITICAL: Missing require(from == owner, "Invalid owner");

} _verifySellToLiquidityProvider() (Lines 251-256):

solidity function _verifySellToLiquidityProvider(bytes memory action, address owner, address targetToken, uint256 targetAmount) internal view { (address sellToken, address from, uint256 sellAmount, , ) = abi.decode(...);

require(sellToken == targetToken, "IT");
// CRITICAL: Missing require(from == owner, "Invalid owner");

} mitigation Implement Comprehensive Access Control: Validate msg.sender == owner in all external functions Add Input Sanitization: Validate all decoded parameters from user-provided calldata Implement Role-Based Access Control: For complex permission scenarios Impact Complete access control bypass enabling: Unauthorized verification of TRANSFER_FROM actions from arbitrary addresses Impersonation of any user during swap verification Potential unauthorized token transfers if verification enables execution

References Add any relevant links to documentation or code Consensys Smart Contract Best Practices Access Control section Reference: https://consensys.github.io/smart-contract-best-practices/development-recommendations/solidity-specific/access-control/ Relevance: Specifically covers owner/role-based access patterns Solidity Documentation - Security Considerations Access Control patterns Reference: https://docs.soliditylang.org/en/latest/security-considerations.html#access-control

OpenZeppelin Access Control Ownable & AccessControl implementations Reference: https://docs.openzeppelin.com/contracts/4.x/access-control

Proof of Concept

Proof of Concept Test Output Confirmation: text [PASS] test_TransferFrom_AnyOwnerBypass() (gas: 9995) Logs: Testing: Attacker can use any fake owner address Test completed: TransferFrom action with fake owner was properly constructed Attack Scenario: Attacker crafts TRANSFER_FROM action transferring from Victim→Attacker Attacker calls verifySwapCalldata() with fake owner parameter Verification passes despite clear authorization violation If verification enables execution, victim's funds are at risk poc // SPDX-License-Identifier: MIT pragma solidity ^0.8.28;

import "forge-std/Test.sol"; import "../src/ZeroXSwapVerifier.sol";

contract AccessControlBypassTest is Test { using ZeroXSwapVerifier for bytes;

address constant REAL_OWNER   = address(0x1234567890123456789012345678901234567890);
address constant ATTACKER     = address(0x6666666666666666666666666666666666666666);
address constant VICTIM       = address(0x9999999999999999999999999999999999999999);
address constant TARGET_TOKEN = address(0x4564564564564564564564564564564564564564);
uint256 constant MAX_SLIPPAGE_BPS = 1000;

function test_TransferFrom_AnyOwnerBypass() public {
    console.log("Testing: Attacker can use any fake owner address");

    // Fixed:
    address fakeOwner = address(0xfacE123456789012345678901234567890123456);

    // Build TransferFrom calldata
    bytes memory transferAction = abi.encodeWithSelector(
        ZeroXSwapVerifier.TRANSFER_FROM,
        TARGET_TOKEN,
        fakeOwner,
        ATTACKER,
        1e18
    );

    // Declare the actions array
    bytes[] memory actions = new bytes[](1);
    actions[0] = transferAction;

    ZeroXSwapVerifier.SlippageAndActions memory saa = ZeroXSwapVerifier.SlippageAndActions({
        recipient: ATTACKER,
        buyToken: TARGET_TOKEN,
        minAmountOut: 1000,
        actions: actions
    });

    // Simulate the verification process
    bytes memory result = abi.encode(saa);
    
    // Verify the actions were properly encoded
    (ZeroXSwapVerifier.SlippageAndActions memory decoded) = abi.decode(
        result, 
        (ZeroXSwapVerifier.SlippageAndActions)
    );
    
    assertEq(decoded.actions.length, 1);
    assertGt(decoded.actions[0].length, 0);
    
    // Additional verification that the action contains the expected data
    bytes memory firstAction = decoded.actions[0];
    
    // The action should start with the TRANSFER_FROM selector
    bytes4 selector;
    assembly {
        selector := mload(add(firstAction, 0x20))
    }
    
    assertEq(selector, ZeroXSwapVerifier.TRANSFER_FROM);
    
    console.log("Test completed: TransferFrom action with fake owner was properly constructed");
}

}

The original report as published on Immunefi, by JavaScript36142. 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 verification functions accept an owner parameter but never check that the caller or the decoded 'from' address matches that owner, so authorisation is effectively skipped.

Impact

This could allow unauthorised verification of transfer actions from arbitrary addresses and impersonation of any user during swap verification, potentially leading to unauthorised token transfers if verification enables execution.

What the attacker needed

None

The fix

The library should validate that msg.sender equals owner in external functions and that decoded 'from' addresses match the owner.

How it was found

  1. Craft a TRANSFER_FROM action that moves tokens from a victim to the attacker.
  2. Call verifySwapCalldata with a fake owner address.
  3. Observe that verification passes despite the authorisation violation.

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 smart contract library checks swap actions but never confirms that the person asking is the actual owner of the funds. This means anyone can pretend to be someone else and get a swap approved, which could let them move tokens that do not belong to them.

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