Skip to content

Detector: Reentrancy via env.invoke_contract before effects (#793) - #864

Open
odogu01 wants to merge 1 commit into
Centurylong:mainfrom
odogu01:detector/reentrancy-invoke-before-effects
Open

Detector: Reentrancy via env.invoke_contract before effects (#793)#864
odogu01 wants to merge 1 commit into
Centurylong:mainfrom
odogu01:detector/reentrancy-invoke-before-effects

Conversation

@odogu01

@odogu01 odogu01 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

Adds a new static-analysis detector reentrancy_invoke to flag when env.invoke_contract is called before storage effects (writes), violating the Checks-Effects-Interactions (CEI) pattern.

Closes #793

Changes

  • New rule tooling/sanctifier-core/src/rules/reentrancy_invoke.rs — analyzes public contract functions for invoke_contract calls that precede storage mutations (set/update/remove/try_update). Skips #[cfg(test)] modules and does not flag when effects already precede the invoke.
  • Finding code SANCT_REENTRANCY_INVOKE added to finding_codes.rs
  • Registration in rules/mod.rs default rule set
  • Documentation docs/detectors/reentrancy_invoke.md with vulnerable example, fix, and detection technique
  • Tests 9 unit tests covering all acceptance criteria
  • differential-corpus.json updated with the new rule mapping

Acceptance Criteria

  • Flags invoke_contract before effects
  • No FP when effects precede
  • Skips test modules
  • No FP when no state writes exist

…fore state effects

Adds a static-analysis detector that flags when env.invoke_contract is
called before storage writes (set/update/remove/try_update) in a public
contract function, violating the Checks-Effects-Interactions (CEI) pattern.

Closes Centurylong#793
@github-actions github-actions Bot added rust Pull requests that update rust code area: core-engine sanctifier-core static analysis engine area: docs Documentation and guides area: testing Tests, benchmarks, fuzzing size/m labels Jul 27, 2026
@Gbangbolaoluwagbemiga

Copy link
Copy Markdown
Contributor

@odogu01, please resolve conflicts and make sure all ci passes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core-engine sanctifier-core static analysis engine area: docs Documentation and guides area: testing Tests, benchmarks, fuzzing rust Pull requests that update rust code size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detector: Reentrancy via env.invoke_contract before effects

2 participants