Related Links を読みながら、Meltdown/Spectre に関する理解を整理しました。 もしこの記事における間違いを見つけた場合には、コメントいただけると嬉しいです。 # What is Meltdown/Spectre Meltdown/Spectre は、CPU 実装に起因する Cache [side-channel attack](https://ja.wikipedia.org/wiki/%E3%82%B5%E3%82%A4%E3%83%89%E3%83%81%E3%83%A3%E3%83%8D%E3%83%AB%E6%94%BB%E6%92%83) です。 これらの攻撃手法では、CPU の実装を悪用して、本来プロセスの実行権限でアクセスできないメモリ上のデータ(user/kernel space)を CPU キャッシュに書き出し、そのキャッシュから対象データを取得します。Meltdown/Spectre ともに CPU 実装を悪用しますが、 それぞれ悪用する CPU 実装が異なります(下表を参照)。 | Meltdown/Spectre | 攻撃手法 | 悪用する CPU 実装 | CVE番号 | CVSSv3 Base Metrics(Red Hat 評価) | |:-----------------|:--------|:-----------------|:--------|:----------------------------------| |Spectre|Bounds check bypass|Speculative execution|[CVE-2017-5753](https://access.redhat.com/security/cve/cve-2017-5753)|8.2 CVSS:3.0/AV:A/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N| |Spectre|Branch target injection|Speculative execution|[CVE-2017-5715](https://access.redhat.com/security/cve/cve-2017-5715)|6.7 CVSS:3.0/AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:N| |Meltdown|Rogue data cache load|Out-of-order execution|[CVE-2017-5754](https://access.redhat.com/security/cve/cve-2017-5754)|7.9 CVSS:3.0/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N| # Impact/Mitigation for Meltdown/Spectre ## Spectre: CVE-2017-5753 (Bounds check bypass) ### Impact ユーザプロセスにおいて、**同一プロセスにおける**アクセスを制御しているメモリ領域のデータを読み取られてしまう恐れがあります。 これにより、攻撃者にそのメモリ領域で保護しているデータ(e.g. パスワード等)が漏洩してしまいます。 なお、そのユーザプロセスの権限次第では、OS のメモリ領域のデータも読み取られてしまいます。 ### Mitigation [Intel の Whitepaper](https://newsroom.intel.com/wp-content/uploads/sites/11/2018/01/Intel-Analysis-of-Speculative-Execution-Side-Channels.pdf) によると、 適切な箇所に Speculative execution を止める[バリア](http://www.wdic.org/w/SCI/%E3%83%A1%E3%83%A2%E3%83%AA%E3%83%BC%E3%83%90%E3%83%AA%E3%82%A2)を挿入することで対策できます。 その Whitepaper では、特に [LFENCE 命令](http://www.wdic.org/w/SCI/%E3%83%A1%E3%83%A2%E3%83%AA%E3%83%BC%E3%83%90%E3%83%AA%E3%82%A2#x86) の採用を推奨しています。 | Layer | アップデートの必要性 | |:------|:-------------------| | Application* | Yes | | OS | Yes | | CPU([microcode](https://ja.wikipedia.org/wiki/%E3%83%9E%E3%82%A4%E3%82%AF%E3%83%AD%E3%82%B3%E3%83%BC%E3%83%89)) | No | *: この文脈では、同じプロセス内で Sandbox を実現している Web Brower, Container/Virtualization 関連アプリケーションを意識しています。 ## Spectre: CVE-2017-5715 (Branch target injection) ### Impact ユーザプロセスにおいて、**他のプロセスにおける**アクセスを制御しているメモリ領域のデータを読み取られてしまう恐れがあります。 これにより、攻撃者にそのメモリ領域で保護しているデータ(e.g. パスワード等)が漏洩してしまいます。 なお、そのユーザプロセスの権限次第では、OS のメモリ領域のデータも読み取られてしまいます。 ### Mitigation [Intel の Whitepaper](https://newsroom.intel.com/wp-content/uploads/sites/11/2018/01/Intel-Analysis-of-Speculative-Execution-Side-Channels.pdf) によると、 下記どちらかの方法で対策できます。 1. プロセッサとシステムソフトウェアの間に Branch target injection を防ぐ仕組みを実装する - Indirect Branch Restricted Speculation (IBRS) - Single Thread Indirect Branch Predictors (STIBP) - Indirect Branch Predictor Barrier (IBPB) 2. Return trampoline (a.k.a retpoline) を導入する | Layer | アップデートの必要性 | |:------|:-------------------| | Application* | Yes | | OS | Yes | | CPU([microcode](https://ja.wikipedia.org/wiki/%E3%83%9E%E3%82%A4%E3%82%AF%E3%83%AD%E3%82%B3%E3%83%BC%E3%83%89)) | Yes | *: この文脈では、同じプロセス内で Sandbox を実現している Web Brower, Container/Virtualization 関連アプリケーションを意識しています。 ## Meltdown: CVE-2017-5754 (Rogue data cache load) ### Impact ユーザプロセスにおいて、そのプロセスにマッピングしている OS メモリ領域のデータを読み取られてしまう恐れがあります。 これにより、攻撃者にその OS メモリ領域で保護しているデータ(e.g. パスワード等)が漏洩してしまいます。 ### Mitigation [Intel の Whitepaper](https://newsroom.intel.com/wp-content/uploads/sites/11/2018/01/Intel-Analysis-of-Speculative-Execution-Side-Channels.pdf) によると、 ユーザコードが保護された OS のメモリ領域にアクセスするときに、OS がそのメモリ領域がユーザプロセスにマップされていないことを検証すること、 または KASLR:Kernel Address Space Layout Randomization (旧 KAISER) を実装することで対策できます。 | Layer | アップデートの必要性 | |:------|:-------------------| | Application* | No | | OS | Yes | | CPU([microcode](https://ja.wikipedia.org/wiki/%E3%83%9E%E3%82%A4%E3%82%AF%E3%83%AD%E3%82%B3%E3%83%BC%E3%83%89)) | No | *: この文脈では、同じプロセス内で Sandbox を実現している Web Brower, Container/Virtualization 関連アプリケーションを意識しています。 # Related Links 僕が Meltdown/Spectre を調べているときに参照したリンクをまとめます。基本的にきちんと読んだリンクのみ掲載しているため、Meltdown/Spectre に関する情報の網羅性は低いです。 ## Meltdown/Spectre themselves - https://meltdownattack.com/ - https://www.kb.cert.org/vuls/id/584653 - http://www.4gamer.net/games/999/G999902/20180105085/ - https://pc.watch.impress.co.jp/docs/news/1099687.html - https://www.youtube.com/watch?v=8FFSQwrLsfE&feature=youtu.be - http://msyksphinz.hatenablog.com/entry/2018/01/06/020000 ## Proof of Concept(PoC) - https://bugs.chromium.org/p/project-zero/issues/detail?id=1272 - http://xlab.tencent.com/special/spectre/spectre_check.html * Web browser が Spectre に対して脆弱性であるか検証する ## Mitigation - https://gist.github.com/woachk/2f86755260f2fee1baf71c90cd6533e9 ## Vendor Response/Whitepaper - https://newsroom.intel.com/wp-content/uploads/sites/11/2018/01/Intel-Analysis-of-Speculative-Execution-Side-Channels.pdf - https://developer.arm.com/support/security-update - https://aws.amazon.com/de/security/security-bulletins/AWS-2018-013/ - https://access.redhat.com/security/vulnerabilities/speculativeexecution * https://access.redhat.com/security/cve/cve-2017-5753 * https://access.redhat.com/security/cve/cve-2017-5715 * https://access.redhat.com/security/cve/cve-2017-5754 - https://www.mozilla.org/en-US/security/advisories/mfsa2018-01/ * Firefox 57.0.4 - https://support.google.com/faqs/answer/7622138 ## Impact for Performance - https://access.redhat.com/articles/3307751 * 日本語訳: https://access.redhat.com/ja/articles/3315851 - https://gigazine.net/news/20180110-epic-games-meltdown-patch-performance/ * Epic games - https://newsroom.intel.com/news/intel-security-issue-update-addressing-reboot-issues/ - https://pc.watch.impress.co.jp/docs/news/1100287.html ## Related Topics - https://www.gamebusiness.jp/article/2018/01/06/13946.html - https://techcrunch.com/2018/01/06/how-tier-2-cloud-vendors-banded-together-to-cope-with-spectre-and-meltdown/