Proj Unknown Paper Reading: SAILFISH: Vetting Smart Contract State-Inconsistency Bugs in Seconds
Abstract
本文: SAILFISH
TASK: find state-inconsistency bugs in smart contracts
Method: a hybrid approach, 1. a lightweight exploration phase 2. 一种新的value-summary analysis方式,与symbolic evaluation结合用在refinement phase。这一value-summary analysis能够产生额外的constraints, 用以oever-approximate整个程序执行的副作用,进而保证整个执行的精确度 3. 可用于reentrancy和transaction order dependence两种flaws。
实验:
数据集: ETHERSCAN中的89853个智能合约
竞争对手:SECURIFY, MYTHRIL, OYENTE, SEREUM, VANDAL
效果:
- 发现了 47个新bugs
1. Intro
背景:
- 智能合约不可变,这使得修复错误十分困难
本文:
对象:state inconsistency bugs 状态不一致漏洞,攻击者可以篡改关键存储变量,这些变量通过数据或控制依赖性对货币交易产⽣可传递的影响
特点:可扩展
现有研究-检测状态不一致错误
- over-approximate the execution of a smart contract, 这会导致误报
- 枚举concrete or symbolic traces,不适应大型合约
- dynamic tools: 只有当主动攻击时才能发现
- a syntax-directed pattern matching,无法兼容潜在攻击模式
- 静态工具
- 挑战
- 暴露的公共方法都可以作为攻击入口点,可以通过写入存储变量来改变合约状态
- 攻击者可以以任意顺序调用任意次数的任意方法,由于不同的合约可以通过公共方法相互通信,因此更难检测拼接调用多个公共方法发起的cross-function attacks
本文:SAILFISH
特点:scalable, hybrid
方法:
- EXPLORE phase: convert the contract into a storage dependency graph(SDG) G
- SDG的作用:1. 记录了读写依赖,记录了读写副作用 2. 建模state-inconsistency bugs为graph queries,查询返回易受攻击的子图g(potentially vulnerable。g可能是误报
- 特点:light-weight, hybrid
- REFINE phase: value-summary analysis,基于symbolic evaluation,
- 其他工具存在的问题
- a conservative symbolic executor会将storage variables初始化为unconstrained,这会导致剪枝无效率(许多可以不走的路径会走)
- 本文为了解决这个问题:a light-weight value-summary analysis,记录总结storage variables的value constraints,再将这些约束用作symbolic evaluation的pre-conditions
- compute the summaries path-by-path,leading to full-summaries,指数增长无法应用在大规模合约上
- 本文:summaries through a finite(loop-free) precedure, 多项式复杂度
实验:
数据集: ETHERSCAN中的89853个智能合约
竞争对手:SECURIFY, MYTHRIL, OYENTE, SEREUM, VANDAL
效果:
- 漏报和误报上表现更好
- 快速:SAILFISH平均只⽤了30.79秒来分析智能合约,⽐MYTHRIL [3]快31倍,⽐SECURIFY [54]快 6 个数量级。
结构
III: 定义了state-inconsistency bugs,探究了两个根本原因, a new reentrancy attack patterns
V: SGD, encodes the high-level semantics of smart contracts over global states.
VI: a novel value-summary analysis 对智能合约全局状态的高级语义进行编码
VIII: a systematic evaluation of SAILFISH on ETHERSCAN
II. Background
Smart contract
event: the invocation of a public/external method from outside the contract(the calls originated from inside are not events)
A schedule H is a valid sequence of events that can be executed by EVM
contract state Δ = (V, B), where V = {V1, V2,..., Vn}, the set of all the storage variables. B: balance
State inconsistency(SI)
if a schedule H1 should generate final state Δ1, but due to the reordering of transactions\ reentrant calls, the actual executed schedule is H2, and the final state Δ2 is different than Δ1.