Skip to content

test reentrancy guard on store + ERC721/ERC1155 recipient paths#471

Open
thedavidmeister wants to merge 1 commit intomainfrom
2026-05-07-issue-309-reentrancy-per-path-tests
Open

test reentrancy guard on store + ERC721/ERC1155 recipient paths#471
thedavidmeister wants to merge 1 commit intomainfrom
2026-05-07-issue-309-reentrancy-per-path-tests

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

Summary

Flow.flow carries nonReentrant and the LibFlow.flow NatSpec names four reentrancy entry points. PR #446 covers ERC20/ERC777-style reentrancy via a malicious token. This adds tests for the remaining three:

  1. Malicious interpreter store: MaliciousReenteringStore.set re-enters flow.flow. Etched at the framework's STORE address. Storage slots from the deployed contract are copied across so the etched code retains its evaluable.
  2. Malicious ERC721 recipient: MaliciousReenteringRecipient.onERC721Received re-enters. The framework's TOKEN_B is etched with StubERC721WithReceiverHook so the underlying safeTransferFrom call propagates into the recipient hook (the standard mock token does not call the hook).
  3. Malicious ERC1155 recipient: same shape via StubERC1155WithReceiverHook at TOKEN_C and onERC1155Received.

Mutation verified: dropping nonReentrant from Flow.flow makes all three new tests fail; reverting passes.

Replaces the closed PR #440 (NatSpec-only enumeration). Closes #309.

Test plan

  • all 3 tests pass under current code
  • mutation: drop nonReentrant → all 3 fail

🤖 Generated with Claude Code

The `Flow.flow` `nonReentrant` guard has four documented entry points
(LibFlow.sol:142). PR #446 covers ERC20/ERC777-style reentrancy via a
malicious token. This adds tests for the remaining three:

1. Malicious interpreter store: `MaliciousReenteringStore.set` re-enters
   `flow.flow`. Etched at the framework's STORE address.
2. Malicious ERC721 recipient: `MaliciousReenteringRecipient
   .onERC721Received` re-enters. The framework's TOKEN_B is etched
   with `StubERC721WithReceiverHook` so the underlying
   `safeTransferFrom` call propagates into the recipient hook.
3. Malicious ERC1155 recipient: same shape via
   `StubERC1155WithReceiverHook` at TOKEN_C and `onERC1155Received`.

Mutation verified: dropping `nonReentrant` from `Flow.flow` makes all
three new tests fail; reverting passes.

Closes #309.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@thedavidmeister has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 53 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 341eaa03-67af-4225-96ef-83985b370bf3

📥 Commits

Reviewing files that changed from the base of the PR and between ceaea3c and 470fe7b.

📒 Files selected for processing (5)
  • test/concrete/MaliciousReenteringRecipient.sol
  • test/concrete/MaliciousReenteringStore.sol
  • test/concrete/StubERC1155WithReceiverHook.sol
  • test/concrete/StubERC721WithReceiverHook.sol
  • test/src/concrete/Flow.transfer.t.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-07-issue-309-reentrancy-per-path-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

[A23-6] [LOW] LibFlow.flow reentrancy surface needs per-path tests

1 participant