Skip to main content
QUICK REVIEW

[论文解读] Executable Operational Semantics of Solidity

Jiao Jiao, Shuanglong Kan|arXiv (Cornell University)|Apr 4, 2018
Blockchain Technology Applications and Security参考文献 2被引用 10
一句话总结

本文首次为以太坊智能合约编程语言 Solidity 提供了可执行的结构化操作语义(SOS),并使用 K 框架进行形式化,从而实现智能合约的自动化验证。通过建模 Solidity 的独特特性——如存储持久性、嵌套数组和回退函数——该工作揭示了关键的设计问题,并检测到重入攻击等漏洞,证明了形式化源代码级语义对于安全智能合约开发至关重要。

ABSTRACT

Bitcoin has attracted everyone's attention and interest recently. Ethereum (ETH), a second generation cryptocurrency, extends Bitcoin's design by offering a Turing-complete programming language called Solidity to develop smart contracts. Smart contracts allow creditable execution of contracts on EVM (Ethereum Virtual Machine) without third parties. Developing correct smart contracts is challenging due to its decentralized computation nature. Buggy smart contracts may lead to huge financial loss. Furthermore, smart contracts are very hard, if not impossible, to patch once they are deployed. Thus, there is a recent surge of interest on analyzing/verifying smart contracts. While existing work focuses on EVM opcode, we argue that it is equally important to understand and define the semantics of Solidity since programmers program and reason about smart contracts at the level of source code. In this work, we develop the structural operational semantics for Solidity, which allows us to identify multiple design issues which underlines many problematic smart contracts. Furthermore, our semantics is executable in the K framework, which allows us to verify/falsify contracts automatically.

研究动机与目标

  • 为解决 Solidity 缺乏形式化、可执行语义的问题,Solidity 是编写以太坊智能合约的高级语言。
  • 支持在源代码级别进行智能合约行为的形式化推理,而非依赖低级别的 EVM 字节码分析。
  • 通过形式化语义检测设计缺陷和漏洞(如意外的数组行为和重入攻击)。
  • 提供一个与官方编译器和文档一致的、形式化验证过的、可执行的 Solidity 模型。
  • 利用 K 框架中的可达性逻辑,支持智能合约属性的自动化验证与反证。

提出的方法

  • 为 Solidity 开发了结构化操作语义(SOS),捕捉了包括存储、内存和堆栈语义在内的关键语言特性。
  • 在 K 框架中形式化语义,实现对合约执行的可执行且机器可检查的推理。
  • 对嵌套数组、函数调用、回退函数和外部调用等复杂特性进行精确的状态转移建模。
  • 通过函数修饰符实现函数参数绑定和条件检查,确保执行上下文的正确处理。
  • 使用 K 框架的可达性逻辑证明器,自动验证或反证合约属性。
  • 通过与 Remix 编译器及官方 Solidity 文档的对比,验证了语义的一致性。

实验结果

研究问题

  • RQ1如何在源代码级别对 Solidity 的语义进行形式化且精确的定义,以支持开发者进行正确推理?
  • RQ2Solidity 中哪些设计层面的问题(如数组处理和回退函数)在实践中会导致可利用的漏洞?
  • RQ3即使在部署前,Solidity 的可执行语义能否检测到已知漏洞(如 DAO 攻击)?
  • RQ4所提出的语义与官方 Solidity 编译器和文档的一致性如何?
  • RQ5K 框架的可达性逻辑在多大程度上可用于自动验证或反证智能合约属性?

主要发现

  • 所提出的可执行语义正确地建模了 Solidity 的大多数核心特性,与官方文档描述一致,并与 Remix 编译器的行为相符。
  • 形式化模型揭示了 Solidity 中细微但关键的行为,如由于存储布局导致的意外数组修改,可能引发安全漏洞。
  • 该语义通过精确建模函数调用和状态转移行为,成功检测到重入类漏洞,包括 DAO 攻击的变体。
  • K 框架的可达性逻辑支持智能合约正确性的自动化验证,可对错误假设进行反证。
  • 本工作表明,源代码级的形式化语义对于可靠的智能合约开发至关重要,因为仅靠低级别 EVM 分析无法捕捉高层语义意图。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。