Skip to content

fix(rpc)!: reject keys outside the schema of an eth_getProof answer - #5458

Merged
tcoratger merged 2 commits into
masterfrom
review-5449-rpc-proof-keys
Dec 4, 2026
Merged

tcoratger merged 2 commits into
masterfrom
review-5449-rpc-proof-keys

Conversation

@tcoratger

Copy link
Copy Markdown
Collaborator

The reader of an eth_getProof answer rejects an answer or a slot that holds a key outside its schema, where it ignored the key.
This supersedes #5449 by @ilitteri, whose commit it carries unchanged, with one review commit on top.

The problem

The AccountProof and StorageProof schemas of execution-apis set additionalProperties: false.
So an answer holds only its seven properties, and a slot only key, value and proof.
accountProofOfJson and storageProofOfJson, the readers of Execution/Rpc/Proof.lean, ignored any other key.
So execution.trie.verify_account_proof accepted an answer that the schema does not allow.

The idea

  • Each reader first checks its keys with onlyKeys, which rejects an object with a key outside a list, null values included.
    The readers of eth_simulateV1 overrides already used it; it moves from Execution/Rpc/Simulate.lean to Serialization/JsonRpc.lean.
  • The review commit makes onlyKeys and hasOnly, the Boolean check beside it, share one search, outsideField: the first field whose name is none of the given names.
    So the JSON-RPC layer keeps one mechanism for an object limited to some keys.
  • accountProofOfJson_unknown_key and storageProofOfJson_unknown_key state the rejection; onlyKeys_mkObj keeps the round trip of the reader.

Example

The answer of the fixture get-account-proof-with-storage.io at block 60, with one more property:

  • {"extra": "0x0"} or {"extra": null} on the answer: answer: unknown key extra, where it was ignored.
  • {"extra": "0x0"} on a slot: slot: unknown key extra.

Each is TrieError code 0, the code of every reading error of this export.

For reviewers

  • A key that the schema names with value null, such as "address": null, still fails as a missing field.
  • hasOnly keeps its result and its callers; only its body now reads outsideField.

Checks

  • lake build EthLib EthLib.Proofs EthLib.Exports --wfail: passed.
  • check-decls: 0 findings; check-accessors: no new site; check-theorems and check_theorems_baseline.py: nothing new.
  • proof-coverage --check, rule-history --check, gen-bindings --check: passed.
  • check_layers.py, check_lean_layout.py, check_comment_code.py, soundness_facts.py --check: passed.
  • pytest -k 'proof or simulate or payload_bodies or generic': 10278 passed, 7 skipped.
  • ruff check, ruff format --check, check_python_comments.py, check_docstrings.py, ty check on the changed test: passed.

BREAKING CHANGE: execution.trie.verify_account_proof raises TrieError for an answer or a slot with a key outside its schema.
In Lean, onlyKeys is EthLib.Serialization.JsonRpc.onlyKeys, where it was EthLib.Execution.Rpc.onlyKeys.

🤖 Generated with Claude Code

ilitteri and others added 2 commits December 4, 2026 12:45
The AccountProof and StorageProof schemas of execution-apis set
additionalProperties to false, so an answer or a slot holds no other
property. The reader of an answer read the properties it knows and
ignored any other, so verify_account_proof accepted such an answer.

Both readers now check their keys first with onlyKeys, as the readers
of block and account overrides do. onlyKeys moves next to fields in
Serialization/JsonRpc.lean, with the lemmas onlyKeys_mkObj and
onlyKeys_rejects. The round trip of the reader still holds, and
accountProofOfJson_unknown_key and storageProofOfJson_unknown_key state
the rejection.

BREAKING CHANGE: execution.trie.verify_account_proof raises TrieError
for an answer or a slot with a key outside its schema. In Lean,
onlyKeys is EthLib.Serialization.JsonRpc.onlyKeys, where it was
EthLib.Execution.Rpc.onlyKeys.
`hasOnly` and `onlyKeys` now both read the first field whose name is not
among the given names, `outsideField`, so the JSON-RPC layer has one
mechanism for an object limited to some keys.

The CHANGELOG and SOUNDNESS entries say which reader each theorem covers,
and the test docstring covers the cases of an unknown key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tcoratger
tcoratger merged commit f34f9ed into master Dec 4, 2026
7 checks passed
@tcoratger
tcoratger deleted the review-5449-rpc-proof-keys branch December 4, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants