# Validated-vs-used operand mismatch in accounting

Does the account, key, count, or token checked equal the one actually debited, credited, or read?

_Area: DeFi accounting and math bugs. Seen in 125 disclosed reports; one confirmed bounty: $560,000; latest 2026-06-14. Updated 2026-10-23._

## How it works
Accounting code assumes the operand it validates is the operand it later reads or writes. When a function takes a `user`/`owner` parameter beside `msg.sender`, keys storage by one hash helper, trusts a caller-supplied count, or reads a mutable config field at refund time, the two operands can diverge. The check passes on one identity, value, or key while the debit, credit, or lookup lands on another, so balances drift from reality and value moves to the wrong party. The core test: does the validated operand equal the used operand?

## Where it shows up
- Functions with both `msg.sender` and a `user`/`owner` parameter touching per-user state [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md)[E8](https://bugbountylibrary.com/r/cantina%3Asuperform_may2025%3A3.2.8.md)
- Settlement iterating a caller-supplied count that sits outside the hashed public inputs [E1](https://bugbountylibrary.com/r/dhl%3A20260614-aztecconnect.md)
- `remaining_accounts` entries driving state logic without a key check against the owning pool [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md)
- Transfer guards comparing only one half of a packed storage slot [E3](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AH-02.md)
- Collateral keyed by owner/minter instead of the specific vault or position [E6](https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md)
- Multiple hash helpers for one struct whose field lists differ [E6](https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md)
- Hand-rolled `transferFrom` reading/writing allowance under different keys [E4](https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-redacted-cartel-custom-approval-logic-bugfix-review.md)
- Refund paths reading a mutable denom/price instead of the escrowed value [E5](https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-06.md)
- Shared path parser reused for exactInput and exactOutput, where token order reverses [E7](https://bugbountylibrary.com/r/cantina%3Agauntlet_jun2025%3A3.2.2.md)

## How to review
For each function, list every state read and write and confirm they resolve to the same address, index, key, or count. Per-shape check:
- Identity: the account validated/burned equals the account credited/refunded [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md)[E8](https://bugbountylibrary.com/r/cantina%3Asuperform_may2025%3A3.2.8.md)
- Count: the count settled equals the count proven inside the commitment; confirm what the hash covers [E1](https://bugbountylibrary.com/r/dhl%3A20260614-aztecconnect.md)
- Account: caller-supplied accounts pass a key/PDA/registry check tying them to the owning pool [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md)
- Slot: both halves of a packed slot are checked, not just the net [E3](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AH-02.md)
- Key: the key written equals the key read; diff hash helpers field by field [E6](https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md)
- Allowance: the same (owner, spender) key is read and written in approve/transferFrom [E4](https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-redacted-cartel-custom-approval-logic-bugfix-review.md)
- Escrow: refunds use the value recorded at deposit, not current config [E5](https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-06.md)
- Direction: shared parsers handle direction-specific encoding [E7](https://bugbountylibrary.com/r/cantina%3Agauntlet_jun2025%3A3.2.2.md)

## Variants seen
- Debit `msg.sender`, redeem using `user` state [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md)
- Prove all slots, settle only `numRealTxs` [E1](https://bugbountylibrary.com/r/dhl%3A20260614-aztecconnect.md)
- Unverified `remaining_accounts[0]` bitmap flips tick bits [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md)
- Guard checks right slot only; left slot corrupts accounting [E3](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AH-02.md)
- Allowance read from recipient, written to spender [E4](https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-redacted-cartel-custom-approval-logic-bugfix-review.md)
- Refund denom changed mid-bid [E5](https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-06.md)
- Collateral counted per minter, visible to sibling vaults [E6](https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md)
- Storage keyed by `toHash()`, receipt looked up by `toTracingId()` [E6](https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md)
- exactOutput path parsed forward, swapping token roles [E7](https://bugbountylibrary.com/r/cantina%3Agauntlet_jun2025%3A3.2.2.md)
- Hook reads caller `account` balance instead of `owner` for cost basis [E8](https://bugbountylibrary.com/r/cantina%3Asuperform_may2025%3A3.2.8.md)

## Impact and severity
Drains of ETH backing and Treasury funds [E1](https://bugbountylibrary.com/r/dhl%3A20260614-aztecconnect.md)[E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md), inflated liquidity [E2](https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md), corrupted premium accounting [E3](https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AH-02.md), approval theft [E4](https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-redacted-cartel-custom-approval-logic-bugfix-review.md), escrow drain [E5](https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-06.md), double-counted collateral and trapped refunds [E6](https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md), slippage/accounting bypass [E7](https://bugbountylibrary.com/r/cantina%3Agauntlet_jun2025%3A3.2.2.md), fee miscalculation and div-by-zero DoS [E8](https://bugbountylibrary.com/r/cantina%3Asuperform_may2025%3A3.2.8.md). Severity rises when the mismatch is silent (no revert) and repeatable, letting an attacker amplify the drift. Impact claims are per-report, not generalized.

## Evidence
- E1: https://bugbountylibrary.com/r/dhl%3A20260614-aztecconnect.md
- E2: https://bugbountylibrary.com/r/sherlock%3A2024-11-autonomint%3AH-3.md
- E3: https://bugbountylibrary.com/r/c4%3A2023-11-panoptic%3AH-02.md
- E4: https://bugbountylibrary.com/r/blog%3Aimmunefi-com-blog-bug-fix-reviews-redacted-cartel-custom-approval-logic-bugfix-review.md
- E5: https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-06.md
- E6: https://bugbountylibrary.com/r/c4%3A2025-02-recall%3AH-03.md
- E7: https://bugbountylibrary.com/r/cantina%3Agauntlet_jun2025%3A3.2.2.md
- E8: https://bugbountylibrary.com/r/cantina%3Asuperform_may2025%3A3.2.8.md
