SlideShare a Scribd company logo
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
To accelerate our learnings, we brought in an expert in CPU
side channel attacks
Anders Fogh
Virtualization-based isolation Microsoft Azure, Hyper-V Affected
Kernel-user separation Windows Affected
Process-based isolation Windows Affected
Language-based isolation Microsoft Edge & Internet Explorer Affected
Enclaves Microsoft Azure, Windows Affected
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Pipeline
Instructions are put on an “assembly line” and different jobs are done
in different stages
Superscalar Multiple instructions are executed at once
Out-of-order execution
Instructions are executed as dependencies are resolved and resources
are available
Speculative execution Instructions are executed based on predictions
Instruction Status
MOV RAX, [Address] Ready to execute
ADD RBX, RAX Has to wait
MOV RCX, [ECX] Ready to execute
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
A conditional branch can potentially mispredict, thus leading to a speculative out-of-
bounds load that feeds a second load, thus creating cache side effects based on a secret.
The attacker can train the branch to speculatively run the code.
if (untrusted_index < length) { This can mispredict executing the below lines with
any value of untrusted_index
char value = buf[untrusted_index]; Loads nearly arbitrary memory
char value2 = buf2[value * 0x40]; Loads the cache as an artifact of the value
}
Consequence
If an attacker can find/create & execute this code in Hypervisor/Kernel/Enclave/sandbox,
they can read the memory
An indirect branch can potentially mispredict the branch target, thus leading to
speculative execution from an attacker controlled target address which could perform a
load and feed that value to a second load
0x4000: JMP RAX ; RAX = 0x5000
....
This can mispredict the target address, thus
speculative executing anywhere
0x4141: MOVZX RCX, BYTE PTR [RCX]
SHL RCX, 6
MOV RCX, [RDX+RCX]
Loads any memory at RCX
Multiply by 0x40 (cacheline size)
Loads the cache as an artifact of the value
Consequence
If attacker can find/create & execute this code in Hypervisor/Kernel/Enclave/sandbox, they
can read the memory
Exception delivery may be deferred until instruction retirement, thus allowing data that
should be inaccessible to be speculatively forwarded onto other instructions
TEST RAX, RAX
JE Skip
MOVZX RCX, BYTE PTR [KERNEL_ADDR]
SHL RCX, 6
MOV RCX, [Buf2+RCX]
This can mispredict the target address, thus
speculative executing anywhere
Fetch any kernel address. Error/Roll back arrives
delayed
Multiply by 0x40 to store information in the cache
Consequence
An unprivileged user mode process can read kernel memory
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Requirement Taxonomy
Speculation
1. Gaining speculation Speculation primitive
2. Maintaining speculation Windowing gadget
Side channel
3. Persisting the results Disclosure gadget
4. Observing the results Disclosure primitive
If any of these 4 components are not present, there is no speculative side channel
Spectre variant 1 Conditional branches are predicted on past behavior, thus we can train them
Spectre variant 2
Indirect branches can be trained in place like conditional branches, or since not all
bits are used for prediction, they can be trained in an attacker controlled context
Meltdown
The CPU may defer exceptions and may speculatively forward data on to dependent
instructions
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
1. Speculation primitive Example
Conditional branch
misprediction
if (n < *p) {
// can speculate when n >= *p
}
Indirect branch
misprediction
// can speculate wrong branch target
(*FuncPtr)();
Exception delivery
// may do permission check at
// retirement
value = *p;
2. Windowing gadget Example
Non-cached load
// *p not present in cache
value = *p;
Dependency chain of loads value = ********p;
Dependency chain of ALU
operations
value += 10;
value += 10;
value += 10;
…
3. Disclosure gadget Example
One level of memory indirection,
out-of-bounds
if (x < y)
return buf[x];
Two levels of memory indirection,
out-of-bounds
if (x < y) {
n = buf[x];
return buf2[n];
}
Three levels of memory indirection,
out-of-bounds
if (x < y) {
char *p = buf[n];
char b = *p;
return buf2[b];
}
…
4. Disclosure primitive Example
FLUSH+RELOAD
Priming phase: flush candidate cache lines
Trigger phase: cache line is loaded based off secret
Observing phase: load candidate cache lines, fastest
access may be signal
EVICT+TIME
Priming phase: evict congruent cache line
Trigger phase: cache line is loaded based off secret
Observing phase: measure time of operation, slowest
operation may be signal
PRIME+PROBE
Priming phase: load candidate cache lines
Triggering phase: cache set is evicted based off secret
Observing phase: load candidate cache lines, slowest
access may be signal
Attack category Attack scenario
Conditional branch
misprediction
Indirect branch
misprediction
Exception delivery
Inter-VM
Hypervisor-to-guest
Host-to-guest
Guest-to-guest
Intra-OS
Kernel-to-user
Process-to-process
Intra-process
Enclave Enclave-to-any
Applicable Not applicableLegend:
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Prevent speculation
techniques
Prevent a speculation primitive from executing a disclosure gadget
Remove sensitive content
from memory
Ensure there is no sensitive information in memory that could be read
by a speculation technique
Remove observation
channels
Remove channels for communicating information via speculation
techniques
Goal: prevent a speculation primitive from executing a disclosure gadget
Speculation
primitive
Windowing
gadget
Disclosure
gadget
Disclosure
primitive
if (untrusted_index < length) {
_mm_lfence(); // barrier for speculation
char value = buf[untrusted_index];
char value2 = buf2[value * 0x40];
}
if (untrusted_index < length) {
// cmp untrusted_index, length
// xor reg,reg
// cmovae untrusted_index, reg
char value = buf[untrusted_index];
char value2 = buf2[value * 0x40];
}
minimum root CPU groups
Indirect Branch Restricted Speculation
(IBRS)
Indirect Branch Prediction Barrier
(IBPB)
Single-Thread Indirect Prediction Barrier
(STIBP)
When IBRS=1, less-privileged modes
cannot influence indirect branch
predictions of higher-privileged
modes
Kernel and/or hypervisor can set
IBRS=1 on entry to prevent less
privileged modes from attacking them
When IBPB=1, indirect branch
prediction state is flushed (BTB and
RSB)
Kernel and/or hypervisor can write
this when switching process or VM
contexts to prevent cross-process
and cross-VM attacks
When STIBP=1, sibling SMTs cannot
influence one another’s indirect branch
predictions
Processes can request that the kernel set
this to prevent cross-process SMT-based
attacks on indirect branch prediction
FAR JMP and FAR RET are not
predicted on Intel CPUs
RDTSCP or LFENCE before indirect
JMP is safe on AMD CPUs
Indirect calls and jumps can be
transformed into “retpolines”
Indirect calls and jumps can be
transformed into FAR JMP on Intel
CPUs
Indirect calls and jumps can be
transformed into RDTSCP or LFENCE
before indirect JMP on AMD CPUs
Google proposed “retpoline” which
transforms indirect calls and jumps
into “retpoline” stubs
Goal: ensure there is no sensitive information in memory that could be read by a speculation technique
Speculation
primitive
Windowing
gadget
Disclosure
gadget
Disclosure
primitive
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Goal: remove channels for communicating information via speculation techniques
Speculation
primitive
Windowing
gadget
Disclosure
gadget
Disclosure
primitive
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Mitigation Tactic Mitigation Name
Attack category Speculation primitive
Inter-VM Intra-OS Enclave
Conditional branch
misprediction
Indirect branch
misprediction
Exception
delivery
Prevent speculation techniques
Speculation barrier via execution serializing
instruction
Security domain CPU core isolation
Indirect branch speculation barrier on demand
and mode change
Non-speculated or safely-speculated indirect
branches
Remove sensitive content from
memory
Hypervisor address space segregation
Split user and kernel page tables (“KVA
Shadow”)
Remove observation channels
Map guest memory as noncacheable in root
extended page tables
Do not share physical pages across guests
Decrease browser timer precision
Applicable Not applicable
Variant Conceptualization
Variant 1 (CVE-2017-5753)
This is a hardware vulnerability class that requires
software changes in order to mitigate.
No universal mitigation for this variant exists today.
Variant 2 (CVE-2017-5715)
This is a hardware vulnerability that can be mitigated
through a combination of OS and firmware changes.
Variant 3 (CVE-2017-5754)
This is a hardware vulnerability that can be mitigated
through OS changes to create split user/kernel page
tables.
Disclosed Variant Speculation primitive category Mitigation
May, 2018
Speculative Store Bypass
(CVE-2018-3639)
Memory access misprediction
(new category)
• Disable speculative store bypass
optimization
• Speculation barrier prior to unsafe
store
June, 2018
Lazy FP State Restore
(CVE-2018-3665)
Exception delivery
(same as Meltdown)
• Use eager restore of FP state
(rather than lazy restore)
July, 2018 Bounds Check Bypass Store
Conditional branch misprediction
(same as Spectre variant 1)
• Speculation barrier as required
July, 2018 NetSpectre
Conditional branch misprediction
(same as Spectre variant 1)
• Speculation barrier as required
https://aka.ms/sescbounty
https://aka.ms/sescdevguide
https://blogs.technet.microsoft.com/srd/2018/03/15/mitigating-speculative-execution-side-channel-hardware-
vulnerabilities/
https://blogs.technet.microsoft.com/srd/2018/03/23/kva-shadow-mitigating-meltdown-on-windows/
https://blogs.technet.microsoft.com/srd/2018/05/21/analysis-and-mitigation-of-speculative-store-bypass-cve-
2018-3639/
Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities
Priming Getting the system into a known initial state (e.g. flushing cache lines)
Triggering Actively or passively causing the victim to execute
Observing Observe if state is changed and thereby infer information from this

More Related Content

PPTX
Concurrency 2010
KEY
Intermediate Capistrano
PPT
Channel 2010
PPT
12 virtualmachine
PPT
PPT
PPT
Posix Threads
Concurrency 2010
Intermediate Capistrano
Channel 2010
12 virtualmachine
Posix Threads

What's hot (20)

PPTX
C++ process new
PDF
Если нашлась одна ошибка — есть и другие. Один способ выявить «наследуемые» у...
PDF
Smashing The Stack
PDF
Riding the Overflow - Then and Now
PDF
Modern net bsd kernel module
PDF
Shellcoding, an Introduction
PDF
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
PDF
Virtual Machines Security Internals: Detection and Exploitation
PDF
Other Approaches (Concurrency)
PPTX
Thread and method_2010
PPTX
SystemC Ports
PPT
Coding for multiple cores
PDF
Lucene revolution 2011
PPTX
Угадываем пароль за минуту
PPTX
[Defcon24] Introduction to the Witchcraft Compiler Collection
PDF
D itg-manual
PDF
Direct Code Execution @ CoNEXT 2013
PDF
Kernelvm 201312-dlmopen
PPTX
Abusing Microsoft Kerberos - Sorry you guys don't get it
PPT
[CCC-28c3] Post Memory Corruption Memory Analysis
C++ process new
Если нашлась одна ошибка — есть и другие. Один способ выявить «наследуемые» у...
Smashing The Stack
Riding the Overflow - Then and Now
Modern net bsd kernel module
Shellcoding, an Introduction
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Virtual Machines Security Internals: Detection and Exploitation
Other Approaches (Concurrency)
Thread and method_2010
SystemC Ports
Coding for multiple cores
Lucene revolution 2011
Угадываем пароль за минуту
[Defcon24] Introduction to the Witchcraft Compiler Collection
D itg-manual
Direct Code Execution @ CoNEXT 2013
Kernelvm 201312-dlmopen
Abusing Microsoft Kerberos - Sorry you guys don't get it
[CCC-28c3] Post Memory Corruption Memory Analysis
Ad

Similar to Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities (20)

PDF
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
PDF
Introduction to eBPF and XDP
PDF
Austin c-c++-meetup-feb2018-spectre
PDF
Offensive cyber security: Smashing the stack with Python
PDF
Mobile Email Security
PPT
Sedna XML Database: Executor Internals
PDF
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
PDF
ARM Architecture and Meltdown/Spectre
PPTX
Introduction to Apache Mesos
PDF
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
PDF
What`s new in Java 7
KEY
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
PDF
OpenSSL Basic Function Call Flow
PPT
Server side JavaScript: going all the way
PPTX
Linux Ethernet device driver
PDF
Davide Berardi - Linux hardening and security measures against Memory corruption
PDF
Squash Those IoT Security Bugs with a Hardened System Profile
PDF
Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...
PDF
Linux kernel-rootkit-dev - Wonokaerun
PDF
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Introduction to eBPF and XDP
Austin c-c++-meetup-feb2018-spectre
Offensive cyber security: Smashing the stack with Python
Mobile Email Security
Sedna XML Database: Executor Internals
pg / shardman: шардинг в PostgreSQL на основе postgres / fdw, pg / pathman и ...
ARM Architecture and Meltdown/Spectre
Introduction to Apache Mesos
XPDDS19: Speculative Sidechannels and Mitigations - Andrew Cooper, Citrix
What`s new in Java 7
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
OpenSSL Basic Function Call Flow
Server side JavaScript: going all the way
Linux Ethernet device driver
Davide Berardi - Linux hardening and security measures against Memory corruption
Squash Those IoT Security Bugs with a Hardened System Profile
Lost in Translation: When Industrial Protocol Translation goes Wrong [CONFide...
Linux kernel-rootkit-dev - Wonokaerun
PG Day'14 Russia, PostgreSQL System Architecture, Heikki Linnakangas
Ad

More from Priyanka Aash (20)

PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
PDF
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
PDF
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
PDF
Lessons Learned from Developing Secure AI Workflows.pdf
PDF
Cyber Defense Matrix Workshop - RSA Conference
PDF
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
PDF
Securing AI - There Is No Try, Only Do!.pdf
PDF
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
PDF
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
PDF
10 Key Challenges for AI within the EU Data Protection Framework.pdf
PDF
Techniques for Automatic Device Identification and Network Assignment.pdf
PDF
Keynote : Presentation on SASE Technology
PDF
Keynote : AI & Future Of Offensive Security
PDF
Redefining Cybersecurity with AI Capabilities
PDF
Demystifying Neural Networks And Building Cybersecurity Applications
PDF
Finetuning GenAI For Hacking and Defending
PDF
(CISOPlatform Summit & SACON 2024) Kids Cyber Security .pdf
PDF
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
PDF
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
From Chatbot to Destroyer of Endpoints - Can ChatGPT Automate EDR Bypasses (1...
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Cyber Defense Matrix Workshop - RSA Conference
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Securing AI - There Is No Try, Only Do!.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Keynote : Presentation on SASE Technology
Keynote : AI & Future Of Offensive Security
Redefining Cybersecurity with AI Capabilities
Demystifying Neural Networks And Building Cybersecurity Applications
Finetuning GenAI For Hacking and Defending
(CISOPlatform Summit & SACON 2024) Kids Cyber Security .pdf
(CISOPlatform Summit & SACON 2024) Regulation & Response In Banks.pdf
(CISOPlatform Summit & SACON 2024) Cyber Insurance & Risk Quantification.pdf

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Empathic Computing: Creating Shared Understanding
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Encapsulation theory and applications.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Machine learning based COVID-19 study performance prediction
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Review of recent advances in non-invasive hemoglobin estimation
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation_ Review paper, used for researhc scholars
Empathic Computing: Creating Shared Understanding
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Unlocking AI with Model Context Protocol (MCP)
Chapter 3 Spatial Domain Image Processing.pdf
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
A comparative analysis of optical character recognition models for extracting...
Encapsulation theory and applications.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

Wrangling with the Ghost: An Inside Story of Mitigating Speculative Execution Side Channel Vulnerabilities

  • 4. To accelerate our learnings, we brought in an expert in CPU side channel attacks Anders Fogh
  • 5. Virtualization-based isolation Microsoft Azure, Hyper-V Affected Kernel-user separation Windows Affected Process-based isolation Windows Affected Language-based isolation Microsoft Edge & Internet Explorer Affected Enclaves Microsoft Azure, Windows Affected
  • 7. Pipeline Instructions are put on an “assembly line” and different jobs are done in different stages Superscalar Multiple instructions are executed at once Out-of-order execution Instructions are executed as dependencies are resolved and resources are available Speculative execution Instructions are executed based on predictions
  • 8. Instruction Status MOV RAX, [Address] Ready to execute ADD RBX, RAX Has to wait MOV RCX, [ECX] Ready to execute
  • 13. A conditional branch can potentially mispredict, thus leading to a speculative out-of- bounds load that feeds a second load, thus creating cache side effects based on a secret. The attacker can train the branch to speculatively run the code. if (untrusted_index < length) { This can mispredict executing the below lines with any value of untrusted_index char value = buf[untrusted_index]; Loads nearly arbitrary memory char value2 = buf2[value * 0x40]; Loads the cache as an artifact of the value } Consequence If an attacker can find/create & execute this code in Hypervisor/Kernel/Enclave/sandbox, they can read the memory
  • 14. An indirect branch can potentially mispredict the branch target, thus leading to speculative execution from an attacker controlled target address which could perform a load and feed that value to a second load 0x4000: JMP RAX ; RAX = 0x5000 .... This can mispredict the target address, thus speculative executing anywhere 0x4141: MOVZX RCX, BYTE PTR [RCX] SHL RCX, 6 MOV RCX, [RDX+RCX] Loads any memory at RCX Multiply by 0x40 (cacheline size) Loads the cache as an artifact of the value Consequence If attacker can find/create & execute this code in Hypervisor/Kernel/Enclave/sandbox, they can read the memory
  • 15. Exception delivery may be deferred until instruction retirement, thus allowing data that should be inaccessible to be speculatively forwarded onto other instructions TEST RAX, RAX JE Skip MOVZX RCX, BYTE PTR [KERNEL_ADDR] SHL RCX, 6 MOV RCX, [Buf2+RCX] This can mispredict the target address, thus speculative executing anywhere Fetch any kernel address. Error/Roll back arrives delayed Multiply by 0x40 to store information in the cache Consequence An unprivileged user mode process can read kernel memory
  • 17. Requirement Taxonomy Speculation 1. Gaining speculation Speculation primitive 2. Maintaining speculation Windowing gadget Side channel 3. Persisting the results Disclosure gadget 4. Observing the results Disclosure primitive If any of these 4 components are not present, there is no speculative side channel
  • 18. Spectre variant 1 Conditional branches are predicted on past behavior, thus we can train them Spectre variant 2 Indirect branches can be trained in place like conditional branches, or since not all bits are used for prediction, they can be trained in an attacker controlled context Meltdown The CPU may defer exceptions and may speculatively forward data on to dependent instructions
  • 22. 1. Speculation primitive Example Conditional branch misprediction if (n < *p) { // can speculate when n >= *p } Indirect branch misprediction // can speculate wrong branch target (*FuncPtr)(); Exception delivery // may do permission check at // retirement value = *p; 2. Windowing gadget Example Non-cached load // *p not present in cache value = *p; Dependency chain of loads value = ********p; Dependency chain of ALU operations value += 10; value += 10; value += 10; … 3. Disclosure gadget Example One level of memory indirection, out-of-bounds if (x < y) return buf[x]; Two levels of memory indirection, out-of-bounds if (x < y) { n = buf[x]; return buf2[n]; } Three levels of memory indirection, out-of-bounds if (x < y) { char *p = buf[n]; char b = *p; return buf2[b]; } … 4. Disclosure primitive Example FLUSH+RELOAD Priming phase: flush candidate cache lines Trigger phase: cache line is loaded based off secret Observing phase: load candidate cache lines, fastest access may be signal EVICT+TIME Priming phase: evict congruent cache line Trigger phase: cache line is loaded based off secret Observing phase: measure time of operation, slowest operation may be signal PRIME+PROBE Priming phase: load candidate cache lines Triggering phase: cache set is evicted based off secret Observing phase: load candidate cache lines, slowest access may be signal
  • 23. Attack category Attack scenario Conditional branch misprediction Indirect branch misprediction Exception delivery Inter-VM Hypervisor-to-guest Host-to-guest Guest-to-guest Intra-OS Kernel-to-user Process-to-process Intra-process Enclave Enclave-to-any Applicable Not applicableLegend:
  • 25. Prevent speculation techniques Prevent a speculation primitive from executing a disclosure gadget Remove sensitive content from memory Ensure there is no sensitive information in memory that could be read by a speculation technique Remove observation channels Remove channels for communicating information via speculation techniques
  • 26. Goal: prevent a speculation primitive from executing a disclosure gadget Speculation primitive Windowing gadget Disclosure gadget Disclosure primitive
  • 27. if (untrusted_index < length) { _mm_lfence(); // barrier for speculation char value = buf[untrusted_index]; char value2 = buf2[value * 0x40]; } if (untrusted_index < length) { // cmp untrusted_index, length // xor reg,reg // cmovae untrusted_index, reg char value = buf[untrusted_index]; char value2 = buf2[value * 0x40]; }
  • 29. Indirect Branch Restricted Speculation (IBRS) Indirect Branch Prediction Barrier (IBPB) Single-Thread Indirect Prediction Barrier (STIBP) When IBRS=1, less-privileged modes cannot influence indirect branch predictions of higher-privileged modes Kernel and/or hypervisor can set IBRS=1 on entry to prevent less privileged modes from attacking them When IBPB=1, indirect branch prediction state is flushed (BTB and RSB) Kernel and/or hypervisor can write this when switching process or VM contexts to prevent cross-process and cross-VM attacks When STIBP=1, sibling SMTs cannot influence one another’s indirect branch predictions Processes can request that the kernel set this to prevent cross-process SMT-based attacks on indirect branch prediction
  • 30. FAR JMP and FAR RET are not predicted on Intel CPUs RDTSCP or LFENCE before indirect JMP is safe on AMD CPUs Indirect calls and jumps can be transformed into “retpolines” Indirect calls and jumps can be transformed into FAR JMP on Intel CPUs Indirect calls and jumps can be transformed into RDTSCP or LFENCE before indirect JMP on AMD CPUs Google proposed “retpoline” which transforms indirect calls and jumps into “retpoline” stubs
  • 31. Goal: ensure there is no sensitive information in memory that could be read by a speculation technique Speculation primitive Windowing gadget Disclosure gadget Disclosure primitive
  • 34. Goal: remove channels for communicating information via speculation techniques Speculation primitive Windowing gadget Disclosure gadget Disclosure primitive
  • 39. Mitigation Tactic Mitigation Name Attack category Speculation primitive Inter-VM Intra-OS Enclave Conditional branch misprediction Indirect branch misprediction Exception delivery Prevent speculation techniques Speculation barrier via execution serializing instruction Security domain CPU core isolation Indirect branch speculation barrier on demand and mode change Non-speculated or safely-speculated indirect branches Remove sensitive content from memory Hypervisor address space segregation Split user and kernel page tables (“KVA Shadow”) Remove observation channels Map guest memory as noncacheable in root extended page tables Do not share physical pages across guests Decrease browser timer precision Applicable Not applicable
  • 40. Variant Conceptualization Variant 1 (CVE-2017-5753) This is a hardware vulnerability class that requires software changes in order to mitigate. No universal mitigation for this variant exists today. Variant 2 (CVE-2017-5715) This is a hardware vulnerability that can be mitigated through a combination of OS and firmware changes. Variant 3 (CVE-2017-5754) This is a hardware vulnerability that can be mitigated through OS changes to create split user/kernel page tables.
  • 41. Disclosed Variant Speculation primitive category Mitigation May, 2018 Speculative Store Bypass (CVE-2018-3639) Memory access misprediction (new category) • Disable speculative store bypass optimization • Speculation barrier prior to unsafe store June, 2018 Lazy FP State Restore (CVE-2018-3665) Exception delivery (same as Meltdown) • Use eager restore of FP state (rather than lazy restore) July, 2018 Bounds Check Bypass Store Conditional branch misprediction (same as Spectre variant 1) • Speculation barrier as required July, 2018 NetSpectre Conditional branch misprediction (same as Spectre variant 1) • Speculation barrier as required
  • 44. Priming Getting the system into a known initial state (e.g. flushing cache lines) Triggering Actively or passively causing the victim to execute Observing Observe if state is changed and thereby infer information from this