Skip to content
Crypto.world

Research

PSR2: A Phase-based Semantic Reasoning Framework for Atomicity Violation Detection via Contract Refinement

Traditional smart contract scanners rely either on rigid rule sets or on local pattern matching, which leads to two failures: they cannot tell whether a state variable that looks dangerous actually…

PSR2: A Phase-based Semantic Reasoning Framework for Atomicity Violation Detection via Contract Refinement
arXiv
2604.06975
Published
2026-04-08
Authors
Xin Wang, Wenkai Li, Zongwei Li, Xiaoqi Li

AI summary

Overview

Research area: Smart contract security, specifically static program analysis for detecting atomicity violations in Ethereum-style contracts (arXiv category: Cryptography and Security, cs.CR). The paper is a software engineering / program-analysis contribution, published in the FSE Companion '26 track (34th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering, Montreal, July 2026).

Technical level: Advanced. The paper is written with formal notation (semantic repositories, path predicates, a decision function), but its central idea — combining graph reachability with semantic data-dependency checks — is graspable by an intermediate reader.

Scope (one sentence): The paper presents PSR², a static analysis framework that fuses control-flow path searching with semantic data-dependency reasoning to detect atomicity violations (reentrancy and unchecked external calls) in smart contracts, evaluated against Slither and Semgrep on 1,600 contract samples.

What This Paper Is About

Traditional smart contract scanners rely either on rigid rule sets or on local pattern matching, which leads to two failures: they cannot tell whether a state variable that looks dangerous actually feeds into an external call (context blindness), and they cannot tell whether a suspicious code pattern is actually reachable along a real execution path (topological insensitivity). PSR² aims to fix both by running two independent analyses in parallel — one over the contract's control flow graph, one over its abstract syntax tree — and then requiring both to agree before a vulnerability is reported.

The target class of bugs is "atomicity violations": situations where a critical state variable is read, an external call happens, and the variable is written back afterward, so that the contract is observed in an intermediate, uncommitted state and can be exploited (classic reentrancy) or where an external call's return value is ignored before execution continues to a state write.

Key Contributions

  1. A collaborative two-module framework (PSR²). It couples path-sensitive graph analysis (GSAM) with context-aware semantic extraction (SCAM) under a third component, the Fusion Decision Module (FDM), which resolves the false-positive/false-negative trade-off the authors attribute to existing tools.

  2. A Unified Atomicity Inconsistency Model. The paper abstracts distinct vulnerability classes — explicit reentrancy, implicit ERC-721 callback reentrancy, and unchecked external calls — into one logic primitive: a critical variable sitting in an intermediate state during a side-effect-heavy interaction. This lets one decision function cover multiple bug types instead of requiring per-bug signatures.

  3. A Fusion Decision Module that cross-validates structure against semantics. The FDM queries semantic facts for each suspicious path (call target type, whether the state variable is data-dependent on the call, whether the call truly occurs between the load and the store) and assigns High / Medium / Low risk accordingly, emitting a structured evidence report.

  4. An empirical evaluation on 1,600 samples across three benchmarks (Smartbugs-Reentrancy, ERC-721 Reentrancy, Smartbugs-Unchecked External Call) against Slither and Semgrep, plus an ablation study on a balanced set of 719 vulnerable and 719 safe contracts.

Main Findings

  • ERC-721 (implicit callbacks) is where the gap is largest: PSR² reaches an F1-score of 92.36% (precision 94.94%, recall 89.91%), against Semgrep's 51.86% (precision 59.90%, recall 45.73%) and Slither's 18.53% (precision 16.31%, recall 21.45%). The authors attribute Slither's result to "contextual blindness" when external calls trigger implicit callbacks such as onERC721Received.

  • Reentrancy benchmark: PSR² achieves 86.96% F1 (precision 78.13%, recall 98.04%), versus Semgrep 81.51% (precision 71.32%, recall 95.10%) and Slither 4.76% (precision 12.50%, recall 2.94%).

  • Unchecked external calls: PSR² reaches 90.69% F1 (precision 84.21%, recall 98.25%), versus Slither 73.01% (precision 74.12%, recall 71.93%) and Semgrep 16.42% (precision 55.00%, recall 9.65%). The collapse in Semgrep's recall is presented as evidence that signature-based matching does not generalize to non-standard implementations.

  • Ablation shows each module alone is insufficient: On the balanced set, the graph-only variant (PSR²_GSAM) gets 88.87% recall with an 11.27% false-positive rate; the semantic-only variant (PSR²_SCAM) gets 83.73% recall with an 82.61% false-positive rate; the full framework gets 92.35% recall with a 6.40% false-positive rate. The full configuration's final metric column in Table 2 reads 92.93%, with 88.81% and 62.87% for the two decoupled variants.

  • Fusion roughly halves the false-positive rate relative to single-module analysis (as stated in the abstract), and the paper reports that the fusion logic also raises recall by recovering ERC-721 vulnerabilities that require both structural reachability and a semantic trigger.

  • Caveat stated by the authors: the paper explicitly notes typographical and LaTeX column-misalignment errors in Tables 1 and 2, states that the core findings are unaffected, and reports that a formal Corrigendum was submitted to the ACM Digital Library.

Methodology in Plain English

The framework runs three stages on a contract's source code.

Stage 1 — Semantic Context Analysis (SCAM). The contract is parsed into an abstract syntax tree. From it, the tool builds a deterministic fact base: for every function, an identifier, name, and role (role assigned by matching signatures against a keyword set such as price, update); for every state variable, its type and which functions read it, write it, or both. It then looks at every external call site and records where the call is, what kind of target it has (a fixed address versus user-controlled input), and — critically — which state variables determine the call's arguments or its execution conditions. That last part is the "dependency set," and it is what distinguishes a genuinely dangerous call from a harmless one.

Stage 2 — Graph Structure Analysis (GSAM). The contract's control flow graph is collapsed into a simplified graph whose nodes are labeled only with operations that matter for atomicity: SLOAD(s) (read state variable s), SSTORE(s) (write state variable s), CALL(t) (external call to target t), CHECK, and OTHER. Everything else is filtered out. The tool then searches for paths where the same variable is loaded, an external call happens, and the variable is stored — the SLOAD → CALL → SSTORE sequence — and flags them as structurally suspicious. At this stage nothing is confirmed; these are path-level alerts.

Stage 3 — Fusion Decision (FDM). Each suspicious path is annotated by looking up the semantic facts: the call target type, a boolean for whether the state variable actually appears in the call's dependency set, and a boolean for whether the call occurs strictly between the load and the store. The decision rule is: High risk if the dependency and intermediate-state checks both hold and the target is not a fixed address; Medium if both hold but the target is fixed; Low (discarded) otherwise. Only High and Medium produce a report, and each report carries the verdict, the path, the variable, the call fact, and the semantic context, so the finding is auditable.

The point of the third stage is that structural paths alone produce noise (benign sequences that happen to match the shape), and semantic patterns alone produce false alarms (patterns that are never actually reachable). Requiring both to agree is the paper's central design claim.

Why This Matters

Impact on research. The paper argues that heterogeneous smart contract vulnerabilities share one underlying pathology — a critical variable left in an intermediate, uncommitted state across an external interaction — and that this lets a single detection logic replace hand-written per-bug rules. If that abstraction holds, it changes how detection tools are built: instead of adding a new signature per vulnerability class, you refine each class into the same primitive. The paper also provides a directly comparable head-to-head against two widely used industry tools (Slither, Semgrep) on named public benchmarks, which is useful baseline data for the field.

Real-world applications:

  • Auditing DeFi protocols that pull prices from external oracles, where a state read can be invalidated by an out-of-band update before the write lands.
  • NFT (ERC-721) marketplaces and contracts implementing receiver hooks, where the dangerous call is an implicit callback rather than an obvious external call in the source.
  • Pre-deployment CI gates in smart contract development pipelines, screening for unchecked low-level call return values before execution proceeds to a state write.
  • Blockchain data-sharing and IoT-adjacent deployments, which the conclusion names as a broader application area for the same state-consistency guarantee.

Industry relevance. The strongest commercial signal is the ERC-721 result: a 92.36% F1 versus 51.86% for the best baseline on contracts whose risk lives in implicit control flow. Auditors relying on pattern matchers would miss roughly half of those cases by the paper's measurement. The structured evidence reports (path plus semantic facts plus verdict) also map onto how audit findings must be documented for clients, rather than producing a bare warning.

Future Directions

  • Cross-contract calls without available source code. The discussion identifies mapping complete dependency sets as still challenging when a call targets a contract whose source is unavailable, and points to semantic lifting at the bytecode level as the necessary next step.

  • Extending the unified primitive to more vulnerability classes. The paper demonstrates the abstraction on reentrancy (explicit and implicit) and unchecked external calls; whether the same intermediate-state formulation covers other state-inconsistency bugs is left open.

  • Validating the abstraction beyond the three benchmarks used. All results come from Smartbugs-Reentrancy, ERC-721 Reentrancy, and Smartbugs-Unchecked External Call; broader, more diverse real-world corpora would test the generalizability claim more sharply.

  • Resolving the reported table errors. The authors flag typographical and column-misalignment issues in Tables 1 and 2 and have submitted a corrigendum; independent replication of the ablation numbers (the reported 92.93% final metric for the full framework alongside 88.81% and 62.87% for the decoupled variants) would firm up the quantitative case for fusion.

Target Audience

Smart contract security researchers and auditors, particularly those working on static analysis tooling and on DeFi/NFT contract review, who want a concrete design for combining control-flow reachability with data-dependency reasoning. It also suits graduate students in software engineering or program analysis looking for a worked example of multi-analysis fusion with an ablation study, and security engineers at firms building or evaluating scanner pipelines, who can read the Slither/Semgrep comparison as a benchmark of where rule-based tools break down. Readers need comfort with control flow graphs, abstract syntax trees, and basic data-flow concepts; the formal notation is compact but not the main barrier.

Authors’ abstract

With the rapid advancement of decentralized applications, smart contract security faces severe challenges, particularly regarding atomicity violations in complex logic such as Oracle and NFT contracts. Rigid rule sets often limit traditional static analyzers and lack deep contextual awareness, leading to high false-positive and false-negative rates when identifying vulnerabilities that depend on intermediate state inconsistencies. To address these limitations, this paper…

The full abstract on arXiv
Read the original paper