SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Bletchley 2018.01.19 1
https://www.youtube.com/watch?
v=L1N1P2zxaZE
§ Discover Date: 2018.01.03
§ Threat
§  Adversary who can execute low
privilege code can read
unpermitted memory region
§ Impact
§  Meltdown: Most Intel processors
§  Spectre: Intel, AMD, and ARM
processors
§ Reason
§  Inconsistence between processor
architecture and
microarchitecture (cache)
§  Lack of permission checking
when CPU optimization
2
§ Disclosure by
§  Meltdown
§  Jann Horn (Google Project Zero),
§  Werner Haas,Thomas Prescher (Cyberus Technology),
§  Daniel Gruss, Moritz Lipp, Stefan Mangard, Michael Schwarz (Graz
University of Technology)
§  Spectre
§  Jann Horn (Google Project Zero)
§  Paul Kocher + Daniel Genkin (University of Pennsylvania and
University of Maryland), Mike Hamburg (Rambus), Moritz Lipp
(Graz University of Technology), andYuvalYarom (University of
Adelaide and Data61)
§  Website
§  https://meltdownattack.com/
3
§  CVE-2017-5753 - bounds check bypass (Spectre)
§  CVE-2017-5715 - branch target injection (Spectre)
§  CVE-2017-5754 - rogue data cache load (Meltdown)
4
•  Frontend
•  Fetch and Decode
•  Execution Engine
•  Reorder Buffer
•  Execution Unit
5
§  Once the data dependency is satisfied, the instructions are put into
Execution Units for execution
§  In order to fully utilize execution units, out-of-order execution is
used in most modern processors
§  Instruction can execute in advanced, even the previous instruction is not
yet finished.
§  In normal case,
§  Execution unit calculates and keeps the effect of this instruction.
§  Until all previous instructions finished, this instruction is retired, and
committing it’s result.
§  In error occurs,
§  The executing result will be discarded.
§  Even though the execution result may not commit to architecture,
the state of microarchitecture is already changed.
§  Cache state
6
§  Speculative execution is one kind of out-of-order execution
§  Once a conditional branch instruction whose direction depends
on preceding instructions whose execution has not completed
yet.
§  CPU makes a prediction as to the path that the program will
follow, and speculatively execute instructions along the path.
§  Predict corrects, the instructions are retired and committed
§  Predict fails, the execution result is then discarded.
§  Even though the execution result may not commit to
architecture, the state of microarchitecture is already changed.
7
§  Cache side-channel attacks exploit timing differences that are
introduced by the caches
§  Meltdown and Spectre take Microarchitectural Side-Channel
Attacks to uncover data in the microarchitecture
§  Several Side Channel Attacks
§  Evict+Time
§  Prime+Probe
§  Flush+Reload
8
§  Flush+Reload attacks work on a single cache line granularity.
§  These attacks exploit the shared, inclusive last-level cache.
§  An attacker frequently flushes a targeted memory location
using the clflush instruction.
§  By measuring the time it takes to reload the data, the attacker
determines whether data was loaded into the cache by another
process in the meantime.
9
§  array is an attacker-controllable data
§  Access time
§  Hit
§  Miss
§  256 accesses help discover one byte data
Array[61*
cache_line_size ]
10
§  Exploit out-of-order execution features in
processors
§  Transfer hidden data from cache via Cache
Side Channel Attack
11
§  The content of an attacker-chosen memory location, which is
inaccessible to the attacker, is loaded into a register.
§  A transient instruction accesses a cache line based on the
secret content of the register.
§  The attacker uses Flush+Reload to determine the accessed
cache line and hence the secret stored at the chosen memory
location.
12
§  Transient instruction
§  Instructions which should never executing
§  CPU executes it via out-of-order execution
§  Change the microarchitecture state of the processors
13
§  Line 3 is never executing
§  CPU stealthy executing
line 3 in advance
§  Execution result will be
abandoned
§  But cache state is already
changed
14
§  An traversal of probe array can be made to record time to
access each element in probe array
§  Data is 84
15
§  Meltdown POC
§  https://github.com/IAIK/meltdown
§  Consists of 5 demo program
§  A first test to access other process’ memory
§  Breaking KASLR
§  Reliability test
§  Read physical memory 
§  Dump the memory
§  Core library - libkdump
16
§ Statistic time to access
cached/non-cached
data
§ Calculate threshold
17
§ libkdump_read calls
§  libkdump_read_tsx()
§  libkdump_read_signal_handler()
to read memory
§ Call to MELTDOWN to trigger
out-of-order
§ Invoke flush_reload() to reveal
data value from cache
18
§  Since memory in rcx is invalid, the exception will arise – line 50
§  Line 51 – 53 will be executed in an out-of-order manner
§  Part of probe array rbx is loaded to cache, thus reveals value of rcx
19
§  Flush + Reload
§  Check if the value is in cache
20
§  Reconstructing a photo with Meltdown
§  https://www.youtube.com/watch?v=L1N1P2zxaZE
21
§  Exploit processors’ speculative
execution and branch prediction
feature
§  Discover cache data via Cache Side
Channel Attack
22
1.  Mistrain the processor so that it will later make an
exploitably erroneous speculative prediction
2.  Speculatively executes instructions that transfer confidential
information from the victim context into a microarchitectural
side channel
3.  Recovered the confidential data from cache
23
§  Pretrain
§  make program enter this condition check many times
§  Adversary can chose malicious x for accessing unpermitted data, e.g. kernel
space memory
§  Since
§  array1_size is not in cache, CPU is delayed to read the value
§  Branch predictor beliefs the branch will taken, thus speculative execute the code in
branch with malicious x
§  In the end, the execution result will be discarded, but still remains in cache
§  Similar to Meltdown, Flush+Reload to recover the confidential data
No Cache
No
Cache
Cache
24
§  Spectre POC
§  https://github.com/crozone/SpectrePoC
§  provided by Erik August's gist
25
§  Make 5 train runs with 1 attack run
§  Mistrain branch predictor
26
§  Victim function
§  When x is larger than array1_size, the code will speculative
execute
§  Change the cache state
27
§  Calculate the time needed to access memory
§  Determine if it is in the cache
28
29
30
§  handling, we catch the exception effectively occurring
after executing the transient instruction sequence,
and with exception suppression, we prevent the exception
from occurring at all and instead redirect the control
flow after executing the transient instruction sequence
31
§  The Branch Target Buffer(BTB) keeps a mapping from
addresses of recently executed branch instructions to
destination addresses
32

Weitere ähnliche Inhalte

Mehr von Hacks in Taiwan (HITCON)

【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】Hacks in Taiwan (HITCON)
 
【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹Hacks in Taiwan (HITCON)
 
【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro Datasets【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro DatasetsHacks in Taiwan (HITCON)
 
HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊 HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊 Hacks in Taiwan (HITCON)
 
HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介Hacks in Taiwan (HITCON)
 
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果Hacks in Taiwan (HITCON)
 
2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生Hacks in Taiwan (HITCON)
 

Mehr von Hacks in Taiwan (HITCON) (18)

【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】【HITCON FreeTalk 2021 -  SolarWinds 供應鏈攻擊事件分析】
【HITCON FreeTalk 2021 - SolarWinds 供應鏈攻擊事件分析】
 
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞的修補策略與 risk mitigation】
 
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
【HITCON FreeTalk 2018 - 從晶片設計角度看硬體安全】
 
【HITCON FreeTalk】Supply Chain Attack
【HITCON FreeTalk】Supply Chain Attack【HITCON FreeTalk】Supply Chain Attack
【HITCON FreeTalk】Supply Chain Attack
 
【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹【HITCON FreeTalk】HITCON 2017 下半年活動介紹
【HITCON FreeTalk】HITCON 2017 下半年活動介紹
 
【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro Datasets【HITCON Hackathon 2017】 TrendMicro Datasets
【HITCON Hackathon 2017】 TrendMicro Datasets
 
HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊 HITCON TALK 技術解析 SWIFT Network 攻擊
HITCON TALK 技術解析 SWIFT Network 攻擊
 
HITCON TALK ATM 金融攻擊事件解析
HITCON TALK ATM 金融攻擊事件解析HITCON TALK ATM 金融攻擊事件解析
HITCON TALK ATM 金融攻擊事件解析
 
HITCON TALK 產業視野下的 InfoSec
HITCON TALK 產業視野下的 InfoSecHITCON TALK 產業視野下的 InfoSec
HITCON TALK 產業視野下的 InfoSec
 
HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介HITCON TALK 台灣駭客協會年度活動簡介
HITCON TALK 台灣駭客協會年度活動簡介
 
HITCON CTF 導覽
HITCON CTF 導覽HITCON CTF 導覽
HITCON CTF 導覽
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
 
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
Hacker as a maker 如何利用 mtk 7688 設計出超炫的 ctf 決賽戰場燈控效果
 
2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生2015 資安從業人員的寶(鬼)島求生
2015 資安從業人員的寶(鬼)島求生
 
CTF 經驗分享
CTF 經驗分享CTF 經驗分享
CTF 經驗分享
 
台灣資安人才培育現況
台灣資安人才培育現況台灣資安人才培育現況
台灣資安人才培育現況
 
HITCON GIRLS Malware Analysis
HITCON GIRLS Malware AnalysisHITCON GIRLS Malware Analysis
HITCON GIRLS Malware Analysis
 
Practical cryptanalysis for hackers
Practical cryptanalysis for hackersPractical cryptanalysis for hackers
Practical cryptanalysis for hackers
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Kürzlich hochgeladen (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

【HITCON FreeTalk 2018 - Spectre & Meltdown 漏洞原理說明與 POC 剖析】

  • 2. § Discover Date: 2018.01.03 § Threat §  Adversary who can execute low privilege code can read unpermitted memory region § Impact §  Meltdown: Most Intel processors §  Spectre: Intel, AMD, and ARM processors § Reason §  Inconsistence between processor architecture and microarchitecture (cache) §  Lack of permission checking when CPU optimization 2
  • 3. § Disclosure by §  Meltdown §  Jann Horn (Google Project Zero), §  Werner Haas,Thomas Prescher (Cyberus Technology), §  Daniel Gruss, Moritz Lipp, Stefan Mangard, Michael Schwarz (Graz University of Technology) §  Spectre §  Jann Horn (Google Project Zero) §  Paul Kocher + Daniel Genkin (University of Pennsylvania and University of Maryland), Mike Hamburg (Rambus), Moritz Lipp (Graz University of Technology), andYuvalYarom (University of Adelaide and Data61) §  Website §  https://meltdownattack.com/ 3
  • 4. §  CVE-2017-5753 - bounds check bypass (Spectre) §  CVE-2017-5715 - branch target injection (Spectre) §  CVE-2017-5754 - rogue data cache load (Meltdown) 4
  • 5. •  Frontend •  Fetch and Decode •  Execution Engine •  Reorder Buffer •  Execution Unit 5
  • 6. §  Once the data dependency is satisfied, the instructions are put into Execution Units for execution §  In order to fully utilize execution units, out-of-order execution is used in most modern processors §  Instruction can execute in advanced, even the previous instruction is not yet finished. §  In normal case, §  Execution unit calculates and keeps the effect of this instruction. §  Until all previous instructions finished, this instruction is retired, and committing it’s result. §  In error occurs, §  The executing result will be discarded. §  Even though the execution result may not commit to architecture, the state of microarchitecture is already changed. §  Cache state 6
  • 7. §  Speculative execution is one kind of out-of-order execution §  Once a conditional branch instruction whose direction depends on preceding instructions whose execution has not completed yet. §  CPU makes a prediction as to the path that the program will follow, and speculatively execute instructions along the path. §  Predict corrects, the instructions are retired and committed §  Predict fails, the execution result is then discarded. §  Even though the execution result may not commit to architecture, the state of microarchitecture is already changed. 7
  • 8. §  Cache side-channel attacks exploit timing differences that are introduced by the caches §  Meltdown and Spectre take Microarchitectural Side-Channel Attacks to uncover data in the microarchitecture §  Several Side Channel Attacks §  Evict+Time §  Prime+Probe §  Flush+Reload 8
  • 9. §  Flush+Reload attacks work on a single cache line granularity. §  These attacks exploit the shared, inclusive last-level cache. §  An attacker frequently flushes a targeted memory location using the clflush instruction. §  By measuring the time it takes to reload the data, the attacker determines whether data was loaded into the cache by another process in the meantime. 9
  • 10. §  array is an attacker-controllable data §  Access time §  Hit §  Miss §  256 accesses help discover one byte data Array[61* cache_line_size ] 10
  • 11. §  Exploit out-of-order execution features in processors §  Transfer hidden data from cache via Cache Side Channel Attack 11
  • 12. §  The content of an attacker-chosen memory location, which is inaccessible to the attacker, is loaded into a register. §  A transient instruction accesses a cache line based on the secret content of the register. §  The attacker uses Flush+Reload to determine the accessed cache line and hence the secret stored at the chosen memory location. 12
  • 13. §  Transient instruction §  Instructions which should never executing §  CPU executes it via out-of-order execution §  Change the microarchitecture state of the processors 13
  • 14. §  Line 3 is never executing §  CPU stealthy executing line 3 in advance §  Execution result will be abandoned §  But cache state is already changed 14
  • 15. §  An traversal of probe array can be made to record time to access each element in probe array §  Data is 84 15
  • 16. §  Meltdown POC §  https://github.com/IAIK/meltdown §  Consists of 5 demo program §  A first test to access other process’ memory §  Breaking KASLR §  Reliability test §  Read physical memory  §  Dump the memory §  Core library - libkdump 16
  • 17. § Statistic time to access cached/non-cached data § Calculate threshold 17
  • 18. § libkdump_read calls §  libkdump_read_tsx() §  libkdump_read_signal_handler() to read memory § Call to MELTDOWN to trigger out-of-order § Invoke flush_reload() to reveal data value from cache 18
  • 19. §  Since memory in rcx is invalid, the exception will arise – line 50 §  Line 51 – 53 will be executed in an out-of-order manner §  Part of probe array rbx is loaded to cache, thus reveals value of rcx 19
  • 20. §  Flush + Reload §  Check if the value is in cache 20
  • 21. §  Reconstructing a photo with Meltdown §  https://www.youtube.com/watch?v=L1N1P2zxaZE 21
  • 22. §  Exploit processors’ speculative execution and branch prediction feature §  Discover cache data via Cache Side Channel Attack 22
  • 23. 1.  Mistrain the processor so that it will later make an exploitably erroneous speculative prediction 2.  Speculatively executes instructions that transfer confidential information from the victim context into a microarchitectural side channel 3.  Recovered the confidential data from cache 23
  • 24. §  Pretrain §  make program enter this condition check many times §  Adversary can chose malicious x for accessing unpermitted data, e.g. kernel space memory §  Since §  array1_size is not in cache, CPU is delayed to read the value §  Branch predictor beliefs the branch will taken, thus speculative execute the code in branch with malicious x §  In the end, the execution result will be discarded, but still remains in cache §  Similar to Meltdown, Flush+Reload to recover the confidential data No Cache No Cache Cache 24
  • 25. §  Spectre POC §  https://github.com/crozone/SpectrePoC §  provided by Erik August's gist 25
  • 26. §  Make 5 train runs with 1 attack run §  Mistrain branch predictor 26
  • 27. §  Victim function §  When x is larger than array1_size, the code will speculative execute §  Change the cache state 27
  • 28. §  Calculate the time needed to access memory §  Determine if it is in the cache 28
  • 29. 29
  • 30. 30
  • 31. §  handling, we catch the exception effectively occurring after executing the transient instruction sequence, and with exception suppression, we prevent the exception from occurring at all and instead redirect the control flow after executing the transient instruction sequence 31
  • 32. §  The Branch Target Buffer(BTB) keeps a mapping from addresses of recently executed branch instructions to destination addresses 32