
Searaify 2.0是以太坊基金會和鏈條支持的以太坊智能合約的安全掃描儀。 Searifify背後的核心研究是在Eth Zurich的安全,可靠和智能的系統實驗室進行的。
它是受歡迎的Securefy Security掃描儀的後繼產品(您可以在此處找到舊版本)。
建造容器:
sudo docker build -t securify .
運行容器:
sudo docker run -it -v <contract-dir-full-path>:/share securify /share/<contract>.sol
注意:要通過Docker運行代碼,其堅固性版本與0.5.12不同,您將需要修改Dockerfile頂部的變量ARG SOLC=0.5.12以指向您的版本。使用正確的版本構建後,您不應遇到錯誤。
以下說明假定已經安裝了Python。除此之外,Securefy需要在系統上安裝solc , souffle和graphviz :
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
按照此處的說明:https://souffle-lang.github.io/download.html
請不要選擇不穩定的版本,因為它可能在任何時候破裂。
sudo apt install graphviz
安裝先決條件後,我們可以設置Python虛擬環境,我們將在該虛擬環境中運行該項目中的腳本。
在項目的根文件夾中,執行以下命令以設置並激活虛擬環境:
virtualenv --python=/usr/bin/python3.7 venv
source venv/bin/activate
驗證python版本實際上是3.7 :
python --version
設置LD_LIBRARY_PATH :
cd <securify_root>/securify/staticanalysis/libfunctors
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`
最後,通過從<securify_root>文件夾中運行以下命令來安裝項目的依賴項:
pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
現在,您可以開始使用Seareify框架了。
請記住:在執行框架的腳本之前,您需要使用以下命令來激活虛擬環境:
source venv/bin/activate
當前,Seareify2僅支持不包含進口聲明的合同的平面合同。
要分析當地合同,簡單地運行:
securify <contract_source>.sol [--use-patterns Pattern1 Pattern2 ...]
或使用Etherscan.io API從區塊鏈下載它:
securify <contract_address> --from-blockchain [--key <key-file>]
請注意,您需要Etherscan.io的API-KEY來使用此功能。
分析針對特定嚴重性水平的合同:
securify <contract_source>.sol [--include-severity Severity1 Severity2]
securify <contract_source>.sol [--exclude-severity Severity1 Severity2]
為了使所有可用模式運行:
securify --list
| ID | 圖案名稱 | 嚴重程度 | Slither ID | SWC ID | 評論 |
|---|---|---|---|---|---|
| 1 | Todamount | 批判的 | - | SWC-114 | |
| 2 | Todreceiver | 批判的 | - | SWC-114 | |
| 3 | Todtransfer | 批判的 | - | SWC-114 | |
| 4 | 不受限制地 | 批判的 | - | SWC-124 | |
| 5 | Right Toleftoverride | 高的 | rtlo | SWC-130 | |
| 6 | Shadowedstatevaria | 高的 | shadowing-state , shadowing-abstract | SWC-119 | |
| 7 | 不受限制的自我毀滅 | 高的 | suicidal | SWC-106 | |
| 8 | 非初始化的州 | 高的 | uninitialized-state | SWC-109 | |
| 9 | 非初始化的距離 | 高的 | uninitialized-storage | SWC-109 | |
| 10 | 不受限制的DelegateCall | 高的 | controlled-delegatecall | SWC-112 | |
| 11 | 道 | 高的 | reentrancy-eth | SWC-107 | |
| 12 | ERC20接口 | 中等的 | erc20-interface | - | |
| 13 | ERC721結界 | 中等的 | erc721-interface | - | |
| 14 | 不正確的平等 | 中等的 | incorrect-equality | SWC-132 | |
| 15 | 鎖定 | 中等的 | locked-ether | - | |
| 16 | 重新進入 | 中等的 | reentrancy-no-eth | SWC-107 | |
| 17 | txorigin | 中等的 | tx-origin | SWC-115 | |
| 18 | 未手持感受 | 中等的 | unchecked-lowlevel | - | |
| 19 | 無限制流 | 中等的 | unchecked-send | SWC-105 | |
| 20 | 非專業的local | 中等的 | uninitialized-local | SWC-109 | |
| 21 | 未使用的記錄 | 中等的 | unused-return | SWC-104 | |
| 22 | Shadowedbuiltin | 低的 | shadowing-builtin | - | |
| 23 | Shadowedlocalvarable | 低的 | shadowing-local | - | |
| 24 | CallTodeFaultConstructor? | 低的 | void-cst | - | |
| 25 | Callinloop | 低的 | calls-loop | SWC-104 | |
| 26 | 重新進入 | 低的 | reentrancy-benign | SWC-107 | |
| 27 | 時間戳 | 低的 | timestamp | SWC-116 | |
| 28 | 組裝 | 資訊 | assembly | - | |
| 29 | ERC20索引 | 資訊 | erc20-indexed | - | |
| 30 | LowlevelCalls | 資訊 | low-level-calls | - | |
| 31 | 命名 | 資訊 | naming-convention | - | |
| 32 | 解決方案 | 資訊 | solc-version | SWC-103 | |
| 33 | 無用的州 | 資訊 | unused-state | - | |
| 34 | toomanynigits | 資訊 | too-many-digits | - | |
| 35 | 構成 | 資訊 | constable-states | - | |
| 36 | 外部功能 | 資訊 | external-function | - | |
| 37 | StateVariablesDefaultVisible | 資訊 | - | SWC-108 |
由於固體編譯器對其進行檢查(VER。0.5.8):
constant-functiondeprecated-standardspragma以下SWC漏洞不適用於具有pragma> = 5.8的堅固合同,因此未通過Seareify檢查: