Repository navigation
fix(rpc)!: reject keys outside the schema of an eth_getProof answer - #5458
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reader of an
eth_getProofanswer 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
AccountProofandStorageProofschemas of execution-apis setadditionalProperties: false.So an answer holds only its seven properties, and a slot only
key,valueandproof.accountProofOfJsonandstorageProofOfJson, the readers ofExecution/Rpc/Proof.lean, ignored any other key.So
execution.trie.verify_account_proofaccepted an answer that the schema does not allow.The idea
onlyKeys, which rejects an object with a key outside a list,nullvalues included.The readers of
eth_simulateV1overrides already used it; it moves fromExecution/Rpc/Simulate.leantoSerialization/JsonRpc.lean.onlyKeysandhasOnly, 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_keyandstorageProofOfJson_unknown_keystate the rejection;onlyKeys_mkObjkeeps the round trip of the reader.Example
The answer of the fixture
get-account-proof-with-storage.ioat 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
TrieErrorcode 0, the code of every reading error of this export.For reviewers
null, such as"address": null, still fails as a missing field.hasOnlykeeps its result and its callers; only its body now readsoutsideField.Checks
lake build EthLib EthLib.Proofs EthLib.Exports --wfail: passed.check-decls: 0 findings;check-accessors: no new site;check-theoremsandcheck_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 checkon the changed test: passed.BREAKING CHANGE:
execution.trie.verify_account_proofraisesTrieErrorfor an answer or a slot with a key outside its schema.In Lean,
onlyKeysisEthLib.Serialization.JsonRpc.onlyKeys, where it wasEthLib.Execution.Rpc.onlyKeys.🤖 Generated with Claude Code