Repository navigation
fix: detect interprocedural storage TOCTOU through qualified Self:: calls - #454
Merged
luhrhenz merged 2 commits intoAug 26, 2026
Conversation
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 interprocedural storage TOCTOU detection for qualified
Self::callsProblem
cargo test -p soroban-guard-checksfailed on main:The check was registered and running, but it returned 0 findings on a fixture that clearly demonstrates the split-function TOCTOU pattern:
claim()reads storage viaalready_claimed(), then writes storage viado_claim(). Because the read and write happen in different functions, the guard inclaim()does not protect the write indo_claim().Root Cause
In
collect_ops_visitor,visit_expr_callextracted the callee name using:get_ident()only returnsSomefor simple, unqualified identifiers (e.g.,foo()). For qualified calls likeSelf::already_claimed(&env)orSelf::do_claim(&env), the path isPathwith multiple segments, soget_ident()returnsNone. As a result, the visitor never descended into called helper functions, and their storage operations were never collected. With no writes collected, the read/write matching logic had nothing to flag.Fix
Changed callee extraction to use the last segment of the path:
This works for both:
foo()→ segmentfooSelf::foo()→ segmentfooNow the interprocedural visitor correctly traverses into helper functions and collects their storage reads/writes, allowing the TOCTOU pattern to be detected.
Verification
cargo test -p soroban-guard-checks --libResult: 741 passed; 0 failed
The previously failing test now passes, and all existing tests continue to pass.
Files Changed
crates/checks/src/interprocedural_storage_toctou.rscloses #441