Skip to content

feat(sdk): check conditions on nested calldata before they are applied - #13

Merged
jfschwarz merged 1 commit into
mainfrom
nested-calldata-guard
Nov 25, 2026
Merged

jfschwarz merged 1 commit into
mainfrom
nested-calldata-guard

Conversation

@juliaklaue

Copy link
Copy Markdown

Adds a check to targetIntegrity for two kinds of condition whose safety depends on the contract that receives the call:

  • calldataMatches / abiEncodedMatches on calldata nested in a bytes parameter
  • a bitmask on a bytes value that expects the last bytes it checks to be zero

Most such permissions are fine. The new docs page, Nested Calldata (general/nested-calldata), explains the edge case and what to check on the receiving contract.

Acknowledging a checked condition. The error (ReadingIntegrityError) links the docs page and reports an acknowledgement. Once the receiving contract is checked, the condition passes with:

  • targetIntegrity(targets, { acknowledged: [...] }), or
  • "acknowledged": [...] in the permissions posted to the Roles app.

An acknowledgement covers that condition on one function of one target. The same condition elsewhere, or a changed condition, is checked again.

Roles app:

  • planApplyRole runs the check on every condition it adds. Conditions already on chain are left alone.
  • The diff page shows the error as a notice instead of failing.
  • The permissions API and page pass acknowledged through.

Also: conditionHash now uses ethers' sha256 instead of Node's crypto (same output), so the check runs in the browser too.

Tests: 348 SDK tests pass, including new ones for the check, acknowledgements and their scope, and the bitmask rule. The 24 app tests pass, and the app builds. Type errors in the SDK swaps files and the app (ChainIcon, derivePermissions.test) are the same as on main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DvEkN8jKo5TwdxzerGzeoG

targetIntegrity now also rejects two kinds of condition whose safety
depends on the contract receiving the call:

- calldataMatches / abiEncodedMatches on calldata nested in a `bytes`
  parameter
- a bitmask on a `bytes` value that expects the last bytes it checks to
  be zero

The error links a new docs page, general/nested-calldata, which says
what to check, and reports an acknowledgement. Once checked, a condition
passes with `acknowledged: [acknowledgement]`, in targetIntegrity's
options or in the permissions posted to the Roles app. An acknowledgement
covers the condition on one function of one target only. The app runs
the check on every condition it adds and shows the error on the diff
page.

conditionHash now hashes with ethers' sha256 (same output), so the check
also runs in the browser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DvEkN8jKo5TwdxzerGzeoG
@jfschwarz
jfschwarz merged commit 62498cd into main Nov 25, 2026
2 checks passed
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