SlideShare a Scribd company logo
1 of 39
Download to read offline
Case Studies of Fuzzing with Xen
Tamas K Lengyel
@tklengyel
Balint Varga-Perke
@buherator
2
Disclaimers
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex​.
Performance results are based on testing as of dates shown in configurations and may not reflect all publicly available ​updates.
See backup for configuration details. No product or component can be absolutely secure.
No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document.
Intel does not control or audit third-party data. You should consult other sources to evaluate accuracy.
Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a
particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.
Your costs and results may vary.
Intel technologies may require enabled hardware, software or service activation.
© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names
and brands may be claimed as the property of others. ​
3
TL;DR
KF/x: https://github.com/intel/kernel-fuzzer-for-xen-project
Full-VM snapshot fuzzer
Open-source (MIT)
Integrates with AFL/AFL++
In this talk – the tale of two vastly different targets
- Linux Virtio
- Symantec Endpoint Protection
4
Xen VM forking
Copy-on-write memory in VM forks
Reset vCPU registers and free dirty pages
Parent VM
…
Page X
Page Y
Page Z
…
Fork VM
…
Shared Page X
Copied Page Y
Shared Page Z
…
R
W
X
5
Can run multiple forks
& multiple fuzzing
loops concurrently
Fuzzing with KF/x
Parent
VM
Magic
CPUID
Fork
Sink
VM
panic()
kasan_report()
ubsan_prologue()
…
Fuzz
VM
Add 0xCC
Read input from AFL
Write it to VM’s mem
Reset
Catch a breakpoint
Report crash
Catch Magic CPUID
Report no-crash
Neither: timeout
Analyze
Decode IPT log
Report coverage
Fork
Run
Fuzz
Compile & run target
code with CPUID
harness in place.
No custom compiler
needed!
Any error-handling
function can be a
designated sink point.
Easy to override with
custom list (symbol
name, VA or PA).
6
Design principles behind KF/x
Stable foundation
- All hypervisor components upstream (VM forking, introspection, IPT)
Reduced complexity
- No in-guest agent necessary
Flexible
- Components should be reusable to target any code running in the VM
Extendable
- Integrate with other fuzzers, use different harness mechanism, etc.
7
Limitations
No I/O in fork VMs
- No disk, no network, no screen, no console, no MMIO, no interrupts
- Single vCPU only
Bug enrichment features need to be compiled-in (ASAN, UBSAN)
Target needs to execute normally in a Xen VM
8
Fuzzing Virtio
Part of a larger kernel hardening project in preparation for TDX
See Linux Security Summit ‘21 talk by Elena Reshetova
Attacking guest from the host via shared memory (“DMA”)
Xen doesn’t support Virtio – can’t use KF/x
- Unless .. !
9
VM transplantation!
The idea is simple:
1. Capture system state on KVM
2. Transfer it to Xen
3. Load
4. Fuzz!
10
Capturing the system state
During fuzzing we are running the VM forks with only:
- Memory
- CPU
We are in luck! QEMU QMP command dump-guest-memory
- Creates and ELF file detailing the memory map & memory contents
- Surprise undocumented feature: an ELF note has the CPU register state
We also need the magic CPUID pausing on KVM
11
KVM patch to exit
on magic CPUID
QEMU patch to
pause VM
12
Loading state on Xen
1. Create “empty” VM
2. Load memory according to memory map
3. Load CPU register state
- Fix mismatch between segment attribute byte format in ELF vs Xen
13
It’s alive!
14
Back to Virtio
We have a way to save, transplant & fuzz
Just have to figure out what to fuzz..
Virtio will be used for all I/O on TDX 1.0
- Disk, network, console
That’s a lot of different code-paths to cover
- Does anyone even know all the different ways Virtio code is reached?
15
Retargeting existing code
Had a similar challenge while fuzzing xHCI
Made a tool (dmamonitor) that can hook Linux’s DMA API
- Hook dma_alloc_attrs with VMI
- Remove EPT permission from DMA pages
- Log RIP when EPT fault triggers with read-violation
Could really use it here too..
- We are in luck: https://github.com/KVM-VMI/kvm-vmi
16
Boot Linux with DMA debug
patched to have dummy API
for easier hooking &
force Virtio to go through DMA
API
DMA hook triggers for
DMA page use
Change EPT permission
KVM
Setup
DMA
page
Linux VM boot
& runtime DMA
monitor
E P T
Handle EPT read-fault
Unwind stack & hash return
pointers
If hash is new, snapshot
EPT fault triggers when Virtio
is fetching data from page
1.
3.
2.
4.
17
1
2
3
4
18
No end-harness
We don’t need any!
1. Transplant snapshot
2. Fork
3. Singlestep up to 300k
4. Check which of the stack
return pointers was reached
5. Inject breakpoint to transplant
6. Fuzz!
19
Results with hardened 5.15-rc6
126,061 DMA accesses observed during boot and basic functioning
13 unique DMA access sites
738 unique call-chains lead to DMA access
70 snapshots fuzzed based on top-5 stack frame uniqueness
7,567,463,809 fuzzing cycles completed (in 2 weeks)
0 issues found (no KASAN/UBSAN/panic/oops)
13 snapshots were found to have hangs when fuzzed
54 snapshots had less then 5 paths discovered
20
No bugs?
We weren’t the first
- Check out VIA: Analyzing Device Interfaces of Protected Virtual Machines
- They fuzzed 5.10 and already reported the sanitizer bugs & got them fixed
- We were able to catch some of the same bugs they found when we targeted 5.10
I still consider this a win
- Tools & techniques all open-sourced & anyone is welcome to replicate
- KF/x target setup & fuzzing can now happen at different systems
- No longer need to setup your target on Xen (can use QEMU/KVM/Simics)
Thanks to the whole lot of folks!
Andrew Cooper, Sundaram Arumugasundaram, Mostafa Elsaid, Andi Kleen, Neelima Krishnan, Sathyanarayanan Kuppuswamy, Lukasz Odzioba, Sebastian
Osterlund, Elena Reshetova, Carlos Villavicencio Sanchez, Casey Schaufler, Steffen Schulz, Mathieu Tarral
21
Antivirus fuzzing
• Widespread technology
• Complex parsers implemented in C/C++
• Remotely reachable attack surface
• High privileges
• Prior work:
Antivirus (in)Security, Attacking Antivirus, P0 massacre, Sophail,
Nightmare, The AV Hacker’s Handbook, REing Defender, tons of
privescs, blackhats, and many others (sry if I missed yours!)
22
Antivirus fuzzing
• Complex software
• Binary-only (mostly)
• Performance
• Inspectability
• State
• Diversity
• Products
• Formats
23
KF/x vs. AV
• Reusable harness
• Full inspectability
• Full-system fuzzing
• Written documentation +
well-known platform
24
Symantec Endpoint Protection
25
Symantec Endpoint Protection
• Tamper protection
• Can be disabled, some memory still not accessible
• COM-like architecture
• Complex inter-module dependencies (writeup soon)
• COM is obfuscation: No export symbols, no typelib, indirect calls …
• OS interference
26
Proof-of-Concept
• Multiple bugs discovered by Tavis Ormandy in 2016.
• “Decomposers”
• Unrar, dec2lha, libmspack, … -> ccScanW.dll
• Try to rediscover #823 – “PowerPoint misaligned
stream-cache remote stack buffer overflow”
• Easy to modify nasm PoC
• /GS still not applied to all (non-trivial) functions #YOLO
27
Proof-of-Concept
• #823 allowed quick identification of the relevant parser function
and I/O functions
• KF/x tuning
• Interrupt masking
• sinks.h -> “KiDispatchException” (resolved by Volatility)
• if (addr & 0x80000000) return;
• Large test case
• SEP reads data in 8k chunks
• 6 reads necessary before the bug triggers (no disk in KF/x!)
28
Rediscovering CVE-2016-2209 with KF/x
29
Handling large inputs
• Large inputs are not ideal for fuzzing in general
• Performance
• Process state
• Mocking I/O
• Tried it, wouldn’t recommend…
• RAM disk works (on Windows too)
• Chained fuzzing stages
• Other traps: swapping, console output, network, …
30
Other parsers?
• Rabbit Hole Ghidra extension
• Per-function cumulative cyclomatic
complexity
• Ghidra Cpp Class Analyzer
• RTTI info
• Magic numbers
• New target: 7zip decomposer
• Magic number + high complexity +
reachable from C7zEngine class
members
31
“While this fuzzer runs, I will…”1
• Corpus: 1 file, some txt 7z’d with default options
• AFL++, no knowledge about the file format
• Coverage tracking with Intel PT
• Single core
• < 24h runtime
• ~9M execs ~400-500 exec/s (not a perf talk sry)
• No hang elimination (“loose paths”, timeout optimization, …)
1 How to FAIL at Fuzzing, Prospector
32
Fuzzing Symantec Endpoint Protection's 7z parser with KF/x
33
7z bug
• Controlled heap overflow
• Detection can be improved by enabling page heap
• Silently fixed?
• Symantec->Broadcom didn’t make investigation easy
Mandatory AFL graph
34
Using REVEN to triage the 7z parsing heap overflow discovered with KF/x
35
Modularity
• KF/x follows the Unix philosophy
• AFL’s SHMAP became a de-facto standard
• Forkserver-based intergration with LibAFL was trivial
• Timeout/signal handling needed improvement (I/O fail -> hang)
• Independent development of generators, mutators, etc.
• In-memory input passing needs little more work
36
LibAFL
37
Other use-cases
• AV
• Kernel components
• Memory scanners
• DPI/DLP/IPS features
• Games / Anti-cheat
• Sandbox escapes
• Nyx Fuzzer, Fuzzy Snapshots of Firefox IPC
38
Summary
• Trivial vulnerabilities could remain hidden due to the
lack of proper tools
• VM Introspection is a game changer in vulnerability
discovery/analysis
• KF/x is an easy to integrate VMI-based fuzzing harness
39
Thanks!
KF/x: https://github.com/intel/kernel-fuzzer-for-xen-project
Tamas K Lengyel @tklengyel
Balint Varga-Perke @buherator

More Related Content

What's hot

Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF Superpowers
Brendan Gregg
 
Android起動周りのノウハウ
Android起動周りのノウハウAndroid起動周りのノウハウ
Android起動周りのノウハウ
chancelab
 

What's hot (20)

CMake - Introduction and best practices
CMake - Introduction and best practicesCMake - Introduction and best practices
CMake - Introduction and best practices
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
 
Linux Performance Tools 2014
Linux Performance Tools 2014Linux Performance Tools 2014
Linux Performance Tools 2014
 
PowerShell for Practical Purple Teaming
PowerShell for Practical Purple TeamingPowerShell for Practical Purple Teaming
PowerShell for Practical Purple Teaming
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
 
Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF Superpowers
 
Cmake kitware
Cmake kitwareCmake kitware
Cmake kitware
 
LISA2019 Linux Systems Performance
LISA2019 Linux Systems PerformanceLISA2019 Linux Systems Performance
LISA2019 Linux Systems Performance
 
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security TeamSecrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
 
Velocity 2015 linux perf tools
Velocity 2015 linux perf toolsVelocity 2015 linux perf tools
Velocity 2015 linux perf tools
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Introduction to EasyBuild: Tutorial Part 1
Introduction to EasyBuild: Tutorial Part 1Introduction to EasyBuild: Tutorial Part 1
Introduction to EasyBuild: Tutorial Part 1
 
初心者 Git 上手攻略
初心者 Git 上手攻略初心者 Git 上手攻略
初心者 Git 上手攻略
 
virtio
virtiovirtio
virtio
 
Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
What is version control software and why do you need it?
What is version control software and why do you need it?What is version control software and why do you need it?
What is version control software and why do you need it?
 
Android起動周りのノウハウ
Android起動周りのノウハウAndroid起動周りのノウハウ
Android起動周りのノウハウ
 
Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1) Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1)
 
Linux Kernel Init Process
Linux Kernel Init ProcessLinux Kernel Init Process
Linux Kernel Init Process
 

Similar to OffensiveCon2022: Case Studies of Fuzzing with Xen

Kernel Mode Threats and Practical Defenses
Kernel Mode Threats and Practical DefensesKernel Mode Threats and Practical Defenses
Kernel Mode Threats and Practical Defenses
Priyanka Aash
 
the NML project
the NML projectthe NML project
the NML project
Lei Yang
 
Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0
guest72e8c1
 
4 implementation
4 implementation4 implementation
4 implementation
hanmya
 

Similar to OffensiveCon2022: Case Studies of Fuzzing with Xen (20)

Platform Security Summit 18: Xen Security Weather Report 2018
Platform Security Summit 18: Xen Security Weather Report 2018Platform Security Summit 18: Xen Security Weather Report 2018
Platform Security Summit 18: Xen Security Weather Report 2018
 
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
Hacktivity2014: Virtual Machine Introspection to Detect and ProtectHacktivity2014: Virtual Machine Introspection to Detect and Protect
Hacktivity2014: Virtual Machine Introspection to Detect and Protect
 
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORSDEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
 
LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...
LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...
LCNA14: Why Use Xen for Large Scale Enterprise Deployments? - Konrad Rzeszute...
 
VM Forking and Hypervisor-based fuzzing
VM Forking and Hypervisor-based fuzzingVM Forking and Hypervisor-based fuzzing
VM Forking and Hypervisor-based fuzzing
 
LCC17 - Securing Embedded Systems with the Hypervisor - Lars Kurth, Citrix
LCC17 - Securing Embedded Systems with the Hypervisor - Lars Kurth, CitrixLCC17 - Securing Embedded Systems with the Hypervisor - Lars Kurth, Citrix
LCC17 - Securing Embedded Systems with the Hypervisor - Lars Kurth, Citrix
 
Kernel Mode Threats and Practical Defenses
Kernel Mode Threats and Practical DefensesKernel Mode Threats and Practical Defenses
Kernel Mode Threats and Practical Defenses
 
the NML project
the NML projectthe NML project
the NML project
 
Securing Your Linux System
Securing Your Linux SystemSecuring Your Linux System
Securing Your Linux System
 
RMLL / LSM 2009
RMLL / LSM 2009RMLL / LSM 2009
RMLL / LSM 2009
 
Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0Rmll Virtualization As Is Tool 20090707 V1.0
Rmll Virtualization As Is Tool 20090707 V1.0
 
2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat2012-03-15 What's New at Red Hat
2012-03-15 What's New at Red Hat
 
Sierraware ARM hypervisor
Sierraware ARM hypervisor Sierraware ARM hypervisor
Sierraware ARM hypervisor
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM BoardsDevelop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
 
Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?Docker, Linux Containers, and Security: Does It Add Up?
Docker, Linux Containers, and Security: Does It Add Up?
 
DFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
DFIR Austin Training (Feb 2020): Remote Access & Deploying AgentsDFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
DFIR Austin Training (Feb 2020): Remote Access & Deploying Agents
 
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan BalazsHacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
 
Attack on the Core
Attack on the CoreAttack on the Core
Attack on the Core
 
31c3 Presentation - Virtual Machine Introspection
31c3 Presentation - Virtual Machine Introspection31c3 Presentation - Virtual Machine Introspection
31c3 Presentation - Virtual Machine Introspection
 
4 implementation
4 implementation4 implementation
4 implementation
 

More from Tamas K Lengyel

Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis SystemScalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Tamas K Lengyel
 
Dfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopDfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshop
Tamas K Lengyel
 

More from Tamas K Lengyel (19)

Estimating Security Risk Through Repository Mining
Estimating Security Risk Through Repository MiningEstimating Security Risk Through Repository Mining
Estimating Security Risk Through Repository Mining
 
Pitfalls and limits of dynamic malware analysis
Pitfalls and limits of dynamic malware analysisPitfalls and limits of dynamic malware analysis
Pitfalls and limits of dynamic malware analysis
 
VM Forking and Hypervisor-based Fuzzing with Xen
VM Forking and Hypervisor-based Fuzzing with XenVM Forking and Hypervisor-based Fuzzing with Xen
VM Forking and Hypervisor-based Fuzzing with Xen
 
BSides Denver: Stealthy, hypervisor-based malware analysis
BSides Denver: Stealthy, hypervisor-based malware analysisBSides Denver: Stealthy, hypervisor-based malware analysis
BSides Denver: Stealthy, hypervisor-based malware analysis
 
Hacktivity 2016: Stealthy, hypervisor based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysisHacktivity 2016: Stealthy, hypervisor based malware analysis
Hacktivity 2016: Stealthy, hypervisor based malware analysis
 
Anti-evil maid with UEFI and Xen
Anti-evil maid with UEFI and XenAnti-evil maid with UEFI and Xen
Anti-evil maid with UEFI and Xen
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware Analysis
 
Malware Collection and Analysis via Hardware Virtualization
Malware Collection and Analysis via Hardware VirtualizationMalware Collection and Analysis via Hardware Virtualization
Malware Collection and Analysis via Hardware Virtualization
 
CyberSEED: Virtual Machine Introspection to Detect and Protect
CyberSEED: Virtual Machine Introspection to Detect and ProtectCyberSEED: Virtual Machine Introspection to Detect and Protect
CyberSEED: Virtual Machine Introspection to Detect and Protect
 
Virtual Machine Introspection with Xen
Virtual Machine Introspection with XenVirtual Machine Introspection with Xen
Virtual Machine Introspection with Xen
 
Cloud Security with LibVMI
Cloud Security with LibVMICloud Security with LibVMI
Cloud Security with LibVMI
 
Troopers15 Lightning talk: VMI & DRAKVUF
Troopers15 Lightning talk: VMI & DRAKVUFTroopers15 Lightning talk: VMI & DRAKVUF
Troopers15 Lightning talk: VMI & DRAKVUF
 
CrySys guest-lecture: Virtual machine introspection on modern hardware
CrySys guest-lecture: Virtual machine introspection on modern hardwareCrySys guest-lecture: Virtual machine introspection on modern hardware
CrySys guest-lecture: Virtual machine introspection on modern hardware
 
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis SystemScalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
 
Virtual Machine Introspection with Xen on ARM
Virtual Machine Introspection with Xen on ARMVirtual Machine Introspection with Xen on ARM
Virtual Machine Introspection with Xen on ARM
 
Pitfalls of virtual machine introspection on modern hardware
Pitfalls of virtual machine introspection on modern hardwarePitfalls of virtual machine introspection on modern hardware
Pitfalls of virtual machine introspection on modern hardware
 
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and CloningNSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
NSS 2013: Towards Hybrid Honeynets via Virtual Machine Introspection and Cloning
 
Virtual Machine Introspection in a Hyberid Honeypot Architecture
Virtual Machine Introspection in a Hyberid Honeypot ArchitectureVirtual Machine Introspection in a Hyberid Honeypot Architecture
Virtual Machine Introspection in a Hyberid Honeypot Architecture
 
Dfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshopDfrws eu 2014 rekall workshop
Dfrws eu 2014 rekall workshop
 

Recently uploaded

Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
drjose256
 

Recently uploaded (20)

Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 

OffensiveCon2022: Case Studies of Fuzzing with Xen

  • 1. Case Studies of Fuzzing with Xen Tamas K Lengyel @tklengyel Balint Varga-Perke @buherator
  • 2. 2 Disclaimers Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex​. Performance results are based on testing as of dates shown in configurations and may not reflect all publicly available ​updates. See backup for configuration details. No product or component can be absolutely secure. No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document. Intel does not control or audit third-party data. You should consult other sources to evaluate accuracy. Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade. Your costs and results may vary. Intel technologies may require enabled hardware, software or service activation. © Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others. ​
  • 3. 3 TL;DR KF/x: https://github.com/intel/kernel-fuzzer-for-xen-project Full-VM snapshot fuzzer Open-source (MIT) Integrates with AFL/AFL++ In this talk – the tale of two vastly different targets - Linux Virtio - Symantec Endpoint Protection
  • 4. 4 Xen VM forking Copy-on-write memory in VM forks Reset vCPU registers and free dirty pages Parent VM … Page X Page Y Page Z … Fork VM … Shared Page X Copied Page Y Shared Page Z … R W X
  • 5. 5 Can run multiple forks & multiple fuzzing loops concurrently Fuzzing with KF/x Parent VM Magic CPUID Fork Sink VM panic() kasan_report() ubsan_prologue() … Fuzz VM Add 0xCC Read input from AFL Write it to VM’s mem Reset Catch a breakpoint Report crash Catch Magic CPUID Report no-crash Neither: timeout Analyze Decode IPT log Report coverage Fork Run Fuzz Compile & run target code with CPUID harness in place. No custom compiler needed! Any error-handling function can be a designated sink point. Easy to override with custom list (symbol name, VA or PA).
  • 6. 6 Design principles behind KF/x Stable foundation - All hypervisor components upstream (VM forking, introspection, IPT) Reduced complexity - No in-guest agent necessary Flexible - Components should be reusable to target any code running in the VM Extendable - Integrate with other fuzzers, use different harness mechanism, etc.
  • 7. 7 Limitations No I/O in fork VMs - No disk, no network, no screen, no console, no MMIO, no interrupts - Single vCPU only Bug enrichment features need to be compiled-in (ASAN, UBSAN) Target needs to execute normally in a Xen VM
  • 8. 8 Fuzzing Virtio Part of a larger kernel hardening project in preparation for TDX See Linux Security Summit ‘21 talk by Elena Reshetova Attacking guest from the host via shared memory (“DMA”) Xen doesn’t support Virtio – can’t use KF/x - Unless .. !
  • 9. 9 VM transplantation! The idea is simple: 1. Capture system state on KVM 2. Transfer it to Xen 3. Load 4. Fuzz!
  • 10. 10 Capturing the system state During fuzzing we are running the VM forks with only: - Memory - CPU We are in luck! QEMU QMP command dump-guest-memory - Creates and ELF file detailing the memory map & memory contents - Surprise undocumented feature: an ELF note has the CPU register state We also need the magic CPUID pausing on KVM
  • 11. 11 KVM patch to exit on magic CPUID QEMU patch to pause VM
  • 12. 12 Loading state on Xen 1. Create “empty” VM 2. Load memory according to memory map 3. Load CPU register state - Fix mismatch between segment attribute byte format in ELF vs Xen
  • 14. 14 Back to Virtio We have a way to save, transplant & fuzz Just have to figure out what to fuzz.. Virtio will be used for all I/O on TDX 1.0 - Disk, network, console That’s a lot of different code-paths to cover - Does anyone even know all the different ways Virtio code is reached?
  • 15. 15 Retargeting existing code Had a similar challenge while fuzzing xHCI Made a tool (dmamonitor) that can hook Linux’s DMA API - Hook dma_alloc_attrs with VMI - Remove EPT permission from DMA pages - Log RIP when EPT fault triggers with read-violation Could really use it here too.. - We are in luck: https://github.com/KVM-VMI/kvm-vmi
  • 16. 16 Boot Linux with DMA debug patched to have dummy API for easier hooking & force Virtio to go through DMA API DMA hook triggers for DMA page use Change EPT permission KVM Setup DMA page Linux VM boot & runtime DMA monitor E P T Handle EPT read-fault Unwind stack & hash return pointers If hash is new, snapshot EPT fault triggers when Virtio is fetching data from page 1. 3. 2. 4.
  • 18. 18 No end-harness We don’t need any! 1. Transplant snapshot 2. Fork 3. Singlestep up to 300k 4. Check which of the stack return pointers was reached 5. Inject breakpoint to transplant 6. Fuzz!
  • 19. 19 Results with hardened 5.15-rc6 126,061 DMA accesses observed during boot and basic functioning 13 unique DMA access sites 738 unique call-chains lead to DMA access 70 snapshots fuzzed based on top-5 stack frame uniqueness 7,567,463,809 fuzzing cycles completed (in 2 weeks) 0 issues found (no KASAN/UBSAN/panic/oops) 13 snapshots were found to have hangs when fuzzed 54 snapshots had less then 5 paths discovered
  • 20. 20 No bugs? We weren’t the first - Check out VIA: Analyzing Device Interfaces of Protected Virtual Machines - They fuzzed 5.10 and already reported the sanitizer bugs & got them fixed - We were able to catch some of the same bugs they found when we targeted 5.10 I still consider this a win - Tools & techniques all open-sourced & anyone is welcome to replicate - KF/x target setup & fuzzing can now happen at different systems - No longer need to setup your target on Xen (can use QEMU/KVM/Simics) Thanks to the whole lot of folks! Andrew Cooper, Sundaram Arumugasundaram, Mostafa Elsaid, Andi Kleen, Neelima Krishnan, Sathyanarayanan Kuppuswamy, Lukasz Odzioba, Sebastian Osterlund, Elena Reshetova, Carlos Villavicencio Sanchez, Casey Schaufler, Steffen Schulz, Mathieu Tarral
  • 21. 21 Antivirus fuzzing • Widespread technology • Complex parsers implemented in C/C++ • Remotely reachable attack surface • High privileges • Prior work: Antivirus (in)Security, Attacking Antivirus, P0 massacre, Sophail, Nightmare, The AV Hacker’s Handbook, REing Defender, tons of privescs, blackhats, and many others (sry if I missed yours!)
  • 22. 22 Antivirus fuzzing • Complex software • Binary-only (mostly) • Performance • Inspectability • State • Diversity • Products • Formats
  • 23. 23 KF/x vs. AV • Reusable harness • Full inspectability • Full-system fuzzing • Written documentation + well-known platform
  • 25. 25 Symantec Endpoint Protection • Tamper protection • Can be disabled, some memory still not accessible • COM-like architecture • Complex inter-module dependencies (writeup soon) • COM is obfuscation: No export symbols, no typelib, indirect calls … • OS interference
  • 26. 26 Proof-of-Concept • Multiple bugs discovered by Tavis Ormandy in 2016. • “Decomposers” • Unrar, dec2lha, libmspack, … -> ccScanW.dll • Try to rediscover #823 – “PowerPoint misaligned stream-cache remote stack buffer overflow” • Easy to modify nasm PoC • /GS still not applied to all (non-trivial) functions #YOLO
  • 27. 27 Proof-of-Concept • #823 allowed quick identification of the relevant parser function and I/O functions • KF/x tuning • Interrupt masking • sinks.h -> “KiDispatchException” (resolved by Volatility) • if (addr & 0x80000000) return; • Large test case • SEP reads data in 8k chunks • 6 reads necessary before the bug triggers (no disk in KF/x!)
  • 29. 29 Handling large inputs • Large inputs are not ideal for fuzzing in general • Performance • Process state • Mocking I/O • Tried it, wouldn’t recommend… • RAM disk works (on Windows too) • Chained fuzzing stages • Other traps: swapping, console output, network, …
  • 30. 30 Other parsers? • Rabbit Hole Ghidra extension • Per-function cumulative cyclomatic complexity • Ghidra Cpp Class Analyzer • RTTI info • Magic numbers • New target: 7zip decomposer • Magic number + high complexity + reachable from C7zEngine class members
  • 31. 31 “While this fuzzer runs, I will…”1 • Corpus: 1 file, some txt 7z’d with default options • AFL++, no knowledge about the file format • Coverage tracking with Intel PT • Single core • < 24h runtime • ~9M execs ~400-500 exec/s (not a perf talk sry) • No hang elimination (“loose paths”, timeout optimization, …) 1 How to FAIL at Fuzzing, Prospector
  • 32. 32 Fuzzing Symantec Endpoint Protection's 7z parser with KF/x
  • 33. 33 7z bug • Controlled heap overflow • Detection can be improved by enabling page heap • Silently fixed? • Symantec->Broadcom didn’t make investigation easy Mandatory AFL graph
  • 34. 34 Using REVEN to triage the 7z parsing heap overflow discovered with KF/x
  • 35. 35 Modularity • KF/x follows the Unix philosophy • AFL’s SHMAP became a de-facto standard • Forkserver-based intergration with LibAFL was trivial • Timeout/signal handling needed improvement (I/O fail -> hang) • Independent development of generators, mutators, etc. • In-memory input passing needs little more work
  • 37. 37 Other use-cases • AV • Kernel components • Memory scanners • DPI/DLP/IPS features • Games / Anti-cheat • Sandbox escapes • Nyx Fuzzer, Fuzzy Snapshots of Firefox IPC
  • 38. 38 Summary • Trivial vulnerabilities could remain hidden due to the lack of proper tools • VM Introspection is a game changer in vulnerability discovery/analysis • KF/x is an easy to integrate VMI-based fuzzing harness