cross-contract-state

Solid

Detect cross-contract state inconsistency — two or more contracts sharing a token, oracle, or price feed where one mutates and another reads stale, cached state that drifts from source of truth, non-atomic multi-contract updates, accounting that assumes synchronized state, and reads during callbacks. Activate whenever a system spans multiple contracts that must agree on a value but update at different times.

AI & Automation 38 stars 5 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 82/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Cross-contract state consistency detection ## When this applies Trigger on any of: - A value (price, total supply, share rate, debt) lives in contract A but is read by B - Cached/mirrored state (`cachedRate`, `lastTotalAssets`) that must be refreshed - Multi-contract operations that mutate several contracts non-atomically - Modules/plugins/hooks that read core state mid-update (read-during-callback) - Proxy + implementation, or vault + strategy, or controller + market splits - Accounting assuming "A and B are always in sync" ## Detection patterns ### Stale read of another contract's mid-update state (HIGH) ```solidity // Vault.deposit() transfers to Strategy, then: uint256 tvl = strategy.totalAssets(); // ← strategy hasn't accounted the deposit yet shares = amount * totalSupply / tvl; // wrong denominator ``` **Signal:** B reads A while A's update is incomplete (or vice versa). Share/price math uses a denominator that's about to change, letting an attacker mint mispriced shares. This is the read-only-reentrancy family generalized to ordinary call ordering. ### Cached value drift (HIGH) ```solidity uint256 public cachedPrice; // updated by poke() function valueOf(uint256 amt) external view returns (uint256) { return amt * cachedPrice / 1e18; // ← may be hours stale } ``` **Signal:** a mirrored value with no freshness guarantee or no atomic refresh-before-use. Trades/loans price off a cache that diverged from the source contract. ### Non-atomic mu...

Details

Author
iktok90-design
Repository
iktok90-design/ai-smart-contract-auditor
Created
1 weeks ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category