Temporarily Restricting Solidity Smart Contract Interactions
Valerian Callens, Zeeshan Meghji, Jan Gorzny
TL;DR
The paper addresses the problem of temporarily restricting Solidity smart contract interactions to mitigate reentrancy-related exploits. It surveys standard reentrancy defenses and extends the discussion to restricting entire sets of functions, including read-only ones, and time- or block-based constraints; it also analyzes cross-chain execution differences. Key contributions include a taxonomy of restriction techniques (within the same execution, within a transaction, and within time/blocks) and a deep dive into read-only reentrancy and multi-function guards, illustrated by case studies from 2023 DeFi incidents. The findings underscore the potential to prevent large losses, while also highlighting trade-offs in security versus composability, gas costs, and cross-chain semantics, calling for careful, context-aware deployment and further study.
Abstract
In this work we explore ways to restrict the ability to call Solidity smart contract functions for a specified duration. We describe methods to restrict functions from being called twice in the same transaction, block, or time period. This is related to the notion of non-reentrant functions, which are functions that can be called within a previous execution. These methods can be used to restrict interactions with entire sets of functions of smart contracts. We are motivated to revisit this topic for two reasons. First, we note that sixteen real-world smart contracts exploits in 2023 resulting in over $136M USD lost or stolen that could have been prevented by restricting function calls. As part of this survey, we dissect a new class of exploit that involves so-called read-only reentrancy: exploits that re-enter read-only functions to make smart contract state inconsistent in order to enable their exploitation. Second, while some of these approaches are simple, they may not always behave the same across different blockchains that support Solidity.
