feat(lint): add protected-vars - #15766
Merged
Merged
Conversation
Honor @Custom:security write-protection annotations across inherited entry points, modifiers, and resolved internal call paths. Report externally callable writes when the exact annotated function or modifier is not reachable.
Resolve typed calls and most-derived overrides, propagate storage aliases through control flow and assembly, and fail closed on invalid protections.
mattsse
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr and
stevencartavia
as code owners
July 15, 2026 14:52
mattsse
marked this pull request as draft
July 15, 2026 16:10
mattsse
marked this pull request as ready for review
July 15, 2026 16:52
94 tasks
mablr
requested changes
Jul 15, 2026
figtracer
reviewed
Jul 15, 2026
Require protection calls to dominate every protected write and model modifier continuations at reachable placeholders. Correct Yul storage-pointer retargeting, persistent storage writes, and resolved call-return roots.
mablr
reviewed
Jul 16, 2026
Merge only reachable continuing try clauses and exhaustive switch arms so synthetic skip paths do not invalidate dominating guards or storage-pointer retargeting.
mablr
reviewed
Jul 17, 2026
Track normal completion across helper calls, recursive summaries, loop exits, and modifier continuations so unreachable protected writes are not reported.
mablr
self-requested a review
July 17, 2026 15:48
mablr
reviewed
Jul 17, 2026
Keep each Yul tuple output's storage roots separate when binding declarations and assignments. This avoids attributing writes through an ordinary returned slot to unrelated protected outputs. Amp-Thread-ID: https://ampcode.com/threads/T-019f896c-fd1a-745b-be37-de6016df1dbb Co-authored-by: Amp <amp@ampcode.com>
mablr
enabled auto-merge (squash)
July 22, 2026 11:54
figtracer
approved these changes
Jul 22, 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.
This adds the high-severity
protected-varslint from #14381. It enforces Solidity's@custom:security write-protectionannotations by tracing writes from externally callable leaf-contract entry points through reachable modifier continuations, resolved internal and library calls, storage aliases, returned storage locations, collection mutations, and resolvable assembly slots.Protection is tracked as must-flow state at each write, so a guard must dominate that occurrence across branches, short-circuit expressions, loops, returns, and modifier expansion. The analysis also retargets Yul storage-pointer
.slotassignments, distinguishes persistentsstorefrom transienttstore, and uses resolved Yul return summaries without contaminating results with unrelated argument roots. Exact overload signatures and virtual dispatch remain respected, while malformed or unresolved annotations stay unsatisfied.The companion Book documentation is in foundry-rs/book#1982, with the dominance and Yul follow-up in foundry-rs/book#1995. This PR was implemented with Codex assistance across code, tests, and lint documentation, then independently reviewed and corrected by a fresh Codex context.