Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
スマートコントラクトの監査について
Search
yudetamago
September 25, 2018
Technology
640
2
Share
スマートコントラクトの監査について
yudetamago
September 25, 2018
More Decks by yudetamago
See All by yudetamago
ブロックチェーンとIndexer
yudetamago
0
970
Unityでブロックチェーンアプリを作る
yudetamago
0
1.9k
DApps開発特有の_ハマりポイントご紹介.pdf
yudetamago
1
1.5k
DApps開発事例 ~CryptoCrystal概要編~
yudetamago
3
340
Gasを誰が払うのか問題について
yudetamago
5
4.7k
Solidityの複数コントラク ト連携を色々試してる話
yudetamago
1
2.4k
Dapps開発におけるSoliidityのはまりどころ
yudetamago
3
2.4k
Other Decks in Technology
See All in Technology
Dynamic Workersについて
yusukebe
2
570
TypeScript Compiler APIとPHP-Parserを活用し、TypeScriptとPHPで型を共有する
shuta13
0
350
AIガバナンス実践 - 生成AIコネクタのデータ漏洩リスクと実務対策
knishioka
0
170
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
1.2k
形式手法特論:公平性制約の位相的特徴づけ #kernelvm / Kernel VM Study Kansai 12th
ytaka23
1
700
Claude Codeを組織で使いこなす— サーバサイドAIエージェント運用の実践知
techtekt
PRO
0
190
Sony_KMP_Journey_KotlinConf2026
sony
2
210
AI活用を推進するために ファインディが下した、一つの小さな決断
starfish719
0
220
ルールやカスタム機能、どう使う?理想の出力を引き出すために今知りたいIBM Bob 5つの機能
muehara
1
310
Platform engineering for developers, architects & the rest of us (AI agents)
danielbryantuk
0
180
JEP 522 Deep Dive - G1 GC同期コスト削減によるスループット向上を徹底検証&解説
tabatad
1
690
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
380
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Typedesign – Prime Four
hannesfritz
42
3.1k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
210
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
160
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Designing for Timeless Needs
cassininazir
1
250
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.1k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
150
Transcript
スマートコントラクトの 監査について ゆで卵(@takayukib) 2018/9/25 blockchain.tokyo #12
⾃⼰紹介的なやつ 名前:ゆで卵(@takayukib) 所属:フリーランス、トークンポケット株式会社 その他 • CryptoCrystalというDappsを作っています • 株式会社LayerXでもお仕事してます 1
監査は何故必要か üスマートコントラクトはデプロイすると基 本的にはアップデート出来ない ü通貨・トークンを扱うためミッションクリ ティカルである 2
今⽇のテーマ スマートコントラクトの開発者・監査者 どちらもが幸せになれるように 良いコードを書きましょう! 3
4 監査対象になるもの(⼀例) スコープ ü セキュリティ ü トークンの仕様 ü トラストレス性 ü
アーキテクチャ ü ⾔語の慣習 ü WPとの整合性 内容 ü コード本体 ü デプロイ⽤スクリプト ü ホワイトペーパー(WP) ü (テストコード) 参考: https://www.smartcontractsecurityalliance.com/
監査内容の各例 5
セキュリティ(よくある例) üオーバーフロー 基本的に計算部分は全てSafeMath等のライブラリを使うことを推奨 üfor loopのindexの上限 forループの上限値が無いとblock gas limitをオーバーするリスクがある üアクセス制御の付け忘れ onlyOwnerや、特定のコントラクトからのみ呼ばれるなど
6
アクセス制御の例(Proxy Pattern) 7 Main Contract Proxy Contract Deployer Another User
onlyOwner onlyProxy Contract これを付ける 参考: https://blog.zeppelinos.org/proxy-patterns/
unbounded loopの例 function addTokenGrant(address _grantee, uint256 _value) external onlyOwner {
… for (uint i = 0; i < tokenGrantees.length; i++). { require(tokenGrantees[i] != _grantee); } 8 block gas limitを超えないように 常にループ回数の上限は確認する https://blog.zeppelin.solutions/kin-token-audit-121788c06fe これ
トラストレス性 極⼒onlyOwner等のトラストレス性を無くすものは付けないよう にする。 例外と思われるもの üProxy Patternでのコントラクトアップデート(ownerが必要) üCloudSaleのロックアップ期間の設定(法律改正によって変わる可能性があるなど) 9 参考: SolidifiedによるCycled
ICOに対するトラストレス性の指摘 https://github.com/solidified- platform/audits/blob/22cda93a7897b4e2f2b0f3689b170eea918fc85d/Audit%20Report%20- %20Cycled%20ICO%20%5B04.25.18%5D.pdf
トークンの仕様(ERC20の例) 基本的にはOpenZeppelin Solidityを 使っていれば問題なし。 標準以外の機能を追加するとき ütransfer、transferFromでboolを返す üトークンのdistribution、airdropはトークン⾃体のコントラクトと分ける 10
⾔語の標準的な慣習(Solidityの例) üOpenZeppelin Solidityを使う üコンパイラのバージョンを最新にする üuint, uint256などの表記ゆれを無くす üLinter(solium, solhint)を使う 11 ⼀番重要
アーキテクチャ 12 ü よく知られているパ ターンを使う ü 図があると良い Facadeパターンの例 https://github.com/cryptocrystalio/crypto crystal-
bounty/blob/118cd744ffc2d8ff0682ef0638 43c4704133fab5/basic.md
アーキテクチャの良い例 0x protocol 2.0.0 specification (ERC20 Exchange) 13 https://github.com/ConsenSys/0x_audit_report_2018-07-23 https://github.com/0xProject/0x-protocol-
specification/blob/189eaf696b35e021860bd9a4f147ed0eed148441/v2/v2-specification.md
14 今後の展望と課題
auditの⾃動化(サービス) Quantstampの例 https://quantstamp.com/public-reports reentrancyのチェックや、assertがfailする条件などを⾃動で確 かめることが出来る 15
auditの⾃動化(ツール) mythril https://github.com/ConsenSys/mythril 16 ※厳密にはconcolic 参考: https://github.com/b-mueller/laser-ethereum üシンボリック実⾏(※)をするツール üバックエンドはlaser-ethereumというシンボリック実⾏⽤の VMを利⽤
まとめ ü⽬的・全体像・仕様はWPなどで⽂書・図にまとめる üOpenzeppelin Solidity使う üコード・関連スクリプト・テストなどを全て含める üセキュリティ・実装はベストプラクティスに従う 17