# Selector collision privileged bypass

Fallback handler selectors colliding with privileged base functions, routing innocent calls to privilege setters

_Area: Smart contract access control and control flow. Seen in 3 disclosed reports; one confirmed bounty: $400,000; latest 2024-03-02. Updated 2026-11-17._

## How it works
Solidity dispatches on the first 4 bytes of calldata only. A wallet that extends itself through `fallback()` forwards unknown selectors to a pluggable handler contract. Nothing checks that a handler's function signatures differ from the base contract's. A handler function can be crafted so its selector equals a privileged base function's selector (4 bytes is cheap to brute-force). A user calling the innocent-looking handler instead lands on the privileged base function, executing with the caller's own authority. The broken assumption: that a handler's name tells you which code runs. Only the selector decides.

## Where it shows up
- `fallback`/`receive` that forwards unknown selectors to a handler or module contract.
- Wallet/account contracts whose base functions include privilege setters (`setAddrPrivilege`-style).
- Any dispatch that trusts the selector alone without checking target code identity.
- Handler registration paths where handler signatures are never compared against base selectors.

## How to review
Enumerate every selector reachable through the fallback/handler path and every privileged selector on the base contract. The invariant: the two sets must be disjoint, or the handler path must not be able to reach base storage or privilege. Check whether handler registration validates signatures against base selectors, and whether a colliding selector would execute base code with the caller's authority rather than the handler's.

## How finders spotted it
- Reasoned from Solidity's selector-based dispatch: since fallback handlers extend the wallet via `fallback()`, any handler function selector can be made to collide with a base contract function, hiding a privileged call behind an innocent signature [E3](https://bugbountylibrary.com/r/c4%3A2023-05-ambire%3AM-01.md).

## Variants seen
- Crafted handler selector colliding with a privileged base function, silently invoking a privilege setter [E3](https://bugbountylibrary.com/r/c4%3A2023-05-ambire%3AM-01.md).

## Impact and severity
A colliding handler selector can invoke a privileged setter such as `setAddrPrivilege`, handing full wallet control to an attacker [E3](https://bugbountylibrary.com/r/c4%3A2023-05-ambire%3AM-01.md). Severity is high whenever the reached base function moves funds or grants privilege; the impact is bounded only by what that function can do.

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **Enzyme Finance** (GasRelayPaymasterLib) (version not stated): Enzyme Finance Missing Privilege Check Bugfix Review. Report: https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-enzyme-finance-privilege-check.md

## Evidence
- E1: https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-enzyme-finance-privilege-check.md
- E2: https://bugbountylibrary.com/r/sherlock%3A2024-03-arrakis%3AH-1.md
- E3: https://bugbountylibrary.com/r/c4%3A2023-05-ambire%3AM-01.md
