58334 sc medium incorrect function selectors

Submitted on Nov 1st 2025 at 10:49:39 UTC by @teoslaf1 for Audit Comp | Alchemix V3arrow-up-right

  • Report ID: #58334

  • Report Type: Smart Contract

  • Report severity: Medium

  • Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/utils/ZeroXSwapVerifier.sol

  • Impacts:

    • Contract fails to deliver promised returns, but doesn't lose value

Description

Description

The ZeroXSwapVerifier.sol contract contains hardcoded function selectors that do not match the deployed 0x Settler contract. When legitimate 0x swap calldata is passed for verification, the library immediately reverts because none of the selector checks match the real function signatures.

Although the team stated the verifier is not currently active, it is part of the intended future 0x integration path (for atomic deallocation or direct quote flows). Once integrated, the issue would immediately render the system unable to perform swaps.

Root Cause:

  • All 9 function selectors are incorrect and do not match the actual deployed contract.

  • The library does not use the canonical 0x deployer (0x00000000000004533Fe15556B1E086BB1A72cEae) to dynamically resolve the latest Settler contract.

  • The design hardcodes both selectors and function formats, which are version-specific and subject to change.

Impact:

Wrong selectors: All valid calldata rejected Static Settler assumptions: Breaks on next 0x upgrade No deployer query: Cannot adapt to protocol changes Architectural incompatibility: Future 0x swaps impossible to verify

Recommendation

Update all function selectors to match the deployed 0x Settler contracts. The correct selectors can be obtained by:

  1. Query the 0x deployer for current Settler address

  2. Calculate selectors from the actual contract interface

  3. Verify selectors exist in deployed bytecode

Additional Context (from 0x documentation)

According to the official 0x Settler documentation: https://github.com/0xProject/0x-settler?tab=readme-ov-file#actions

“See ISettlerActions for a list of actions and their parameters. The list of actions, their names, the type and number of arguments, and the availability by chain is NOT STABLE. Do not rely on ABI encoding/decoding of actions directly.”

This means that any implementation hardcoding function selectors or assuming a fixed ABI (as in ZeroXSwapVerifier) is inherently brittle and will break with future Settler updates.

Proof of Concept

Proof of Concept

Manual Verification

Step 1: Find Deployed Contract

Source: https://github.com/0xProject/0x-settler/blob/master/README.md#how-do-i-find-the-most-recent-deployment

Step 2: Calculate Correct Selector

Source: https://github.com/0xProject/0x-settler/blob/master/src/interfaces/ISettlerTakerSubmitted.sol

Step 3: Compare

  • Correct: 0x1fff991f

  • ZeroXSwapVerifier has: 0xcf71ff4f

  • Result: MISMATCH

Step 4: Verify in Bytecode

For convenience, run the provided verification script:

Was this helpful?