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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
yudetamago
September 25, 2018
Technology
640
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
スマートコントラクトの監査について
yudetamago
September 25, 2018
More Decks by yudetamago
See All by yudetamago
ブロックチェーンとIndexer
yudetamago
0
980
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
[RSJ26] Building a VLA Model Based on Self-Distilled Classification
keio_smilab
PRO
0
160
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3.2k
書籍『生成AIの安全性入門』の入門
wataoka
0
150
Introduction to Bill One Development Engineer
sansan33
PRO
0
490
会計事務所と顧問先の契約関係をOIDC・OAuthで表現する
terara
0
580
Sony-DroidKaigi2026
sony
0
240
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
12
87k
[DroidKaigi 2026] Making UI specifications visible: Android UI development in the AI agent era supported by Compose Screenshot Testing and galleries
syarihu
0
370
Bet AI Day 2026丨Production-Ready AI Agents — エンタープライズの実務を任せるための設計と運用
layerx
PRO
2
1.6k
LLMアプリ、 雰囲気で運用してませんか? 〜LLMOpsの現在地〜
taka_aki
1
660
最新技術に積極チャレンジ!EKS共通基盤のこれまでとこれから
daitak
0
290
AIで開発は速くなったのに、なぜ現場は楽にならないのか 〜あなたの組織のボトルネックを突き止めるワークショップ〜
jacopen
1
120
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
A Soul's Torment
seathinner
7
3.5k
Crafting Experiences
bethany
1
270
Into the Great Unknown - MozCon
thekraken
41
2.7k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
300
A better future with KSS
kneath
240
18k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Building the Perfect Custom Keyboard
takai
2
860
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
570
The untapped power of vector embeddings
frankvandijk
2
1.9k
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