Papers
Topics
Authors
Recent
Search
2000 character limit reached

Combating Reentrancy Bugs on Sharded Blockchains

Published 6 Jun 2025 in cs.CR | (2506.05932v1)

Abstract: Reentrancy is a well-known source of smart contract bugs on Ethereum, leading e.g. to double-spending vulnerabilities in DeFi applications. But less is known about this problem in other blockchains, which can have significantly different execution models. Sharded blockchains in particular generally use an asynchronous messaging model that differs substantially from the synchronous and transactional model of Ethereum. We study the features of this model and its effect on reentrancy bugs on three examples: the Internet Computer (ICP) blockchain, NEAR Protocol, and MultiversX. We argue that this model, while useful for improving performance, also makes it easier to introduce reentrancy bugs. For example, reviews of the pre-production versions of some of the most critical ICP smart contracts found that 66% (10/15) of the reviewed contracts -- written by expert authors -- contained reentrancy bugs of medium or high severity, with potential damages in tens of millions of dollars. We evaluate existing Ethereum programming techniques (in particular the effects-checks-interactions pattern, and locking) to prevent reentrancy bugs in the context of this new messaging model and identify some issues with them. We then present novel Rust and Motoko patterns that can be leveraged on ICP to solve these issues. Finally, we demonstrate that the formal verification tool TLA+ can be used to find and eliminate such bugs in real world smart contracts on sharded blockchains.

Summary

  • The paper identifies reentrancy vulnerabilities specific to asynchronous models in sharded blockchains, with 66% of Internet Computer contracts affected.
  • It evaluates Ethereum’s traditional security patterns, revealing limitations when applied to asynchronous messaging environments.
  • The study proposes novel Rust and Motoko locking patterns and demonstrates their effectiveness using formal TLA+ verification techniques.

Combating Reentrancy Bugs on Sharded Blockchains

The paper under discussion presents an in-depth analysis of reentrancy bugs within the context of sharded blockchain architectures, particularly focusing on the Internet Computer (ICP), NEAR Protocol, and MultiversX blockchains. While reentrancy attacks have been extensively studied within Ethereum's synchronous environment owing to high-profile incidents like The DAO exploit, this study explores the asynchronous messaging models employed by certain sharded blockchains, which present unique challenges in identifying and mitigating these vulnerabilities.

Main Contributions and Findings

The primary contributions of this work are:

  1. Understanding Reentrancy in Asynchronous Models: The paper introduces the differences between asynchronous messaging models used by sharded blockchains and Ethereum's synchronous transaction model. It highlights that the asynchronous model, while enhancing performance due to non-reliant message ordering and parallel message processing capabilities, is conducive to new forms of reentrancy vulnerabilities. A significant observation is that 66% of analyzed contracts on Internet Computer contained reentrancy bugs with potentially substantial financial implications.
  2. Evaluation of Ethereum Techniques: Existing Ethereum programming techniques, namely checks-effects-interactions and mutex patterns, are evaluated within the context of these new models. The paper discusses the inadequacies of these techniques when directly applied to the asynchronous model, such as difficulties with state rollback in the absence of synchronous transaction context.
  3. Novel Locking Patterns: The authors propose advanced Rust and Motoko patterns tailored for the Internet Computer that emphasize how contract features can provide robust security against reentrancy. The developers emphasize the use of fine-grained locking mechanisms as a balance of security and performance, highlighting improvements over traditional mutex locks found unsuitable for asynchronous environments due to deadlock potential.
  4. Utilization of Formal Verification with TLA+: The paper demonstrates how formal verification using the TLA+ toolkit can be employed to detect and eliminate reentrancy bugs in smart contracts. The study provides methodologies for modeling smart contracts, particularly those using async/await paradigms, facilitating thorough verification of the contracts’ execution logic.

Implications

This work holds significant implications for both the development and analysis of blockchain smart contracts in the rapidly advancing domain of sharded blockchains. From a theoretical standpoint, it extends our understanding of concurrency issues within non-transactional contexts and introduces methodologies adaptable across various blockchain platforms using asynchronous models. Practically, it serves as a guidepost for developers aiming to implement robust security measures against reentrancy threats in their contracts, using tailored locking patterns and formal verification techniques.

Future Directions

The paper opens several avenues for further research. First, extending these locking patterns to other languages and blockchains beyond ICP, as noted for NEAR and MultiversX, could enhance cross-platform security solutions. Additionally, investigating the automation of translating code to TLA+ models would streamline the verification process, making formal methods more accessible to the broader smart contract development community. Lastly, as blockchain architectures continue to evolve, ongoing evaluation of existing patterns against emerging threats will be crucial.

By addressing the intricacies of asynchronous execution models and leveraging formal verification to assert security claims, this research lays foundational work that aligns with overarching goals of ensuring security and reliability in decentralized systems.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 3 likes about this paper.