Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
スマートコントラクトの監査について
Search
yudetamago
September 25, 2018
Technology
650
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
350
Gasを誰が払うのか問題について
yudetamago
5
4.7k
Solidityの複数コントラク ト連携を色々試してる話
yudetamago
1
2.4k
Dapps開発におけるSoliidityのはまりどころ
yudetamago
3
2.4k
Other Decks in Technology
See All in Technology
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
3.1k
人にやさしく、AIにやさしく、書き手を選ばないIaCのガードレール再考 / Rethinking IaC Guardrails for Humans and AI Alike
kohbis
5
1.2k
サーバーレスをどこまで使う? WebRTC対戦ゲームで選んだVPSとの共存設計
kaidouji85
0
450
Goodbye ShellScript, Hello File-based App
shunsock
0
1.1k
PQC移行の今 -- IETF からみた現在地
satokan
3
350
[Kiro Meetup #7] Kiro Crew Dive Deep
konippi
0
350
AIエージェントを最高のパートナーに育てる方法|評価と判断軸を育てる5つのステップ
koichiaoki
1
160
リアーキテクチャ後の障害ゼロを目指したShadow Testingの取り組み
nihonbuson
PRO
1
180
Antigravity SDK for the Java Developer
glaforge
0
210
AIに書かせて、プラットフォームで縛る ― EKSプラットフォームで実践した責任境界と権限設計
elmodev09
0
580
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
610
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
13
10k
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
420
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Typedesign – Prime Four
hannesfritz
42
3.2k
Designing for Performance
lara
611
70k
Design in an AI World
tapps
1
330
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
520
Balancing Empowerment & Direction
lara
6
1.3k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
240
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
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