Skip to content

Recover folded mapping slots in keccak assumptions - #1104

Merged
msooseth merged 4 commits into
mainfrom
fix/keccak-literal-slots-1103
Oct 19, 2026
Merged

msooseth merged 4 commits into
mainfrom
fix/keccak-literal-slots-1103

Conversation

@gustavo-grieco

@gustavo-grieco gustavo-grieco commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes #1103.

Compiler-folded mapping slots reach the solver as literals without keccak assumptions, allowing symbolic accesses to alias unrelated mappings. Recover these preimages in concreteKeccaks so the existing assumption generation handles them. This proves that b[k] stays zero after writing a[3], while preserving the validated counterexample at key 3 when reading a[k].

Recovery uses a shared table for keys below 256 and also tries query literals, with mapping slots and field offsets below 256. Unrecoverable literals retain their existing behavior.

The storage-key fuzzer now emits folded mapping hashes. A new property compares symbolic reads against the expected value across concrete stores and explicit writes, including field offsets. Coverage checks require both same-mapping and different-mapping cases.

Validation: all 846 selected tests passed using Stack with GHC 9.10.3, -Werror=name-shadowing, Z3, and Bitwuzla (seed 1103). Both folded-slot fuzz groups passed 200 cases each, with 51.5% same-mapping and 48.5% different-mapping coverage. The Solidity regression preserved the validated counterexample at key 3. The local run excluded CVC5, geth differential tests, and the external Yul corpus.

The branch includes current main, including the abstractArith API required by Echidna's compatibility build.

Checklist

  • tested locally
  • added automated tests
  • updated the docs (not needed for this fix)
  • updated the changelog

@gustavo-grieco gustavo-grieco changed the title Fix spurious keccak aliases with folded mapping slots Recover folded mapping slots in keccak assumptions Oct 12, 2026
@msooseth
msooseth force-pushed the fix/keccak-literal-slots-1103 branch from 08bd4c0 to 4c85a80 Compare October 19, 2026 09:11
msooseth and others added 2 commits October 19, 2026 12:04
…ions

Recovery of compiler-folded slots now also finds array preimages, follows
parent slots through known and recovered hashes, and targets hashes
written as parent slots into keccak inputs. Keccak results are bounded
from above so field offsets cannot wrap to small slots.

Add properties that write storage slots in one keccak representation and
read them in another, checking for spurious counterexamples and false
proofs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@msooseth
msooseth merged commit 47f3ea3 into main Oct 19, 2026
8 of 9 checks passed
@msooseth
msooseth deleted the fix/keccak-literal-slots-1103 branch October 19, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More spurious counter examples

2 participants