crytic/echidna
GitHub: crytic/echidna
Echidna 是一款专为以太坊智能合约设计的快速模糊测试器,通过基于属性的测试方法自动发现合约中的安全漏洞和逻辑缺陷。
Stars: 3085 | Forks: 422
# Echidna:快速的智能合约模糊测试器

Echidna 是一种奇怪的生物,它吃虫子并且具有高度的电敏感性(向 Jacob Stanley 致歉)
更严肃地说,Echidna 是一个 Haskell 程序,专为以太坊智能合约的模糊测试/基于属性的测试而设计。它使用基于[合约 ABI](https://docs.soliditylang.org/en/develop/abi-spec.html) 的复杂基于语法的模糊测试活动,来证伪用户定义的谓词或 [Solidity 断言](https://docs.soliditylang.org/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions)。我们在设计 Echidna 时考虑到了模块化,因此可以轻松扩展它以包含新的变异或在特定情况下测试特定合约。
## 功能特性
* 生成针对实际代码定制的输入
* 可选的语料库收集、变异和覆盖引导,以发现更深层的错误
* 由 [Slither](https://github.com/crytic/slither) 驱动,在模糊测试活动之前提取有用信息
* 源代码集成,用于识别模糊测试活动后覆盖了哪些行
* 交互式终端 UI、纯文本或 JSON 输出
* 自动化测试用例最小化,便于快速分类
* 无缝集成到开发工作流中
……以及[一个精美的高分辨率手工制作徽标](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/0a2a752d0d232451.png)。
## 用法
### 执行测试运行器
Echidna 的核心功能是一个名为 `echidna` 的可执行文件,它接收一个合约和一个不变量列表(应该始终保持为真的属性)作为输入。对于每个不变量,它生成随机的合约调用序列,并检查不变量是否成立。如果它能找到某种方法来证伪该不变量,它会打印出实现这一点的调用序列。如果找不到,您就可以在一定程度上确信合约是安全的。
### 编写不变量
不变量表示为名称以 `echidna_` 开头、没有参数并返回布尔值的 Solidity 函数。例如,如果您有一个 `balance` 变量永远不应低于 `20`,您可以在合约中编写一个像这样的额外函数:
```
function echidna_check_balance() public returns (bool) {
return(balance >= 20);
}
```
要检查这些不变量,请运行:
```
$ echidna myContract.sol
```
一个带有测试的示例合约可以在 [tests/solidity/basic/flags.sol](tests/solidity/basic/flags.sol) 中找到。要运行它,您应该执行:
```
$ echidna tests/solidity/basic/flags.sol
```
Echidna 应该找到一个证伪 `echidna_sometimesfalse` 的调用序列,并且应该无法找到证伪 `echidna_alwaystrue` 的输入。
### 收集和可视化覆盖率
在完成一个测试活动后,Echidna 可以在一个通过 `corpusDir` 配置选项指定的特殊目录中保存最大化覆盖率的**语料库**。该目录将包含两个条目:(1) 一个名为 `coverage` 的目录,其中包含可由 Echidna 重放的 JSON 文件;(2) 一个名为 `covered.txt` 的纯文本文件,这是带有覆盖率注释的源代码副本。
如果您运行 `tests/solidity/basic/flags.sol` 示例,Echidna 将在 `coverage` 目录中保存一些序列化交易的文件,以及一个 `covered.$(date +%s).txt` 文件,其中包含以下行:
```
*r | function set0(int val) public returns (bool){
* | if (val % 100 == 0)
* | flag0 = false;
}
*r | function set1(int val) public returns (bool){
* | if (val % 10 == 0 && !flag0)
* | flag1 = false;
}
```
我们的工具用以下“行标记”标记语料库中的每个执行跟踪:
* `*` 如果执行以 STOP 结束
* `r` 如果执行以 REVERT 结束
* `o` 如果执行以 gas 耗尽错误结束
* `e` 如果执行以任何其他错误(零除、断言失败等)结束
### 对智能合约构建系统的支持
Echidna 可以测试使用不同智能合约构建系统编译的合约,包括 [Foundry](https://book.getfoundry.sh/)、[Hardhat](https://hardhat.org/) 和 [Truffle](https://archive.trufflesuite.com/),通过 [crytic-compile](https://github.com/crytic/crytic-compile) 实现。要使用当前的编译框架调用 Echidna,请使用 `echidna .`。
除此之外,Echidna 支持两种测试复杂合约的模式。首先,可以[利用现有的网络状态](https://secure-contracts.com/program-analysis/echidna/advanced/state-network-forking.html)并将其作为 Echidna 的基础状态。其次,Echidna 可以通过在 CLI 中传入相应的 Solidity 源代码来调用任何具有已知 ABI 的合约。在配置中使用 `allContracts: true` 来开启此功能。
### Echidna 速成课程
我们的 [Building Secure Smart Contracts](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna#echidna-tutorial) 仓库包含关于 Echidna 的速成课程,包括示例、课程和练习。
### 在 GitHub Actions 工作流中使用 Echidna
有一个 Echidna 操作可用于将 `echidna` 作为 GitHub Actions 工作流的一部分运行。有关使用说明和示例,请参阅 [crytic/echidna-action](https://github.com/crytic/echidna-action) 仓库。
### 配置选项
Echidna 的 CLI 可用于选择要测试的合约并加载配置文件。
```
$ echidna contract.sol --contract TEST --config config.yaml
```
配置文件允许用户选择 EVM 和测试生成参数。可以在 [tests/solidity/basic/default.yaml](tests/solidity/basic/default.yaml) 中找到包含默认选项的完整且带有注释的配置文件示例。
有关可用配置选项的更多详细信息,请参阅[文档](https://secure-contracts.com/program-analysis/echidna/configuration.html)。
Echidna 支持三种不同的输出驱动程序。有默认的 `text` 驱动程序、`json` 驱动程序和 `none` 驱动程序,后者应抑制所有 `stdout` 输出。JSON 驱动程序按如下方式报告整体测试活动。
```
Campaign = {
"success" : bool,
"error" : string?,
"tests" : [Test],
"seed" : number,
"coverage" : Coverage
}
Test = {
"contract" : string,
"name" : string,
"status" : string,
"error" : string?,
"testType" : string,
"transactions" : [Transaction]?
}
Transaction = {
"contract" : string,
"function" : string,
"arguments" : [string]?,
"gas" : number,
"gasprice" : number
}
```
`Coverage` 是一个描述某些增加覆盖率的调用的字典。这些接口稍后可能会更改,以变得更加用户友好。`testType` 将是 `property` 或 `assertion`,而 `status` 总是取值为 `fuzzing`、`shrinking`、`solved`、`passed` 或 `error`。
### 调试性能问题
诊断 Echidna 性能问题的一种方法是在启用分析的情况下运行 `echidna`。
要在启用基本分析的情况下运行 Echidna,请将 `+RTS -p -s` 添加到您原来的 `echidna` 命令中:
```
$ nix develop # alternatively nix-shell
$ cabal --enable-profiling run echidna -- ... +RTS -p -s
$ less echidna.prof
```
这会生成一个报告文件 (`echidna.prof`),显示哪些函数占用了最多的 CPU 和内存。
如果基本分析没有帮助,您可以使用更[高级的分析技术](https://haskell.foundation/hs-opt-handbook.github.io/src/Measurement_Observation/Haskell_Profiling/eventlog.html)。
我们观察到的导致性能问题的常见原因:
- 在热路径中调用了昂贵的函数
- 延迟数据构造器累积了 thunk
- 在热路径中使用了低效的数据结构
检查这些是一个很好的起点。如果您怀疑某些计算过于延迟并泄漏内存,可以使用 `Control.DeepSeq` 中的 `force` 来确保它被求值。
## 限制和已知问题
EVM 模拟和测试很难。Echidna 在最新版本中存在一些限制。其中一些继承自 [hevm](https://github.com/argotorg/hevm),而另一些则是设计/性能决策的结果或仅仅是我们代码中的错误。我们在此列出它们,包括其相应的问题和状态(“wont fix”、“on hold”、“in review”、“fixed”)。标记为“fixed”的问题预计将包含在下一个 Echidna 版本中。
| 描述 | 问题 | 状态 |
| :--- | :---: | :---: |
| Vyper 支持有限 | [#652](https://github.com/crytic/echidna/issues/652) | *wont fix* |
| 测试的库支持有限 | [#651](https://github.com/crytic/echidna/issues/651) | *wont fix* |
## 安装
### 预编译二进制文件
在开始之前,请确保 Slither 已[安装](https://github.com/crytic/slither) (`pip3 install slither-analyzer --user`)。
如果您想在 Linux 或 MacOS 上快速测试 Echidna,我们在[发布页面](https://github.com/crytic/echidna/releases)提供了在 Ubuntu 上构建的静态链接 Linux 二进制文件和主要静态 MacOS 二进制文件。您也可以从我们的 [CI 流水线](https://github.com/crytic/echidna/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush)获取相同类型的二进制文件,只需点击提交即可找到 Linux 或 MacOS 的二进制文件。
### Homebrew (macOS / Linux)
如果您的 Mac 或 Linux 机器上安装了 Homebrew,可以通过运行 `brew install echidna` 来安装 Echidna 及其所有依赖项(Slither、crytic-compile)。
您也可以通过运行 `brew install --HEAD echidna` 来编译和安装最新的 `master` 分支代码。
您可以在 [`echidna` Homebrew Formula](https://formulae.brew.sh/formula/echidna) 页面获取更多信息。该 formula 本身作为 [homebrew-core 仓库](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/e/echidna.rb)的一部分进行维护。
### Docker 容器
如果您更喜欢使用预构建的 Docker 容器,请查看我们的 [docker 包](https://github.com/orgs/crytic/packages?repo_name=echidna),它是通过 GitHub Actions 自动构建的。`echidna` 容器基于 `ubuntu:noble`,旨在成为一个足够小且灵活的镜像以供使用。它提供了预构建版本的 `echidna`,以及 `slither`、`crytic-compile`、`solc-select`、`nvm` 和 `foundry`(包括 `forge`、`cast`、`anvil` 和 `chisel`),大小在 200 MB 以内。
请注意,容器镜像目前仅在 x86 系统上构建。由于 CPU 模拟会导致性能损失,不建议在 ARM 设备(如 Mac M1 系统)上运行它们。
Docker 容器镜像有不同的标签可用:
| 标签 | 标签中的构建内容
|---------------|-------------
| `vx.y.z` | 对应于 `vx.y.z` 版本的构建
| `latest` | 最新的 Echidna 标记版本。
| `edge` | 默认分支上的最新提交。
| `testing-foo` | 基于 `foo` 分支的测试构建。
要使用最新的 Echidna 版本交互式运行容器,您可以使用类似以下的命令。它将当前目录映射为容器内的 `/src`,并为您提供一个可以使用 `echidna` 的 shell:
```
$ docker run --rm -it -v "$(pwd)":/src ghcr.io/crytic/echidna/echidna
```
否则,如果您想在本地构建最新版本的 Echidna,我们建议使用 Docker。在此仓库的克隆中,运行以下命令来构建 Docker 容器镜像:
```
$ docker build -t echidna -f docker/Dockerfile --target final-ubuntu .
```
然后,您可以在本地运行 `echidna` 镜像。例如,要安装 solc 0.5.7 并检查 `tests/solidity/basic/flags.sol`,您可以运行:
```
$ docker run -it -v "$(pwd)":/src echidna bash -c "solc-select install 0.5.7 && solc-select use 0.5.7 && echidna /src/tests/solidity/basic/flags.sol"
```
Docker 镜像还包括用于全面智能合约开发和测试的 Foundry 工具。您可以直接在容器中使用 `forge`、`cast`、`anvil` 和 `chisel`:
```
# 运行一个包含 Foundry 工具的交互式 Shell
$ docker run -it -v "$(pwd)":/src echidna bash
# 在容器内,您可以使用 Foundry 命令:
$ forge --version
$ cast --version
$ anvil --version
$ chisel --version
# 示例:初始化一个新的 Foundry 项目
$ forge init my-project
$ cd my-project
$ forge build
$ forge test
```
### 使用 Stack 构建
如果您更喜欢从源代码构建,请使用 [Stack](https://docs.haskellstack.org/en/stable/)。`stack install` 应该在 `~/.local/bin` 中构建和编译 `echidna`。您需要链接 libreadline 和 libsecp256k1(在启用 recovery 的情况下构建),这应该通过您选择的包管理器安装。您还需要安装最新版本的 [libff](https://github.com/scipr-lab/libff)。请参阅我们的 [CI 测试](.github/scripts/install-libff.sh)以获取指导。
某些 Linux 发行版不随附 Haskell 需要的某些静态库,例如 Arch Linux,这将导致 `stack build` 因链接错误而失败,因为我们使用了 `-static` 标志。在这种情况下,请使用 `--flag echidna:-static` 来生成动态链接的二进制文件。
如果您遇到与链接相关的构建错误,请尝试调整 `--extra-include-dirs` 和 `--extra-lib-dirs`。
### 使用 Nix 构建(原生支持 Apple M1 系统)
[Nix 用户](https://nixos.org/download/)可以使用以下命令安装最新的 Echidna:
```
$ nix-env -i -f https://github.com/crytic/echidna/tarball/master
```
启用 flakes 后,您可以直接从此仓库运行 Echidna:
```
$ nix run github:crytic/echidna # master
$ nix run github:crytic/echidna/v2.1.1 # specific ref (tag/branch/commit)
```
要为非 Nix macOS 系统构建独立版本,以下命令将构建一个主要静态的二进制 Echidna。这也可以在 Linux 系统上用于生成完全静态的二进制文件。
```
$ nix build .#echidna-redistributable
```
Nix 将自动安装开发所需的所有依赖项,包括 `crytic-compile` 和 `solc`。开始开发 Echidna 的一种快速方法:
```
$ git clone https://github.com/crytic/echidna
$ cd echidna
$ nix develop # alternatively nix-shell
[nix-shell]$ cabal run echidna
[nix-shell]$ cabal run tests
[nix-shell]$ cabal new-repl
```
## Echidna 的公开使用
### 属性测试套件
这是使用 Echidna 进行测试的智能合约项目的部分列表:
* [Curvance](https://github.com/curvance/Curvance-CantinaCompetition/tree/CodeFAQAndAdjustments/tests/fuzzing)
* [Primitive](https://github.com/primitivefinance/rmm-core/tree/main/contracts/crytic)
* [Uniswap-v3](https://github.com/search?q=org%3AUniswap+echidna&type=commits)
* [Balancer](https://github.com/balancer/balancer-core/tree/master/echidna)
* [MakerDAO vest](https://github.com/makerdao/dss-vest/pull/16)
* [Optimism DAI Bridge](https://github.com/makerdao/optimism-dai-bridge/blob/master/contracts/test/DaiEchidnaTest.sol)
* [WETH10](https://github.com/WETH10/WETH10/tree/main/contracts/fuzzing)
* [Y](https://github.com/yieldprotocol/fyDai/pull/312)
* [Convexity Protocol](https://github.com/opynfinance/ConvexityProtocol/tree/dev/contracts/echidna)
* [Aragon Staking](https://github.com/aragon/staking/blob/82bf54a3e11ec4e50d470d66048a2dd3154f940b/packages/protocol/contracts/test/lib/EchidnaStaking.sol)
* [Centre Token](https://github.com/circlefin/stablecoin-evm/tree/release-2024-03-15T223309/echidna_tests)
* [Tokencard](https://github.com/tokencard/contracts/tree/master/tools/echidna)
* [Minimalist USD Stablecoin](https://github.com/usmfum/USM/pull/41)
### 安全审计
以下展示了使用 Echidna 发现漏洞的公开安全审计
- [Advanced Blockchain](https://github.com/trailofbits/publications/blob/master/reviews/AdvancedBlockchain.pdf)
- [Amp](https://github.com/trailofbits/publications/blob/master/reviews/amp.pdf)
- [Ampleforth](https://github.com/trailofbits/publications/blob/master/reviews/ampleforth.pdf)
- [Atlendis](https://github.com/trailofbits/publications/blob/master/reviews/2023-03-atlendis-atlendissmartcontracts-securityreview.pdf)
- [Balancer](https://github.com/trailofbits/publications/blob/master/reviews/2021-04-balancer-balancerv2-securityreview.pdf)
- [Basis](https://github.com/trailofbits/publications/blob/master/reviews/basis.pdf)
- [Dai](https://github.com/trailofbits/publications/blob/master/reviews/mc-dai.pdf)
- [Frax](https://github.com/trailofbits/publications/blob/master/reviews/FraxQ22022.pdf)
- [Liquity](https://github.com/trailofbits/publications/blob/master/reviews/LiquityProtocolandStabilityPoolFinalReport.pdf)
- [LooksRare](https://github.com/trailofbits/publications/blob/master/reviews/LooksRare.pdf)
- [Maple](https://github.com/trailofbits/publications/blob/master/reviews/2022-03-maplefinance-securityreview.pdf)
- [Optimism](https://github.com/trailofbits/publications/blob/master/reviews/2022-11-optimism-securityreview.pdf)
- [Opyn](https://github.com/trailofbits/publications/blob/master/reviews/Opyn.pdf)
- [Origin Dollar](https://github.com/trailofbits/publications/blob/master/reviews/OriginDollar.pdf)
- [Origin](https://github.com/trailofbits/publications/blob/master/reviews/origin.pdf)
- [Paxos](https://github.com/trailofbits/publications/blob/master/reviews/paxos.pdf)
- [Primitive](https://github.com/trailofbits/publications/blob/master/reviews/Primitive.pdf)
- [RocketPool](https://github.com/trailofbits/publications/blob/master/reviews/RocketPool.pdf)
- [Seaport](https://github.com/trailofbits/publications/blob/master/reviews/SeaportProtocol.pdf)
- [Set Protocol](https://github.com/trailofbits/publications/blob/master/reviews/setprotocol.pdf)
- [Shell protocol](https://github.com/trailofbits/publications/blob/master/reviews/ShellProtocolv2.pdf)
- [Sherlock](https://github.com/trailofbits/publications/blob/master/reviews/Sherlockv2.pdf)
- [Pegasys Pantheon](https://github.com/trailofbits/publications/blob/master/reviews/pantheon.pdf)
- [TokenCard](https://github.com/trailofbits/publications/blob/master/reviews/TokenCard.pdf)
- [Uniswap](https://github.com/trailofbits/publications/blob/master/reviews/UniswapV3Core.pdf)
- [Yearn](https://github.com/trailofbits/publications/blob/master/reviews/YearnV2Vaults.pdf)
- [Yield](https://github.com/trailofbits/publications/blob/master/reviews/YieldProtocol.pdf)
- [88mph](https://github.com/trailofbits/publications/blob/master/reviews/88mph.pdf)
- [0x](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf)
### 战利品
以下安全漏洞是由 Echidna 发现的。如果您使用我们的工具发现了安全漏洞,请提交包含相关信息的 PR。
| 项目 | 漏洞 | 日期 |
|--|--|--|
[0x Protocol](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf) | 如果订单无法成交,则无法取消 | 2019年10月
[0x Protocol](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf) | 如果订单可以用零部分成交,那么它可以用一个代币部分成交 | 2019年10月
[0x Protocol](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf) | cobbdouglas 函数在使用有效输入参数时不会回退 | 2019年10月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 攻击者无法从公共池中窃取资产 | 2020年1月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 攻击者无法通过 joinPool 生成免费的池代币 | 2020年1月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 调用 joinPool-exitPool 不会导致免费的池代币 | 2020年1月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 调用 exitswapExternAmountOut 不会导致免费资产 | 2020年1月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | [关闭金库需要持有铸造的全部 LUSD 金额](https://github.com/liquity/dev/blob/echidna_ToB_final/packages/contracts/contracts/TestContracts/E2E.sol#L242-L298) | 2020年12月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | [金库可能被不当移除](https://github.com/liquity/dev/blob/echidna_ToB_final/packages/contracts/contracts/TestContracts/E2E.sol#L242-L298) | 2020年12月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | 初始赎回可能会意外回退 | 2020年12月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | 没有赎回的赎回可能仍然返回成功 | 2020年12月
[Origin Dollar](https://github.com/trailofbits/publications/blob/master/reviews/OriginDollar.pdf) | 用户被允许转移超过其持有的代币 | 2020年11月
[Origin Dollar](https://github.com/trailofbits/publications/blob/master/reviews/OriginDollar.pdf) | 用户余额可能大于总供应量 | 2020年11月
[Yield Protocol](https://github.com/trailofbits/publications/blob/master/reviews/YieldProtocol.pdf) | 用于买卖代币的算术计算不精确 | 2020年8月
### 研究
我们还可以使用 Echidna 重现智能合约模糊测试论文中的研究示例,以展示它能多快找到解决方案。所有这些问题都可以在笔记本电脑上几秒钟到一两分钟内解决。
| 来源 | 代码
|--|--
[Using automatic analysis tools with MakerDAO contracts](https://forum.openzeppelin.com/t/using-automatic-analysis-tools-with-makerdao-contracts/1021) | [SimpleDSChief](https://github.com/crytic/echidna/blob/master/tests/solidity/research/vera_dschief.sol)
[Integer precision bug in Sigma Prime](https://github.com/muellerberndt/sabre#example-2-integer-precision-bug) | [VerifyFunWithNumbers](https://github.com/crytic/echidna/blob/master/tests/solidity/research/solcfuzz_funwithnumbers.sol)
[Learning to Fuzz from Symbolic Execution with Application to Smart Contracts](https://files.sri.inf.ethz.ch/website/papers/ccs19-ilf.pdf) | [Crowdsale](https://github.com/crytic/echidna/blob/master/tests/solidity/research/ilf_crowdsale.sol)
[Harvey: A Greybox Fuzzer for Smart Contracts](https://arxiv.org/abs/1905.06944) | [Foo](https://github.com/crytic/echidna/blob/master/tests/solidity/research/harvey_foo.sol), [Baz](https://github.com/crytic/echidna/blob/master/tests/solidity/research/harvey_baz.sol)
### 学术出版物
| 论文标题 | 出版物 | 出版日期 |
| --- | --- | --- |
| [echidna-parade: Diverse multicore smart contract fuzzing](https://agroce.github.io/issta21.pdf) | [ISSTA 2021](https://conf.researchr.org/home/issta-2021) | 2021年7月 |
| [Echidna: Effective, usable, and fast fuzzing for smart contracts](https://agroce.github.io/issta20.pdf) | [ISSTA 2020](https://conf.researchr.org/home/issta-2020) | 2020年7月 |
| [Echidna: A Practical Smart Contract Fuzzer](https://github.com/trailofbits/publications/blob/master/papers/echidna_fc_poster.pdf) | [FC 2020](https://fc20.ifca.ai/program.html) | 2020年2月 |
如果您在学术工作中使用 Echidna,请考虑申请 [Crytic 1万美元研究奖](https://blog.trailofbits.com/2019/11/13/announcing-the-crytic-10k-research-prize/)。
## 获取帮助
请随时访问我们在 [Empire Hacking](https://slack.empirehacking.nyc/) 中的 #ethereum slack 频道,以获取使用或扩展 Echidna 的帮助。
* 从查看这些简单的 [Echidna 不变量](tests/solidity/basic/flags.sol)开始
* 考虑直接[发送电子邮件](mailto:opensource@trailofbits.com)给 Echidna 开发团队以获取更详细的问题
## 许可证
Echidna 根据 [AGPLv3 许可证](https://github.com/crytic/echidna/blob/master/LICENSE)授权和分发。

Echidna 是一种奇怪的生物,它吃虫子并且具有高度的电敏感性(向 Jacob Stanley 致歉)
更严肃地说,Echidna 是一个 Haskell 程序,专为以太坊智能合约的模糊测试/基于属性的测试而设计。它使用基于[合约 ABI](https://docs.soliditylang.org/en/develop/abi-spec.html) 的复杂基于语法的模糊测试活动,来证伪用户定义的谓词或 [Solidity 断言](https://docs.soliditylang.org/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions)。我们在设计 Echidna 时考虑到了模块化,因此可以轻松扩展它以包含新的变异或在特定情况下测试特定合约。
## 功能特性
* 生成针对实际代码定制的输入
* 可选的语料库收集、变异和覆盖引导,以发现更深层的错误
* 由 [Slither](https://github.com/crytic/slither) 驱动,在模糊测试活动之前提取有用信息
* 源代码集成,用于识别模糊测试活动后覆盖了哪些行
* 交互式终端 UI、纯文本或 JSON 输出
* 自动化测试用例最小化,便于快速分类
* 无缝集成到开发工作流中
……以及[一个精美的高分辨率手工制作徽标](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/0a2a752d0d232451.png)。
## 用法
### 执行测试运行器
Echidna 的核心功能是一个名为 `echidna` 的可执行文件,它接收一个合约和一个不变量列表(应该始终保持为真的属性)作为输入。对于每个不变量,它生成随机的合约调用序列,并检查不变量是否成立。如果它能找到某种方法来证伪该不变量,它会打印出实现这一点的调用序列。如果找不到,您就可以在一定程度上确信合约是安全的。
### 编写不变量
不变量表示为名称以 `echidna_` 开头、没有参数并返回布尔值的 Solidity 函数。例如,如果您有一个 `balance` 变量永远不应低于 `20`,您可以在合约中编写一个像这样的额外函数:
```
function echidna_check_balance() public returns (bool) {
return(balance >= 20);
}
```
要检查这些不变量,请运行:
```
$ echidna myContract.sol
```
一个带有测试的示例合约可以在 [tests/solidity/basic/flags.sol](tests/solidity/basic/flags.sol) 中找到。要运行它,您应该执行:
```
$ echidna tests/solidity/basic/flags.sol
```
Echidna 应该找到一个证伪 `echidna_sometimesfalse` 的调用序列,并且应该无法找到证伪 `echidna_alwaystrue` 的输入。
### 收集和可视化覆盖率
在完成一个测试活动后,Echidna 可以在一个通过 `corpusDir` 配置选项指定的特殊目录中保存最大化覆盖率的**语料库**。该目录将包含两个条目:(1) 一个名为 `coverage` 的目录,其中包含可由 Echidna 重放的 JSON 文件;(2) 一个名为 `covered.txt` 的纯文本文件,这是带有覆盖率注释的源代码副本。
如果您运行 `tests/solidity/basic/flags.sol` 示例,Echidna 将在 `coverage` 目录中保存一些序列化交易的文件,以及一个 `covered.$(date +%s).txt` 文件,其中包含以下行:
```
*r | function set0(int val) public returns (bool){
* | if (val % 100 == 0)
* | flag0 = false;
}
*r | function set1(int val) public returns (bool){
* | if (val % 10 == 0 && !flag0)
* | flag1 = false;
}
```
我们的工具用以下“行标记”标记语料库中的每个执行跟踪:
* `*` 如果执行以 STOP 结束
* `r` 如果执行以 REVERT 结束
* `o` 如果执行以 gas 耗尽错误结束
* `e` 如果执行以任何其他错误(零除、断言失败等)结束
### 对智能合约构建系统的支持
Echidna 可以测试使用不同智能合约构建系统编译的合约,包括 [Foundry](https://book.getfoundry.sh/)、[Hardhat](https://hardhat.org/) 和 [Truffle](https://archive.trufflesuite.com/),通过 [crytic-compile](https://github.com/crytic/crytic-compile) 实现。要使用当前的编译框架调用 Echidna,请使用 `echidna .`。
除此之外,Echidna 支持两种测试复杂合约的模式。首先,可以[利用现有的网络状态](https://secure-contracts.com/program-analysis/echidna/advanced/state-network-forking.html)并将其作为 Echidna 的基础状态。其次,Echidna 可以通过在 CLI 中传入相应的 Solidity 源代码来调用任何具有已知 ABI 的合约。在配置中使用 `allContracts: true` 来开启此功能。
### Echidna 速成课程
我们的 [Building Secure Smart Contracts](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna#echidna-tutorial) 仓库包含关于 Echidna 的速成课程,包括示例、课程和练习。
### 在 GitHub Actions 工作流中使用 Echidna
有一个 Echidna 操作可用于将 `echidna` 作为 GitHub Actions 工作流的一部分运行。有关使用说明和示例,请参阅 [crytic/echidna-action](https://github.com/crytic/echidna-action) 仓库。
### 配置选项
Echidna 的 CLI 可用于选择要测试的合约并加载配置文件。
```
$ echidna contract.sol --contract TEST --config config.yaml
```
配置文件允许用户选择 EVM 和测试生成参数。可以在 [tests/solidity/basic/default.yaml](tests/solidity/basic/default.yaml) 中找到包含默认选项的完整且带有注释的配置文件示例。
有关可用配置选项的更多详细信息,请参阅[文档](https://secure-contracts.com/program-analysis/echidna/configuration.html)。
Echidna 支持三种不同的输出驱动程序。有默认的 `text` 驱动程序、`json` 驱动程序和 `none` 驱动程序,后者应抑制所有 `stdout` 输出。JSON 驱动程序按如下方式报告整体测试活动。
```
Campaign = {
"success" : bool,
"error" : string?,
"tests" : [Test],
"seed" : number,
"coverage" : Coverage
}
Test = {
"contract" : string,
"name" : string,
"status" : string,
"error" : string?,
"testType" : string,
"transactions" : [Transaction]?
}
Transaction = {
"contract" : string,
"function" : string,
"arguments" : [string]?,
"gas" : number,
"gasprice" : number
}
```
`Coverage` 是一个描述某些增加覆盖率的调用的字典。这些接口稍后可能会更改,以变得更加用户友好。`testType` 将是 `property` 或 `assertion`,而 `status` 总是取值为 `fuzzing`、`shrinking`、`solved`、`passed` 或 `error`。
### 调试性能问题
诊断 Echidna 性能问题的一种方法是在启用分析的情况下运行 `echidna`。
要在启用基本分析的情况下运行 Echidna,请将 `+RTS -p -s` 添加到您原来的 `echidna` 命令中:
```
$ nix develop # alternatively nix-shell
$ cabal --enable-profiling run echidna -- ... +RTS -p -s
$ less echidna.prof
```
这会生成一个报告文件 (`echidna.prof`),显示哪些函数占用了最多的 CPU 和内存。
如果基本分析没有帮助,您可以使用更[高级的分析技术](https://haskell.foundation/hs-opt-handbook.github.io/src/Measurement_Observation/Haskell_Profiling/eventlog.html)。
我们观察到的导致性能问题的常见原因:
- 在热路径中调用了昂贵的函数
- 延迟数据构造器累积了 thunk
- 在热路径中使用了低效的数据结构
检查这些是一个很好的起点。如果您怀疑某些计算过于延迟并泄漏内存,可以使用 `Control.DeepSeq` 中的 `force` 来确保它被求值。
## 限制和已知问题
EVM 模拟和测试很难。Echidna 在最新版本中存在一些限制。其中一些继承自 [hevm](https://github.com/argotorg/hevm),而另一些则是设计/性能决策的结果或仅仅是我们代码中的错误。我们在此列出它们,包括其相应的问题和状态(“wont fix”、“on hold”、“in review”、“fixed”)。标记为“fixed”的问题预计将包含在下一个 Echidna 版本中。
| 描述 | 问题 | 状态 |
| :--- | :---: | :---: |
| Vyper 支持有限 | [#652](https://github.com/crytic/echidna/issues/652) | *wont fix* |
| 测试的库支持有限 | [#651](https://github.com/crytic/echidna/issues/651) | *wont fix* |
## 安装
### 预编译二进制文件
在开始之前,请确保 Slither 已[安装](https://github.com/crytic/slither) (`pip3 install slither-analyzer --user`)。
如果您想在 Linux 或 MacOS 上快速测试 Echidna,我们在[发布页面](https://github.com/crytic/echidna/releases)提供了在 Ubuntu 上构建的静态链接 Linux 二进制文件和主要静态 MacOS 二进制文件。您也可以从我们的 [CI 流水线](https://github.com/crytic/echidna/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush)获取相同类型的二进制文件,只需点击提交即可找到 Linux 或 MacOS 的二进制文件。
### Homebrew (macOS / Linux)
如果您的 Mac 或 Linux 机器上安装了 Homebrew,可以通过运行 `brew install echidna` 来安装 Echidna 及其所有依赖项(Slither、crytic-compile)。
您也可以通过运行 `brew install --HEAD echidna` 来编译和安装最新的 `master` 分支代码。
您可以在 [`echidna` Homebrew Formula](https://formulae.brew.sh/formula/echidna) 页面获取更多信息。该 formula 本身作为 [homebrew-core 仓库](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/e/echidna.rb)的一部分进行维护。
### Docker 容器
如果您更喜欢使用预构建的 Docker 容器,请查看我们的 [docker 包](https://github.com/orgs/crytic/packages?repo_name=echidna),它是通过 GitHub Actions 自动构建的。`echidna` 容器基于 `ubuntu:noble`,旨在成为一个足够小且灵活的镜像以供使用。它提供了预构建版本的 `echidna`,以及 `slither`、`crytic-compile`、`solc-select`、`nvm` 和 `foundry`(包括 `forge`、`cast`、`anvil` 和 `chisel`),大小在 200 MB 以内。
请注意,容器镜像目前仅在 x86 系统上构建。由于 CPU 模拟会导致性能损失,不建议在 ARM 设备(如 Mac M1 系统)上运行它们。
Docker 容器镜像有不同的标签可用:
| 标签 | 标签中的构建内容
|---------------|-------------
| `vx.y.z` | 对应于 `vx.y.z` 版本的构建
| `latest` | 最新的 Echidna 标记版本。
| `edge` | 默认分支上的最新提交。
| `testing-foo` | 基于 `foo` 分支的测试构建。
要使用最新的 Echidna 版本交互式运行容器,您可以使用类似以下的命令。它将当前目录映射为容器内的 `/src`,并为您提供一个可以使用 `echidna` 的 shell:
```
$ docker run --rm -it -v "$(pwd)":/src ghcr.io/crytic/echidna/echidna
```
否则,如果您想在本地构建最新版本的 Echidna,我们建议使用 Docker。在此仓库的克隆中,运行以下命令来构建 Docker 容器镜像:
```
$ docker build -t echidna -f docker/Dockerfile --target final-ubuntu .
```
然后,您可以在本地运行 `echidna` 镜像。例如,要安装 solc 0.5.7 并检查 `tests/solidity/basic/flags.sol`,您可以运行:
```
$ docker run -it -v "$(pwd)":/src echidna bash -c "solc-select install 0.5.7 && solc-select use 0.5.7 && echidna /src/tests/solidity/basic/flags.sol"
```
Docker 镜像还包括用于全面智能合约开发和测试的 Foundry 工具。您可以直接在容器中使用 `forge`、`cast`、`anvil` 和 `chisel`:
```
# 运行一个包含 Foundry 工具的交互式 Shell
$ docker run -it -v "$(pwd)":/src echidna bash
# 在容器内,您可以使用 Foundry 命令:
$ forge --version
$ cast --version
$ anvil --version
$ chisel --version
# 示例:初始化一个新的 Foundry 项目
$ forge init my-project
$ cd my-project
$ forge build
$ forge test
```
### 使用 Stack 构建
如果您更喜欢从源代码构建,请使用 [Stack](https://docs.haskellstack.org/en/stable/)。`stack install` 应该在 `~/.local/bin` 中构建和编译 `echidna`。您需要链接 libreadline 和 libsecp256k1(在启用 recovery 的情况下构建),这应该通过您选择的包管理器安装。您还需要安装最新版本的 [libff](https://github.com/scipr-lab/libff)。请参阅我们的 [CI 测试](.github/scripts/install-libff.sh)以获取指导。
某些 Linux 发行版不随附 Haskell 需要的某些静态库,例如 Arch Linux,这将导致 `stack build` 因链接错误而失败,因为我们使用了 `-static` 标志。在这种情况下,请使用 `--flag echidna:-static` 来生成动态链接的二进制文件。
如果您遇到与链接相关的构建错误,请尝试调整 `--extra-include-dirs` 和 `--extra-lib-dirs`。
### 使用 Nix 构建(原生支持 Apple M1 系统)
[Nix 用户](https://nixos.org/download/)可以使用以下命令安装最新的 Echidna:
```
$ nix-env -i -f https://github.com/crytic/echidna/tarball/master
```
启用 flakes 后,您可以直接从此仓库运行 Echidna:
```
$ nix run github:crytic/echidna # master
$ nix run github:crytic/echidna/v2.1.1 # specific ref (tag/branch/commit)
```
要为非 Nix macOS 系统构建独立版本,以下命令将构建一个主要静态的二进制 Echidna。这也可以在 Linux 系统上用于生成完全静态的二进制文件。
```
$ nix build .#echidna-redistributable
```
Nix 将自动安装开发所需的所有依赖项,包括 `crytic-compile` 和 `solc`。开始开发 Echidna 的一种快速方法:
```
$ git clone https://github.com/crytic/echidna
$ cd echidna
$ nix develop # alternatively nix-shell
[nix-shell]$ cabal run echidna
[nix-shell]$ cabal run tests
[nix-shell]$ cabal new-repl
```
## Echidna 的公开使用
### 属性测试套件
这是使用 Echidna 进行测试的智能合约项目的部分列表:
* [Curvance](https://github.com/curvance/Curvance-CantinaCompetition/tree/CodeFAQAndAdjustments/tests/fuzzing)
* [Primitive](https://github.com/primitivefinance/rmm-core/tree/main/contracts/crytic)
* [Uniswap-v3](https://github.com/search?q=org%3AUniswap+echidna&type=commits)
* [Balancer](https://github.com/balancer/balancer-core/tree/master/echidna)
* [MakerDAO vest](https://github.com/makerdao/dss-vest/pull/16)
* [Optimism DAI Bridge](https://github.com/makerdao/optimism-dai-bridge/blob/master/contracts/test/DaiEchidnaTest.sol)
* [WETH10](https://github.com/WETH10/WETH10/tree/main/contracts/fuzzing)
* [Y](https://github.com/yieldprotocol/fyDai/pull/312)
* [Convexity Protocol](https://github.com/opynfinance/ConvexityProtocol/tree/dev/contracts/echidna)
* [Aragon Staking](https://github.com/aragon/staking/blob/82bf54a3e11ec4e50d470d66048a2dd3154f940b/packages/protocol/contracts/test/lib/EchidnaStaking.sol)
* [Centre Token](https://github.com/circlefin/stablecoin-evm/tree/release-2024-03-15T223309/echidna_tests)
* [Tokencard](https://github.com/tokencard/contracts/tree/master/tools/echidna)
* [Minimalist USD Stablecoin](https://github.com/usmfum/USM/pull/41)
### 安全审计
以下展示了使用 Echidna 发现漏洞的公开安全审计
- [Advanced Blockchain](https://github.com/trailofbits/publications/blob/master/reviews/AdvancedBlockchain.pdf)
- [Amp](https://github.com/trailofbits/publications/blob/master/reviews/amp.pdf)
- [Ampleforth](https://github.com/trailofbits/publications/blob/master/reviews/ampleforth.pdf)
- [Atlendis](https://github.com/trailofbits/publications/blob/master/reviews/2023-03-atlendis-atlendissmartcontracts-securityreview.pdf)
- [Balancer](https://github.com/trailofbits/publications/blob/master/reviews/2021-04-balancer-balancerv2-securityreview.pdf)
- [Basis](https://github.com/trailofbits/publications/blob/master/reviews/basis.pdf)
- [Dai](https://github.com/trailofbits/publications/blob/master/reviews/mc-dai.pdf)
- [Frax](https://github.com/trailofbits/publications/blob/master/reviews/FraxQ22022.pdf)
- [Liquity](https://github.com/trailofbits/publications/blob/master/reviews/LiquityProtocolandStabilityPoolFinalReport.pdf)
- [LooksRare](https://github.com/trailofbits/publications/blob/master/reviews/LooksRare.pdf)
- [Maple](https://github.com/trailofbits/publications/blob/master/reviews/2022-03-maplefinance-securityreview.pdf)
- [Optimism](https://github.com/trailofbits/publications/blob/master/reviews/2022-11-optimism-securityreview.pdf)
- [Opyn](https://github.com/trailofbits/publications/blob/master/reviews/Opyn.pdf)
- [Origin Dollar](https://github.com/trailofbits/publications/blob/master/reviews/OriginDollar.pdf)
- [Origin](https://github.com/trailofbits/publications/blob/master/reviews/origin.pdf)
- [Paxos](https://github.com/trailofbits/publications/blob/master/reviews/paxos.pdf)
- [Primitive](https://github.com/trailofbits/publications/blob/master/reviews/Primitive.pdf)
- [RocketPool](https://github.com/trailofbits/publications/blob/master/reviews/RocketPool.pdf)
- [Seaport](https://github.com/trailofbits/publications/blob/master/reviews/SeaportProtocol.pdf)
- [Set Protocol](https://github.com/trailofbits/publications/blob/master/reviews/setprotocol.pdf)
- [Shell protocol](https://github.com/trailofbits/publications/blob/master/reviews/ShellProtocolv2.pdf)
- [Sherlock](https://github.com/trailofbits/publications/blob/master/reviews/Sherlockv2.pdf)
- [Pegasys Pantheon](https://github.com/trailofbits/publications/blob/master/reviews/pantheon.pdf)
- [TokenCard](https://github.com/trailofbits/publications/blob/master/reviews/TokenCard.pdf)
- [Uniswap](https://github.com/trailofbits/publications/blob/master/reviews/UniswapV3Core.pdf)
- [Yearn](https://github.com/trailofbits/publications/blob/master/reviews/YearnV2Vaults.pdf)
- [Yield](https://github.com/trailofbits/publications/blob/master/reviews/YieldProtocol.pdf)
- [88mph](https://github.com/trailofbits/publications/blob/master/reviews/88mph.pdf)
- [0x](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf)
### 战利品
以下安全漏洞是由 Echidna 发现的。如果您使用我们的工具发现了安全漏洞,请提交包含相关信息的 PR。
| 项目 | 漏洞 | 日期 |
|--|--|--|
[0x Protocol](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf) | 如果订单无法成交,则无法取消 | 2019年10月
[0x Protocol](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf) | 如果订单可以用零部分成交,那么它可以用一个代币部分成交 | 2019年10月
[0x Protocol](https://github.com/trailofbits/publications/blob/master/reviews/0x-protocol.pdf) | cobbdouglas 函数在使用有效输入参数时不会回退 | 2019年10月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 攻击者无法从公共池中窃取资产 | 2020年1月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 攻击者无法通过 joinPool 生成免费的池代币 | 2020年1月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 调用 joinPool-exitPool 不会导致免费的池代币 | 2020年1月
[Balancer Core](https://github.com/trailofbits/publications/blob/master/reviews/BalancerCore.pdf) | 调用 exitswapExternAmountOut 不会导致免费资产 | 2020年1月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | [关闭金库需要持有铸造的全部 LUSD 金额](https://github.com/liquity/dev/blob/echidna_ToB_final/packages/contracts/contracts/TestContracts/E2E.sol#L242-L298) | 2020年12月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | [金库可能被不当移除](https://github.com/liquity/dev/blob/echidna_ToB_final/packages/contracts/contracts/TestContracts/E2E.sol#L242-L298) | 2020年12月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | 初始赎回可能会意外回退 | 2020年12月
[Liquity Dollar](https://github.com/trailofbits/publications/blob/master/reviews/Liquity.pdf) | 没有赎回的赎回可能仍然返回成功 | 2020年12月
[Origin Dollar](https://github.com/trailofbits/publications/blob/master/reviews/OriginDollar.pdf) | 用户被允许转移超过其持有的代币 | 2020年11月
[Origin Dollar](https://github.com/trailofbits/publications/blob/master/reviews/OriginDollar.pdf) | 用户余额可能大于总供应量 | 2020年11月
[Yield Protocol](https://github.com/trailofbits/publications/blob/master/reviews/YieldProtocol.pdf) | 用于买卖代币的算术计算不精确 | 2020年8月
### 研究
我们还可以使用 Echidna 重现智能合约模糊测试论文中的研究示例,以展示它能多快找到解决方案。所有这些问题都可以在笔记本电脑上几秒钟到一两分钟内解决。
| 来源 | 代码
|--|--
[Using automatic analysis tools with MakerDAO contracts](https://forum.openzeppelin.com/t/using-automatic-analysis-tools-with-makerdao-contracts/1021) | [SimpleDSChief](https://github.com/crytic/echidna/blob/master/tests/solidity/research/vera_dschief.sol)
[Integer precision bug in Sigma Prime](https://github.com/muellerberndt/sabre#example-2-integer-precision-bug) | [VerifyFunWithNumbers](https://github.com/crytic/echidna/blob/master/tests/solidity/research/solcfuzz_funwithnumbers.sol)
[Learning to Fuzz from Symbolic Execution with Application to Smart Contracts](https://files.sri.inf.ethz.ch/website/papers/ccs19-ilf.pdf) | [Crowdsale](https://github.com/crytic/echidna/blob/master/tests/solidity/research/ilf_crowdsale.sol)
[Harvey: A Greybox Fuzzer for Smart Contracts](https://arxiv.org/abs/1905.06944) | [Foo](https://github.com/crytic/echidna/blob/master/tests/solidity/research/harvey_foo.sol), [Baz](https://github.com/crytic/echidna/blob/master/tests/solidity/research/harvey_baz.sol)
### 学术出版物
| 论文标题 | 出版物 | 出版日期 |
| --- | --- | --- |
| [echidna-parade: Diverse multicore smart contract fuzzing](https://agroce.github.io/issta21.pdf) | [ISSTA 2021](https://conf.researchr.org/home/issta-2021) | 2021年7月 |
| [Echidna: Effective, usable, and fast fuzzing for smart contracts](https://agroce.github.io/issta20.pdf) | [ISSTA 2020](https://conf.researchr.org/home/issta-2020) | 2020年7月 |
| [Echidna: A Practical Smart Contract Fuzzer](https://github.com/trailofbits/publications/blob/master/papers/echidna_fc_poster.pdf) | [FC 2020](https://fc20.ifca.ai/program.html) | 2020年2月 |
如果您在学术工作中使用 Echidna,请考虑申请 [Crytic 1万美元研究奖](https://blog.trailofbits.com/2019/11/13/announcing-the-crytic-10k-research-prize/)。
## 获取帮助
请随时访问我们在 [Empire Hacking](https://slack.empirehacking.nyc/) 中的 #ethereum slack 频道,以获取使用或扩展 Echidna 的帮助。
* 从查看这些简单的 [Echidna 不变量](tests/solidity/basic/flags.sol)开始
* 考虑直接[发送电子邮件](mailto:opensource@trailofbits.com)给 Echidna 开发团队以获取更详细的问题
## 许可证
Echidna 根据 [AGPLv3 许可证](https://github.com/crytic/echidna/blob/master/LICENSE)授权和分发。标签:CISA项目, DeFi安全, EVM, Fuzzing, Haskell, Slither, SOC Prime, Solidity, Web3安全, 云安全监控, 代码覆盖率, 以太坊, 区块链安全, 属性测试, 开发工具, 智能合约, 测试框架, 请求拦截, 静态分析