# Missing constraint in default_dict_copy

Kakarot's default_dict_copy never finalized transient_storage/storage/valid_jumpdests dicts, letting a malicious prover set arbitrary default values for uninitialized keys.

- Payout: Audit contest
- Severity: high
- Program: Kakarot
- Found by: g\_x\_w
- Disclosed: 2024-12-10
- Write-up quality: 8/10
- Original: https://github.com/code-423n4/2024-09-kakarot-findings/issues/91
- Library page: https://bugbountylibrary.com/r/c4%3A2024-09-kakarot%3AH-03
- Tags: area:web3 domain:web3 impact:funds-loss impact:integrity kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:misconfiguration

**Target:** CairoZero account/storage dict handling in Kakarot zkEVM
**Root cause:** default_dict_copy picks squashed_start.prev_value as the new dict's default_value without asserting it equals the intended default (0); the finalize constraint `dict_accesses_start.prev_value = default_value` is never applied to transient_storage, storage, or valid_jumpdests.
**Steps:**
1. Read account.cairo L83 and dict.cairo L83: transient_storage created via `default_dict_new(0)` but never `default_dict_finalize`d.
2. Observe Account.copy() calls `default_dict_copy(self.transient_storage_start, self.transient_storage)`.
3. In default_dict_copy, `dict_squash` runs but does not constrain the first prev_value; `default_value = squashed_start.prev_value` is prover-controlled.
4. Prover crafts DictAccess list where all prev_values equal an arbitrary chosen value; squash passes and the new dict inherits that default.
5. Subsequent uninitialized reads from the copied dict return the attacker-chosen value instead of 0, corrupting storage/jumpdest semantics.
**How found:** Code-reading against CairoZero docs: noticed default_dict_new requires default_dict_finalize, then traced that default_dict_copy only squashes and reuses the first prev_value as default without the finalize assertion.
**Exploitation:** A malicious prover fabricates the DictAccess trace so uninitialized storage/transient_storage/valid_jumpdests keys read attacker-chosen values, potentially enabling unauthorized fund access or contract state manipulation in the upper-level EVM logic.
**Insight:** When auditing zkVM/Cairo dict code, check every default_dict_new for a matching default_dict_finalize; copy helpers that derive default_value from squashed_start.prev_value silently trust prover-supplied values unless separately finalized.

