# Stale checkpoint or mapping not cleared

Expiry, transfer, or freeze paths that leave delegation, pending, or address records stale

_Area: DeFi accounting and math bugs. Seen in 3 disclosed reports; latest 2025-07-03. Updated 2026-11-09._

## How it works
A function that is supposed to save or clear state writes a value derived from state it has already mutated, or clears only some of the records that point at an owner. The assumption that breaks is that the function is idempotent and that every mapping is cleaned together. On a second call, or after an ownership change, the saved value is overwritten with a zeroed/derived value, or a resolution mapping still points at the old owner. The stale record then outlives the event that should have invalidated it.

## Where it shows up
- Freeze/unfreeze or pause paths that write a "pending" value from current config on every call [E1](https://bugbountylibrary.com/r/cantina%3Aaave_may2024%3A3.1.1.md)
- Transfer/burn paths that mutate ownership before updating delegation or checkpoint arrays [E2](https://bugbountylibrary.com/r/c4%3A2025-05-blackhole%3AM-14.md)
- Registries with separate ownership and resolution mappings (name_to_addr, addr_to_name) [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md)
- Cleanup loops that pop entries in place without advancing the index [E2](https://bugbountylibrary.com/r/c4%3A2025-05-blackhole%3AM-14.md)
- Getters guarded by an is_expired check that a fresh re-registration bypasses [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md)

## How to review
For each state-saving or cleanup function, ask: is it safe to call twice, and does it clear every mapping that references the old owner? The invariant: after any freeze, transfer, burn, or expiry, no stored value or mapping may still reflect pre-event state, and re-invoking the function must not overwrite a saved value with a derived one. Trace the order of ownership mutation versus bookkeeping updates; any ownerOf lookup after zeroing will misclassify the token [E2](https://bugbountylibrary.com/r/c4%3A2025-05-blackhole%3AM-14.md). Enumerate every mapping a registry keeps and check each mutation path clears all of them [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md).

## How finders spotted it
- Read the modified setReserveFreeze, noticed the unconditional _pendingLtv assignment, and reasoned about repeated calls by different admin roles [E1](https://bugbountylibrary.com/r/cantina%3Aaave_may2024%3A3.1.1.md)
- Read the moveTokenDelegates cleanup loop alongside transferFrom ordering, noticing _removeTokenFrom zeroes owner before the delegation update [E2](https://bugbountylibrary.com/r/c4%3A2025-05-blackhole%3AM-14.md)
- Compared register_domain against set_name cleanup, saw only name_to_token was removed on re-registration, then wrote an end-to-end test asserting stale getter results [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md)

## Variants seen
- Pending-value overwrite on repeated freeze [E1](https://bugbountylibrary.com/r/cantina%3Aaave_may2024%3A3.1.1.md)
- Checkpoint corruption from ownership-zeroing before delegation update [E2](https://bugbountylibrary.com/r/c4%3A2025-05-blackhole%3AM-14.md)
- Partial mapping cleanup on domain re-registration after expiry [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md)

## Impact and severity
E1 blocks collateral use by restoring LTV to 0 on unfreeze. E2 corrupts delegation history. E3 misdirects transfers to the previous owner's address, causing loss of funds [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md). Severity rises with how far the stale record reaches: fund misdirection and permanent delegation corruption are high; a blocked config path is medium.

## Why fixes fail
E3 shows expiry cleanup implemented in one function but not the re-registration path, so the guard is bypassed once a fresh expiry is set [E3](https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md).

## Evidence
- E1: https://bugbountylibrary.com/r/cantina%3Aaave_may2024%3A3.1.1.md
- E2: https://bugbountylibrary.com/r/c4%3A2025-05-blackhole%3AM-14.md
- E3: https://bugbountylibrary.com/r/c4%3A2025-01-initia-move%3AM-01.md
