Smart contracts on Ethereum routinely call each other. A lending protocol reads a price from an oracle contract, and a token forwards execution to an "implementation" contract through a proxy. Whether a given call path is exploitable depends on facts about the other contract: which code sits behind an address, whether it guards against re-entry, and which storage it writes. Those facts change over time. Proxies are repointed to new code, oracle addresses are swapped, and owners rotate. A finding that was true at one block can be false a week later, and the reverse also happens.
Language models used as auditors fail here in two ways. They invent facts about callee contracts, such as functions that do not exist or guards that are absent. They also carry stale facts, either from pretraining on famous protocols or from an audit cached before an upgrade. We propose to make the model state every cross-contract claim as an explicit relational fact. Each fact is checked against a knowledge graph of the contract ecosystem in which every edge carries the range of blocks during which it held. Each surviving finding records the edges it depends on, so that an upgrade re-opens exactly the findings it could have invalidated.
Core Claim
The claim is narrow. Cross-contract LLM auditing should be grounded at the level of individual claims. Each claim is checked against a graph whose edges are versioned by block height, rather than against retrieved code snippets or an unversioned call graph. This should do two things. It should cut both fabricated and stale cross-contract claims, measurably, on cases where exploitability flips across a real upgrade. It should also let a system keep findings current under upgrades at a fraction of the cost of re-auditing everything.
The proposal is also a measurement study. To our knowledge, no benchmark separates "stale" from "fabricated" hallucination in code auditing, and we will build one.
Where This Sits
The cross-contract analysis literature motivates the setting.
- Lyu et al. build a dependency graph over 195,247 active contracts linked by delegated calls. They find that 38 vulnerable contracts put 28,786 others at risk. They treat the graph as a static artifact for a symbolic model checker. We add validity intervals and an LLM reasoner on top.
- Clairvoyance (Ye et al.) builds a cross-contract control-flow graph and uses symbolic execution to discard reentrancy reports blocked by five protective patterns: permission checks, state pre-computation, custom modifiers, locks, and checks-effects-interactions ordering. It reaches about 73.8% precision. It treats contract addresses as static configuration and cannot reason about intent where its solver gives up. We reuse its protective-pattern annotations as graph edges.
- xFuzz (Xue et al.) and SmartReco (Zhang et al.) supply the confirmation machinery. SmartReco's fuzzing seeded with on-chain history becomes our ground-truth oracle on forked chain state.
The LLM-auditing literature constrains the design.
- HMF (Li et al.) reports that standalone LLMs have below 20% precision on contract audits. It responds by banning the LLM from detection. We take this as a warning that free-text LLM findings cannot be trusted without an external check.
- GPTLENS (Hu et al.) has an LLM critic filter an LLM auditor's candidates on 13 single-contract CVEs. We keep its generate-then-filter shape but replace the LLM critic with a graph checker.
- SCALM (Li et al.) uses vector retrieval of bad practices and states that it cannot handle multi-contract or state-dependent flaws.
- SolDetector (Hu et al.) is the closest knowledge-graph work. It turns single Solidity files into an ontology queried with SPARQL. It has no inter-contract edges, no LLM, and no notion of time.
Three works supply methods.
- KISP (Thirukovalluru et al.) constrains a decoder with walks over the local graph neighborhood so it cannot emit relations that do not exist. We adapt this to restrict which callee functions and storage slots the model can name.
- StateMem (Can Agent Memory Systems Track Evolving State?) invalidates derived facts deterministically when a base fact changes. It also shows that models keep using stale facts even when the fresh fact is in context. This is our main reason not to trust "just give it the current code."
- Fact-duration modeling (Zhang and Choi) discounts confidence when a fact's predicted lifespan is shorter than its age. We use the same idea to estimate how quickly each edge type tends to change, and so to schedule re-checks.
Entity abstraction (Choudhary et al.) replaces names with opaque identifiers to suppress pretraining priors. It is a cheap competitor we must beat, not just cite.
Research Program
Block-versioned graph. The first artifact is a cross-contract knowledge graph built from transaction traces and storage reads over a fixed historical window.
- Nodes are deployed addresses, deduplicated code (following Lyu et al.), functions with their selectors, and storage slots.
- Edges cover several relations: a function calls a function at a resolved address, a proxy delegates to an implementation, a slot holds an address, a function writes a slot, and a function is protected by one of the five Clairvoyance patterns.
- Every edge carries the interval of blocks during which it held. For proxy and oracle pointers, the interval is closed by the storage write that changed it.
Constrained auditing. The auditor is a code LLM in GPTLENS's auditor role. It must express each candidate finding as an attack path, meaning a sequence of graph facts ending in an unsafe state change.
- During decoding, any mention of a callee function, slot, or guard is restricted to entities present in the graph at the audit block. This follows KISP's neighborhood restriction.
- After decoding, a checker verifies each fact at the audit block and checks that no protective-pattern edge blocks the path.
- Paths that pass are sent to seeded fuzzing on a fork of chain state at that block for confirmation.
- Paths that fail are labeled by cause. A path is fabricated if the fact never held. It is stale if the fact held at an earlier block. It is blocked if a guard edge exists.
Dependency-linked findings. Each confirmed finding stores the set of edges supporting it. When any of those edges closes, the finding is re-checked, as in StateMem's rechecker. Learned per-edge-type change rates, in the style of Zhang and Choi, decide how often unchanged but volatile edges, such as oracle pointers, get re-validated.
Upgrade-flip benchmark. The evaluation set is new. We take contract systems from the delegated-call dependency graph of Lyu et al., from the external-call contracts of xFuzz Dataset 2, and from SmartReco's DApp collection. In these we mine proxy and oracle retargeting events. For each event, we label exploitability before and after, with fuzzing on forked state as the oracle. The cases that matter are those whose label flips. A system that only reads current code can still get flips wrong if pretraining or a cached analysis leaks in. A system that ignores time gets every flip wrong in one direction.
Baselines
The naive reference point is Slither run with cross-file linking on the same contracts. On the 17,770-contract BigQuery set, Ye et al. report about 1.8% precision for it (3 true positives out of 162 reports). This bounds how bad pattern matching is.
The strongest program-analysis competitors are Clairvoyance and xFuzz. On the 17,770-contract set, Clairvoyance reports about 73.8% precision (124 true positives, 44 false positives) in Ye et al.. On xFuzz's cross-contract benchmark, Xue et al. report 100% precision for xFuzz against 43.7% for Clairvoyance. For read-only reentrancy specifically, SmartReco reports 88.64% precision and 86.67% recall on its 45-case benchmark (Zhang et al.).
We will re-run all three on our benchmark at both pre- and post-upgrade blocks. Each gets the same forked state and the same wall-clock budget as our system. Our system beats them only if it matches their precision at higher recall on cross-contract cases, or matches recall at higher precision, and also tracks flips at least as well. We expect these tools to handle flips correctly when re-run from scratch. Their weakness should be recall on paths their solvers or protective-pattern rules cannot decide.
The strongest LLM competitor is GPTLENS's auditor-critic pipeline. It reports a CVE hit ratio rising from 38.5% to 76.9% on 13 single-contract CVEs (Hu et al.). We will give its critic the full current source of all reachable callees, using the same base model, the same sampling budget, and the same number of critic calls as our checker. HMF's finding of below-20% precision for standalone LLMs (Li et al.) serves as the floor for the auditor alone. There is no reported result on Lacuna for any method on stale-versus-fabricated claim rates, or on exploitability flips across upgrades. Those numbers will come from this work.
Three ablations isolate the key ingredients:
- No time: the same graph with validity intervals removed, using the latest-known edges.
- No claim-level checking: fresh code plus graph serialized into the prompt, with no constrained decoding or verification.
- Masked names: entity names masked in the style of Choudhary et al., with no graph at all.
Why not just…?
Why not just give a long-context LLM the current source of every reachable contract and re-run after each upgrade? This is the most serious alternative. If the model sees only current code, stale context disappears. Two sources of error remain. The first is parametric memory of well-known protocol versions. The second is mixing old and new facts, which StateMem shows persists even when retrieval is perfect (Can Agent Memory Systems Track Evolving State?). Fabrication also remains: HMF's below-20% precision was measured with code in context. The fresh-context ablation, run with and without name masking, tests this directly on the flip benchmark. If it matches our system on flip accuracy and stale-claim rate, the temporal edges are not earning their keep on accuracy. The claim would then shrink to re-audit cost, and we would say so.
Why not just use Clairvoyance or xFuzz and skip the LLM? They are precise and deterministic, and re-running them handles upgrades. Their published limits are the gap we target. Their solvers fail on non-linear arithmetic and oracle-dependent conditions, and Clairvoyance treats addresses as fixed. The comparison at matched budget on cross-contract flips will show whether the LLM adds recall without giving up their precision. If it adds nothing, the honest conclusion is that the graph should feed better solvers, not a language model.
Why not just let an LLM critic filter the findings, as GPTLENS does? An LLM critic can itself hallucinate that a callee is guarded, or rely on a superseded implementation. Our labeled failure causes let us count how often the LLM critic accepts fabricated or stale paths that the graph checker rejects, at an equal call budget.
Why not just use vector retrieval over code, as SCALM does? Retrieval returns similar-looking snippets, not the specific edge that links this caller to this callee at this block. SCALM itself reports failure on multi-contract flaws. We include it for completeness but expect it to be the weakest grounded baseline.
Proposed Experiments and Decisive Checks
The primary experiment runs every system on the upgrade-flip benchmark. It reports four quantities: precision and recall of fuzz-confirmed cross-contract findings at the post-upgrade block, flip accuracy (the fraction of pairs whose verdict changes correctly), and the rates of fabricated and stale claims among emitted attack paths.
A secondary run on Clairvoyance's 17,770-contract set and SmartReco's read-only reentrancy benchmark checks that the system does not lose ground on the problem these tools were built for. The efficiency test replays the window's upgrade stream. It compares the number of findings re-checked, and compute spent, under dependency-linked invalidation versus full re-audit at each upgrade. It also counts any confirmed finding that invalidation failed to re-open.
The decisive test is the no-time ablation against the full system on flip pairs. If removing validity intervals does not raise the stale-claim rate or lower flip accuracy, the obsolescence component of this proposal is not supported. A second decisive test is the fresh-context-plus-masking baseline. If it closes most of the gap, claim-level graph checking is not what drives the gain.
References
- Analyzing Ethereum Smart Contract Vulnerabilities at Scale Based on營nter-Contract Dependency
- Clairvoyance: cross-contract static analysis for detecting practical reentrancy vulnerabilities in smart contracts
- xFuzz: Machine Learning Guided Cross-Contract Fuzzing
- Smartreco: Detecting Read-Only Reentrancy via Fine-Grained Cross-DApp Analysis
- HMF: Enhancing reentrancy vulnerability detection and repair with a hybrid model framework
- Large Language Model-Powered Smart Contract Vulnerability Detection: New Perspectives
- SCALM: Detecting Bad Practices in Smart Contracts Through LLMs
- SolDetector: Detect Defects Based on Knowledge Graph of Solidity Smart Contract
- Knowledge Informed Semantic Parsing for Conversational Question Answering
- Can Agent Memory Systems Track Evolving State?
- Mitigating Temporal Misalignment by Discarding Outdated Facts
- Complex Logical Reasoning over Knowledge Graphs using Large Language Models