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
Why Agent Cost Needs Observability
nttcom
0
130
ソフトウェアDNAとクラウドエージェントのススメ
cloudace
0
120
Minecraft JavaのMODをSwiftで作る
1mash0
0
200
Von-Neumann Machines, Dreams & The Futures of IT
ufried
0
120
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
5
670
絵ではじめるKubernetesセキュリティ
aoi1
4
700
SREへの勘違いに気づいた後の話
tomodakengo
0
140
C#未経験の僕がAIに読めるコードを書かせるまで
maguroalternative
0
230
AIエージェントの権限管理 3: Agentic RAG の Fine grained access control 編
ren8k
0
190
ScotSecure West 2026 - Glasgow
raybugg
0
150
Railsのように考える: See through the Master
snoozer05
PRO
5
1.2k
`t*(42&t>>10)`だけで音楽が鳴る、Swiftで実装するBytebeat / iOSDC Japan 2026
yutailang0119
0
130
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1369
210k
The Spectacular Lies of Maps
axbom
PRO
1
1k
RailsConf 2023
tenderlove
30
1.6k
We Have a Design System, Now What?
morganepeng
55
8.3k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
600
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Design in an AI World
tapps
1
330
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
Un-Boring Meetings
codingconduct
0
420
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
230
Joys of Absence: A Defence of Solitary Play
codingconduct
1
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