# Truncated or colliding identifier spoof

Identity from truncated hashes, colliding series, or unreserved id ranges trusted as unique

_Area: Smart contract access control and control flow. Seen in 3 disclosed reports; latest 2024-06-24. Updated 2026-11-09._

## How it works
A contract treats a derived identifier as unique when it is not. Three ways the assumption breaks: a future id is computed by truncating a timestamp (first-of-month), so many inputs map to one key; a hash is cast down to 160 bits, so many preimages map to one address; a sequential id range is minted from a configurable start without reserving it, so another minter can occupy the same ids. In each case a downstream registry or `require` enforces uniqueness on the colliding key, and the attacker who registers it first blocks or impersonates the victim [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)[E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md)[E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md).

## Where it shows up
- Future maturity/epoch ids built from `block.timestamp` with truncation (e.g. first-of-month) feeding a factory that allows one pool per (adapter, maturity) [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)
- `msg.sender` validated by recomputing an address from `keccak256(...)` cast to `uint160` instead of querying the factory's `getPool` [E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md)
- Sale or mint loops starting at a configurable `currentId` with no reservation of the range [E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md)
- Any `require(!_exists(id))` or `create` that reverts on duplicate keys, downstream of a predictable id [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)[E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md)

## How to review
For every identifier used as a uniqueness key, ask: how many inputs produce it, and who can register it first?
- Truncated timestamps: is the id granularity coarser than the uniqueness window? Can an outsider pre-create the next id? [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)
- Hash-to-address: is the full hash compared, or truncated? Prefer querying the canonical factory (`getPool`) over recomputation [E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md)
- Sequential ranges: is the range reserved/enforced on-chain, or merely assumed exclusive? [E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md)
Invariant: no party outside the intended owner can occupy an id the contract will later require to be free, and identity checks must be preimage-resistant, not birthday-resistant.

## How finders spotted it
- Read `onSponsorWindowOpened` and `getFutureMaturity`, noticed maturity truncates to first-of-month, and that `SpaceFactory` enforces one pool per adapter/maturity — making collisions predictable [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)
- Read the CREATE2-style derivation in `CallbackLib.validateCallback`, saw the `keccak256` result cast to `uint160` (96 bits lost), and reasoned via the birthday paradox that collisions become feasible [E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md)
- Read the `buy()` mint loop alongside OZ `_mint`'s `require(!_exists(tokenId))`, noticing the sale assumes exclusive ownership of its id range without enforcing it [E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md)

## Variants seen
- Pre-registration DoS: attacker creates a colliding series to brick rolling [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)
- Spoofing: birthday collision on a truncated hash to impersonate a pool and drain approvals [E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md)
- Range overlap: another minter occupies sale ids, bricking `buy()` and locking funds [E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md)

## Impact and severity
Bricked rolling and locked funds [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md), potential drain of approved tokens via spoofed pool [E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md), permanently reverting sales with funds stuck [E3](https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md). Impact rises when the colliding id gates fund movement or an approval, and when the id is predictable far in advance so an attacker can pre-register cheaply [E1](https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md)[E2](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md).

## Evidence
- E1: https://bugbountylibrary.com/r/sherlock%3A2022-11-sense%3AH-4.md
- E2: https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AM-05.md
- E3: https://bugbountylibrary.com/r/c4%3A2022-12-escher%3AM-10.md
