fix(keychain): reject dirty recipient word in is_call_allowed - #91
Merged
onbjerg merged 1 commit intoSep 14, 2026
Merged
Conversation
is_call_allowed accepted a recipient-constrained call whose first ABI word had non-zero upper bytes, taking the recipient from the low 20 bytes regardless. tempo_alloy's call_scopes_allow and the on-chain precompile both reject such a word before comparing the recipient, so the client could report a call as allowed that the chain rejects. Require the upper 12 bytes to be zero, and add a regression test.
onbjerg
approved these changes
Sep 14, 2026
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.
Summary
KeyRestrictions.is_call_alloweddocuments that its resolution order "matches the Rust implementation", but for a recipient-constrained selector it extracts the recipient from the low 20 bytes of the first ABI word and ignores the upper 12 bytes:The Rust it mirrors does not. Both the client-side reference
tempo_alloy::call_scopes_allowand the on-chain precompile (AccountKeychain::validate_call_scope_for_transaction) require the upper 12 bytes of that word to be zero before comparing the recipient, and deny the call otherwise:So for calldata whose first word has non-zero upper bytes but whose low 20 bytes happen to match an allowed recipient,
is_call_allowedreturnsTruewhile the chain rejects the call. A caller that trusts the helper to pre-check an access key would build and sign a transaction that then reverts on-chain.Fix
Add the same zero-upper-bytes guard before extracting the recipient, so the client agrees with
call_scopes_allowand the precompile.Test
Adds
test_recipient_word_dirty_upper_bytes_deniedfor the dirty-upper-bytes case; the existing tests only exercised well-formed, zero-padded recipient words.