Skip to content

fix(cheatcodes): check executing code access - #18358

Draft
0xKarl98 wants to merge 3 commits into
foundry-rs:masterfrom
0xKarl98:fix/cheatcode-frame-access
Draft

0xKarl98 wants to merge 3 commits into
foundry-rs:masterfrom
0xKarl98:fix/cheatcode-frame-access

Conversation

@0xKarl98

@0xKarl98 0xKarl98 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fork-mode cheatcode access currently checks the caller address, allowing delegated code to borrow the caller's permission.

  • Check both the execution context and the effective code address, including DELEGATECALL, CALLCODE and EIP-7702 delegation targets.
  • Require authorized ancestors before granting CREATE/CREATE2 children cheatcode access, so an authorized factory cannot pass permission to children created through untrusted code.
  • Preserve frame identities across nested execution and restore them on return or revert. Reuse frame buffers for nested execution and snapshots, and skip repeated checks for the same address. Keep explicit vm.allowCheatcodes grants effective at the point of use.
  • Add regressions for delegated calls, child creation, fork selection and isolated execution. The script regression rejects an unauthorized broadcast while allowing the intended transaction to complete.

Require fork-mode cheatcode permission for both the execution context and
the effective code address. Track initialized frame identities across
nested execution and restore the suspended caller when execution ends.

Only inherit CREATE/CREATE2 permissions through authorized ancestors to
prevent untrusted code from obtaining access through a local factory.
Cover delegated execution, EIP-7702, nested creation and script broadcasts.
Skip duplicate allowlist lookups when the caller, execution context and
code share an address. Resolve delegated bytecode only for call frames;
constructors already execute initcode under the created address.

Reuse an empty frame buffer for independent executions and inherited
snapshots. Restore full parent identities after nested failures and keep
one spare buffer across recursive scopes. Cover buffer reuse and mixed
nesting, and extend the fork regression to recursive constructor failures.
Keep direct and delegated denial checks in the shared lifecycle suite
and remove the redundant script envOr probe. Preserve isolated execution
and dry-run/broadcast coverage.

This branch has not been deployed

No deployments
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.

1 participant