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.
翻译:本文探讨了在指定时间内限制调用Solidity智能合约函数能力的方法。我们描述了限制函数在同一交易、区块或时间段内被重复调用的技术手段,这与"不可重入函数"(即可在前一次执行中被调用的函数)的概念相关。这些方法可用于限制与智能合约完整函数集的交互。我们重新审视这一主题的动机有二:其一,2023年发生的16起真实世界智能合约漏洞事件(导致超1.36亿美元损失或被盗)本可通过限制函数调用加以预防。作为本次调研的一部分,我们剖析了一类新型漏洞——"只读重入",即攻击者通过重入只读函数使智能合约状态不一致以实现利用;其二,尽管部分方法实现简单,但在支持Solidity的不同区块链上其表现可能并不一致。