Cross-Contract Control and Data Flow Analysis

38 concepts27 papers1 proposal

Smart contracts are fundamentally designed to be interoperable. In ecosystems like Decentralized Finance (DeFi), protocols function as "Money Legos," explicitly relying on the ability to call and compose external code to build complex financial products Werner et al..

However, this composability introduces a severe security paradox: a smart contract can be completely secure in isolation, yet completely vulnerable when integrated into a multi-contract ecosystem.

Traditional security tools analyze smart contracts as isolated, self-contained units. To secure modern decentralized applications, program analysis must shift from evaluating individual codebases to tracking control flow and state dependencies across multiple interacting contracts.


The Blind Spot of Isolated Analysis

To understand why isolated analysis fails, consider how a traditional static analysis or symbolic execution tool views an external call. When a contract executes an instruction like target.call(), the tool encounters an execution boundary. Because it only models the host contract's bytecode, it treats the external target as a black box.

This localized perspective creates two critical failure modes:

  1. The False Positive Explosion: If a tool assumes the external target could be completely adversarial, it must flag every instance where an external call occurs before an internal state update as a potential reentrancy vulnerability. As demonstrated by Zhang et al., this fixated pattern-matching leads to a staggering 99.8% false positive rate on modern Ethereum contracts, because tools cannot see if the target contract actually contains path-protective techniques or benign logic Ye et al..
  2. Total Blindness to Emergent Exploits: If a tool assumes the external target behaves benignly, it becomes blind to exploits where the vulnerability trigger and the actual state change are split across separate deployed entities Xiao et al..

When execution context switches between different addresses, traditional frameworks lose global storage visibility Wang et al.. They cannot track how a state change in Contract A alters the execution path of Contract B, leaving a massive gap in security auditing Chen et al..

This challenge is not entirely unique to blockchains. For instance, in Internet of Things (IoT) platforms, individual applications may be secure in isolation, but their interaction through shared physical triggers can cause dangerous, unintended system failures Celik et al.. In the smart contract realm, however, these emergent failures directly translate to catastrophic financial losses.


Mechanisms of Cross-Contract Analysis

To resolve what happens at contract boundaries, cross-contract analysis constructs representations that span the entire interaction space. Instead of treating external addresses as abstract entities, these frameworks dynamically or statically link interacting contracts into a unified model.

Isolated Analysis:
[ Contract A ] ──> ( External Call ) ──> [ ??? Black Box ??? ]

Cross-Contract Analysis:
[ Contract A ] ──> ( Resolve Address/Storage ) ──> [ Contract B (Victim/Library) ]
      ▲                                                    │
      └─────────────────── ( Reentrant Loop ) ─────────────┘

Cross-Contract Control Flow Graphs (CCFGs)

To map execution across boundaries, frameworks build control flow and call graphs that explicitly resolve external targets Ye et al.. By analyzing hardcoded addresses, deployment parameters, or specific storage slots, the analysis can pinpoint the exact code that will execute during an external call Yang et al.. This allows the tool to follow the execution path out of the host contract, through the external entity, and back, mapping out complex multi-contract call chains.

Inter-Contract Data Flow and State Tracking

Tracking data flow across contracts allows tools to maintain a continuous view of state variables. For example, if Contract A delegates its logic to an external library via DELEGATECALL, or relies on an external oracle or token standard for balance checks, cross-contract data flow analysis maps how inputs to one contract mutate the state variables of another Liao et al..

Multi-Invocation Trace Analysis

Many vulnerabilities do not manifest within a single transaction. Instead, they require a sequence of distinct interactions over time. Tools like MAIAN address this by analyzing execution traces across multiple sequential invocations, identifying contracts that are "greedy" (locking funds indefinitely), "prodigal" (leaking funds to unauthorized users), or "suicidal" (allowing anyone to destruct the contract) through multi-step interaction sequences Nikolic et al..


Emergent Vulnerability Classes

By looking across contract boundaries, researchers have categorized several types of vulnerabilities that are completely invisible to single-contract scanners.

Cross-Contract Reentrancy

In classic reentrancy, an attacker calls back into the same function or contract before the state updates. In cross-contract reentrancy, the attacker exploits a state mismatch across multiple interacting contracts Li et al.. For example, if Contract A manages user balances and Contract B handles rewards based on Contract A's balance, an attacker can withdraw funds from Contract A and call Contract B before Contract A has finalized its internal state update.

Non-Local Race Conditions (Event-Ordering Bugs)

Because the final state of a blockchain depends on the order in which transactions are processed, attackers can exploit non-deterministic transaction ordering. Event-ordering (EO) bugs occur when reordering transactions affects the state of external, interacting contracts, leading to non-local race conditions across separate decentralized applications Kolluri et al..

Composable Economic Failures

Sometimes, the code of every participating contract executes exactly as written, yet the system fails economically. Tolmach et al. demonstrated that economic guarantees verified for a protocol in isolation frequently fail when integrated into a multi-protocol ecosystem. For instance, liquidity constraints or pool overutilization in a lending protocol can cascade, invalidating profit or redemption guarantees in an entirely separate, connected protocol.

Dependency Cascades

The ecosystem's interconnectedness means that a vulnerability in a single, heavily utilized contract can jeopardize the entire network. By constructing a Contract Dependency Graph (CDG), Lyu et al. revealed that while only a tiny fraction of active contracts (0.02%) are inherently vulnerable, their role as central dependencies puts nearly 14.7% of the entire network at risk as potential victims.

Misidentified Centralization Risks

Isolated analysis can also lead to false positives regarding governance. If a contract restricts administrative functions to an external address, a single-contract scanner flags this as a centralization defect. However, if cross-contract analysis reveals that the external address is actually a Decentralized Autonomous Organization (DAO) governance contract, the apparent centralization risk disappears Lin.


The Shift Toward Global Verification

Recognizing the limitations of post-deployment scanning, the field is moving toward frameworks that incorporate cross-contract awareness throughout the development lifecycle.

  • Correct-by-Design Modeling: Frameworks like FSolidM and VeriSolid allow developers to model smart contracts as high-level transition systems or Finite State Machines (FSMs) Mavridou et al.. By formalizing inter-contract behaviors and shared state dependencies before code generation, these tools prevent cross-contract flaws from being introduced in the first place Mavridou et al..
  • Global Invariant Verification: Advanced verification frameworks use refinement types or stateful concurrent game models to mathematically prove that global invariants hold true even when contracts interact with unknown or adversarial external code Grishchenko et al., Velner et al., Nishida et al..
  • Holistic Repair: Automated patch generation tools must also adapt; local patch logic is ineffective at fixing vulnerabilities where the exploit state is distributed across multiple unrelated contracts Jin et al.. Modern repair frameworks leverage hybrid models to ensure that patches validate global invariants rather than just local code paths Li et al..

Ultimately, as decentralized applications grow more complex and cross-chain boundaries blur Gao et al., treating smart contracts as isolated islands is no longer a viable security strategy. Securing the future of Web3 requires tools that can reason about the emergent behaviors of composed systems.

Key Foundational Work

Quantitative Analysis of Smart Contracts (2018) — contributed 1 concept elements to this direction.
Designing Secure Ethereum Smart Contracts: A Finite State Machine Based Approach (2018) — contributed 1 concept elements to this direction.
VeriSolid: Correct-by-Design Smart Contracts for Ethereum (2019) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_cross_contract_vulnerability_detection_33a48aa1,
  title = {cross-contract vulnerability detection},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/cross-contract-vulnerability-detection/rdr_33a48aa1aa2041beaff0297a9e450cca},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-20},
}

This exact version (version 1, frozen text):

@misc{lacuna_cross_contract_vulnerability_detection_33a48aa1_v1,
  title = {cross-contract vulnerability detection},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/cross-contract-vulnerability-detection/rdr_33a48aa1aa2041beaff0297a9e450cca/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-20},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake