Fix reentrancy effort-limit bypass in FlowTransactionScheduler - #618
Merged
Conversation
Address review feedback: extract self.config.priorityEffortLimit[txData.priority]! into a local variable used by both the assert condition and its message. make generate for the embedded contract assets.
Adds a test-only ReentrantHandler whose resolveView() attempts to reenter schedule() while the outer schedule() call is still in flight, trying to stuff two 9000-effort high-priority transactions into a 15000-effort slot. With the checks-effects-interactions fix, the outer call reserves its slot capacity before the handler callback runs, so the nested schedule fails the effort estimate and the whole transaction is rolled back atomically. Verified that this test fails against the pre-fix contract. - test-only ReentrantHandler in TestFlowScheduledTransactionHandler - schedule_transaction_reentrant.cdc test transaction - testScheduleReentrancy asserting failure and full slot rollback - make generate for the embedded assets
turbolent
approved these changes
Aug 4, 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.
Fix a reentrancy vector in
schedule()where slot capacity was only reservedafter the handler callback ran. A handler's
resolveView()could reenterschedule()and fit additional transactions into a slot whose capacity wasalready spoken for, bypassing the per-priority effort limit.
This ports the fix already deployed via onflow/flow-core-contracts-internal#7.
Changes
addTransaction) before invoking the handler callbackin
schedule(), following checks-effects-interactionsaddTransaction()that the per-priority slottotal never exceeds the configured effort limit
testScheduleReentrancy) with a test-onlyReentrantHandlerthat attempts to nest aschedule()call; verified tofail against the pre-fix contract
Related: onflow/flow-core-contracts-internal#7