SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
Creating Secure VM
Comparison between Intel and AMD, and one more thing…



                                   Tsukasa Ooi <li@livegrid.org>
                             Livegrid Incorporated, Lead Analyst
Related Topics
• Virtualization
• Behavior based Detection
• Reverse Engineering
What is “Secure VM”?
• Virtual Machine having…
   –   Invisible Breakpoint
   –   Direct Memory Lookup/Modification
   –   System I/O Interception
   –   Instruction/Memory Tracing
• They are useful for security!
   – Direct Memory Lookup to detect rootkits
   – Hooking disk I/Os to find malwares
How to “secure” Virtual Machines
• There are two major ways
  (if CPU-assisted virtualization is used)
• Using Debug Registers (DR0~DR7)
   – DR7.GD bit : Makes guest DRx registers inaccessible
   – VM exit when DR access : Can hook DRx read/write
• Using Page Table Modification
   – PTE.R/W bit : Can hook page write
   – PTE.P bit : Can hook page access (read/write/exec)
   – PTE.NX bit : Can hook page execution
How to set Breakpoint (Debug Registers)
• Set VM exit when:
  – DRx access
  – #DB (Debug) exception
• Set guest DR7.GD bit
• Set guest breakpoint using guest DRx
  – Useful point : Kernel Functions, System Calls…
• If breakpoint is hit…
  – Do extra validation
How to set Breakpoint (Page Table)
• Set VM exit when:
  – #PF (Page Fault) exception
• Reset PTE.P bit or PTE.NX bit of page
  – Do not change guest page table, but shadow.
• If Page Fault is occurred
  – Check if breakpoint is hit (can be false-positive)
  – If breakpoint is hit, do extra validation
Comparison (Debug Registers / Page Table)
• Using Debug Registers is simple
   – Easy to implement
• Using Page Table can handle 5 or more breakpoint
   – Breakpoints of Debug Registers are limited to 4
   – If guest OS also use Debug Registers,
     need to emulate using Page Table Modification
• Using Debug Registers is faster
   – No false-positive, low overhead
• Using Page Table is flexible
   – Can intercept “nearly everything”
Considerations of CPU-assisted virt.
• Cannot intercept important instructions
  – Such as sysenter, sysexit
• Limited interception
  compared than Binary Translation
Comparison between AMD-V/Intel VT-x
• Only AMD-V can intercept IRET instruction
  – Guest OS can workaround host-set breakpoint
    by set EFLAGS.RF bit (Resume Flag: Suppress
    breakpoints for single instruction) and execute
    IRETD instruction
• AMD-V is better if you use Debug Registers
  – No difference if you use Page Table Modification
  – Enough for hooking system calls (not mostly
    called through IRET instruction)
Second Level Address Translation (SLAT)
• Newer features for virtualization
• Two page tables to translate addresses
  – Guest Logical Addr → Guest Physical Addr
  – Guest Physical Addr → Host Physical Addr
• Intel and AMD both have SLAT extension
  – Intel : Extended Page Tables (EPT)
  – AMD : Nested Paging / Rapid virtualization index (RVI)
• But they got a problem…
SLAT considerations
• Limited ways for interception
  – REAL (guest) Page Tables are visible
  – Managing two page tables are bad for security-use
  – In some situation, SLAT cannot be enabled
• Debug Registers can be still used
What about difference?
• Intel EPT can make page “execute-only”
  – If Supported by CPU
     • Currently, all CPUs supporting Intel EPT also
       supports Execute-Only page
  – Stealthy is not enough, but can make invisible chunk
  – Please consider that guest software also can execute
    invisible chunk with jump instructions.
• Mostly same but Intel EPT is better
THANK YOU?
One More Thing:

FULL VIRTUALIZATION OF
X86 ARCHITECTURE ON X86_64
x86 emulation on x86_64 architecture
• Using Binary Translation…
• They are possible and (nearly) practical!
Why “x86 on x86_64”?
• Architecture is very similar
   – No need to execute normal instruction by 3
     instructions (just 1 or 2)
• Have extra memory
   – x86 emulation on x86_64 requires 44GB of virtual
     memory range, but it is easy to allocate in 64-bit mode.
• Have extra registers!
   – R8~R15 registers can be used for extra emulation
     context including trace log pointer…
How to “emulate” x86? (1)
PUSH EBP

MOV   EBP, ESP
MOV   EAX, [EBP+8]
MOV   EDX, [EBP+12]
MOV   EAX, [EAX*4+EDX]

POP   EBP

RET
How to “emulate” x86? (1)
PUSH EBP                 MOV [RCX+RBP-4], EBX
                         LEA EBP, [EBP-4]
MOV   EBP, ESP           MOV EBX, EBP
MOV   EAX, [EBP+8]       MOV EAX, [RCX+RBX+8]
MOV   EDX, [EBP+12]      MOV EDX, [RCX+RBX+12]
MOV   EAX, [EAX*4+EDX]   LEA R14D, [EAX*4+EDX]
                         MOV EAX, [RCX+R14]
POP   EBP                MOV EBX, [RCX+RBP]
                         LEA EBP, [EBP+4]
RET                      (Return Intrinsics)
How to “emulate” x86? (2)
• Register Remapping
  – ESP → EBP/RBP (Stack in x86_64 is 8-bytes)
  – EBP → EBX/RBX (To reduce cost of stack reference)
• RCX : Base address of 32-bit virtual memory
  – All virtual memory range!
• R14/R14D : Temporary Register
• R15 : Widely Used by Emulation System
Using Binary Translation…
• Full instruction/memory tracing of x86!
  – Including execution path, memory read/write…
• Very high overhead but it is worth doing.
What For?
• Detecting some kind of interferences
   – Exploits
   – Hooks
   – (Table/Memory) Modification
• Reverse Engineering
   – Can Trace Everything!
      • Anti-reverse engineering techniques can be detected
   – Protocol Reversing (File, Network…)
   – Algorithm reversing and finding
      • Finding algorithms are useful for anti-DRM.
How to “emulate” x86 with tracing? (1)
PUSH   EBP                MOV           [RCX+RBP-4], EBX
                          LEA           EBP, [EBP-4]
MOV    EBP, ESP           MOV           EBX, EBP
MOV    EAX, [EBP+8]       MOV           EAX, [RCX+RBX+8]
                          MOV           [R13], EAX
                          LEA           R13, [R13+4]
MOV    EDX, [EBP+12]      MOV           EDX, [RCX+RBX+12]
                          MOV           [R13], EDX
                          LEA           R13, [R13+4]
MOV    EAX, [EAX*4+EDX]   LEA           R14D, [EAX*4+EDX]
                          MOV           EAX, [RCX+R14]
                          MOV           [R13], EAX
                          LEA           R13, [R13+4]
POP    EBP                MOV           EBX, [RCX+RBP]
                          MOV           [R13], EBX
                          LEA           R13, [R13+4]
                          LEA           EBP, [EBP+4]
RET                       (Return Intrinsics)
How to “emulate” x86 with tracing? (2)
• R13 : Trace Log Pointer
  – Result of Memory Read
  – Address of Branch
• 1~5 instructions for emulating normal instructions
  – If translation program is “optimized”,
    required number of instructions can be reduced.
Is it practical?
• Nearly.
   – Current Performance Index w/o Disk-write stalls:
             Pentium 4 1.5GHz
     ≧       Core i7 3.0GHz in emulation
     >       Pentium III 1.0GHz
• Not enough for full-system emulation but
  enough for user-mode-emulation!
• Faster than any tracing methods before
  (Like debuggers such as OllyDbg, IDA Pro…)
Limitations / Considerations
• x86 segmentation and addressing
  – x86_64 is constrained “flat memory model”
  – High overhead to emulate segment limit
• VERY FAST Disks are required
  – Fortunately, writing trace log is almost
    “sequential-write” so RAID using HDD is useful
• Consumes much of resources
  – Requires much of memory
When will be available?
• Currently, only experimental programs
  are working…
  – Not “practical” programs…
• I hope… Q2, 2010
Have any questions?

THANK YOU.

Contenu connexe

Tendances

Tendances (20)

The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
JRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing WorldJRuby with Java Code in Data Processing World
JRuby with Java Code in Data Processing World
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101
 
Fluentd - Set Up Once, Collect More
Fluentd - Set Up Once, Collect MoreFluentd - Set Up Once, Collect More
Fluentd - Set Up Once, Collect More
 
Fluentd introduction at ipros
Fluentd introduction at iprosFluentd introduction at ipros
Fluentd introduction at ipros
 
Developing high-performance network servers in Lisp
Developing high-performance network servers in LispDeveloping high-performance network servers in Lisp
Developing high-performance network servers in Lisp
 
Apache HTTPd Server 2.2 Presentation
Apache HTTPd Server 2.2 PresentationApache HTTPd Server 2.2 Presentation
Apache HTTPd Server 2.2 Presentation
 
Erlang on OSv
Erlang on OSvErlang on OSv
Erlang on OSv
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. Kute
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. Kute
 
CPAN Training
CPAN TrainingCPAN Training
CPAN Training
 
Fluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API DetailsFluentd v0.14 Plugin API Details
Fluentd v0.14 Plugin API Details
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
 
Fluentd 101
Fluentd 101Fluentd 101
Fluentd 101
 
Fluentd v0.14 Overview
Fluentd v0.14 OverviewFluentd v0.14 Overview
Fluentd v0.14 Overview
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
 
Perforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and ReliabilityPerforce Administration: Optimization, Scalability, Availability and Reliability
Perforce Administration: Optimization, Scalability, Availability and Reliability
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 

Similaire à Creating Secure VM (Comarison between Intel and AMD, and one more thing...) - AVTokyo 2009

Similaire à Creating Secure VM (Comarison between Intel and AMD, and one more thing...) - AVTokyo 2009 (20)

ESIL - Universal IL (Intermediate Language) for Radare2
ESIL - Universal IL (Intermediate Language) for Radare2ESIL - Universal IL (Intermediate Language) for Radare2
ESIL - Universal IL (Intermediate Language) for Radare2
 
Modern CPUs and Caches - A Starting Point for Programmers
Modern CPUs and Caches - A Starting Point for ProgrammersModern CPUs and Caches - A Starting Point for Programmers
Modern CPUs and Caches - A Starting Point for Programmers
 
Hadoop Architecture_Cluster_Cap_Plan
Hadoop Architecture_Cluster_Cap_PlanHadoop Architecture_Cluster_Cap_Plan
Hadoop Architecture_Cluster_Cap_Plan
 
Pipiot - the double-architecture shellcode constructor
Pipiot - the double-architecture shellcode constructorPipiot - the double-architecture shellcode constructor
Pipiot - the double-architecture shellcode constructor
 
Coal (1)
Coal (1)Coal (1)
Coal (1)
 
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructureDevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
 
Why databases cry at night
Why databases cry at nightWhy databases cry at night
Why databases cry at night
 
Introduction to debugging linux applications
Introduction to debugging linux applicationsIntroduction to debugging linux applications
Introduction to debugging linux applications
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory(8) cpp stack automatic_memory_and_static_memory
(8) cpp stack automatic_memory_and_static_memory
 
OSDC 2017 | Open POWER for the data center by Werner Fischer
OSDC 2017 | Open POWER for the data center by Werner FischerOSDC 2017 | Open POWER for the data center by Werner Fischer
OSDC 2017 | Open POWER for the data center by Werner Fischer
 
OSDC 2017 - Werner Fischer - Open power for the data center
OSDC 2017 - Werner Fischer - Open power for the data centerOSDC 2017 - Werner Fischer - Open power for the data center
OSDC 2017 - Werner Fischer - Open power for the data center
 
OSDC 2017 | Linux Performance Profiling and Monitoring by Werner Fischer
OSDC 2017 | Linux Performance Profiling and Monitoring by Werner FischerOSDC 2017 | Linux Performance Profiling and Monitoring by Werner Fischer
OSDC 2017 | Linux Performance Profiling and Monitoring by Werner Fischer
 
OSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin CharlesOSDC 2016 - Tuning Linux for your Database by Colin Charles
OSDC 2016 - Tuning Linux for your Database by Colin Charles
 
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
 
Exploit techniques - a quick review
Exploit techniques - a quick reviewExploit techniques - a quick review
Exploit techniques - a quick review
 
Howmysqlworks
HowmysqlworksHowmysqlworks
Howmysqlworks
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 Disassembly
 

Plus de Tsukasa Oi

Windows をより安全にする SafeSEH on MinGW
Windows をより安全にする SafeSEH on MinGWWindows をより安全にする SafeSEH on MinGW
Windows をより安全にする SafeSEH on MinGW
Tsukasa Oi
 
A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010
Tsukasa Oi
 
リバースエンジニアリングのための新しいトレース手法 - PacSec 2010
リバースエンジニアリングのための新しいトレース手法 - PacSec 2010リバースエンジニアリングのための新しいトレース手法 - PacSec 2010
リバースエンジニアリングのための新しいトレース手法 - PacSec 2010
Tsukasa Oi
 
ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009
ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009
ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009
Tsukasa Oi
 
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
Tsukasa Oi
 
Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009
Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009
Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009
Tsukasa Oi
 
システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009
システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009
システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009
Tsukasa Oi
 
セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009
セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009
セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009
Tsukasa Oi
 

Plus de Tsukasa Oi (10)

Farewell, Stagefright bugs!
Farewell, Stagefright bugs!Farewell, Stagefright bugs!
Farewell, Stagefright bugs!
 
さらば、Stagefright 脆弱性
さらば、Stagefright 脆弱性さらば、Stagefright 脆弱性
さらば、Stagefright 脆弱性
 
Windows をより安全にする SafeSEH on MinGW
Windows をより安全にする SafeSEH on MinGWWindows をより安全にする SafeSEH on MinGW
Windows をより安全にする SafeSEH on MinGW
 
A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010
 
リバースエンジニアリングのための新しいトレース手法 - PacSec 2010
リバースエンジニアリングのための新しいトレース手法 - PacSec 2010リバースエンジニアリングのための新しいトレース手法 - PacSec 2010
リバースエンジニアリングのための新しいトレース手法 - PacSec 2010
 
ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009
ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009
ステルスルートキット : 悪いヤツはどうライブメモリフォレンジックをすり抜ける? - PacSec 2009
 
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
Stealthy Rootkit : How bad guy fools live memory forensics? - PacSec 2009
 
Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009
Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009
Lack of System Registers and two simple anti-forensic attacks - AVTokyo 2009
 
システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009
システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009
システムレジスタの不足と2つのシンプルなアンチフォレンジック攻撃 - AVTokyo 2009
 
セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009
セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009
セキュアVMの構築 (IntelとAMDの比較、あともうひとつ...) - AVTokyo 2009
 

Dernier

+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

+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...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Creating Secure VM (Comarison between Intel and AMD, and one more thing...) - AVTokyo 2009

  • 1. Creating Secure VM Comparison between Intel and AMD, and one more thing… Tsukasa Ooi <li@livegrid.org> Livegrid Incorporated, Lead Analyst
  • 2. Related Topics • Virtualization • Behavior based Detection • Reverse Engineering
  • 3. What is “Secure VM”? • Virtual Machine having… – Invisible Breakpoint – Direct Memory Lookup/Modification – System I/O Interception – Instruction/Memory Tracing • They are useful for security! – Direct Memory Lookup to detect rootkits – Hooking disk I/Os to find malwares
  • 4. How to “secure” Virtual Machines • There are two major ways (if CPU-assisted virtualization is used) • Using Debug Registers (DR0~DR7) – DR7.GD bit : Makes guest DRx registers inaccessible – VM exit when DR access : Can hook DRx read/write • Using Page Table Modification – PTE.R/W bit : Can hook page write – PTE.P bit : Can hook page access (read/write/exec) – PTE.NX bit : Can hook page execution
  • 5. How to set Breakpoint (Debug Registers) • Set VM exit when: – DRx access – #DB (Debug) exception • Set guest DR7.GD bit • Set guest breakpoint using guest DRx – Useful point : Kernel Functions, System Calls… • If breakpoint is hit… – Do extra validation
  • 6. How to set Breakpoint (Page Table) • Set VM exit when: – #PF (Page Fault) exception • Reset PTE.P bit or PTE.NX bit of page – Do not change guest page table, but shadow. • If Page Fault is occurred – Check if breakpoint is hit (can be false-positive) – If breakpoint is hit, do extra validation
  • 7. Comparison (Debug Registers / Page Table) • Using Debug Registers is simple – Easy to implement • Using Page Table can handle 5 or more breakpoint – Breakpoints of Debug Registers are limited to 4 – If guest OS also use Debug Registers, need to emulate using Page Table Modification • Using Debug Registers is faster – No false-positive, low overhead • Using Page Table is flexible – Can intercept “nearly everything”
  • 8. Considerations of CPU-assisted virt. • Cannot intercept important instructions – Such as sysenter, sysexit • Limited interception compared than Binary Translation
  • 9. Comparison between AMD-V/Intel VT-x • Only AMD-V can intercept IRET instruction – Guest OS can workaround host-set breakpoint by set EFLAGS.RF bit (Resume Flag: Suppress breakpoints for single instruction) and execute IRETD instruction • AMD-V is better if you use Debug Registers – No difference if you use Page Table Modification – Enough for hooking system calls (not mostly called through IRET instruction)
  • 10. Second Level Address Translation (SLAT) • Newer features for virtualization • Two page tables to translate addresses – Guest Logical Addr → Guest Physical Addr – Guest Physical Addr → Host Physical Addr • Intel and AMD both have SLAT extension – Intel : Extended Page Tables (EPT) – AMD : Nested Paging / Rapid virtualization index (RVI) • But they got a problem…
  • 11. SLAT considerations • Limited ways for interception – REAL (guest) Page Tables are visible – Managing two page tables are bad for security-use – In some situation, SLAT cannot be enabled • Debug Registers can be still used
  • 12. What about difference? • Intel EPT can make page “execute-only” – If Supported by CPU • Currently, all CPUs supporting Intel EPT also supports Execute-Only page – Stealthy is not enough, but can make invisible chunk – Please consider that guest software also can execute invisible chunk with jump instructions. • Mostly same but Intel EPT is better
  • 14. One More Thing: FULL VIRTUALIZATION OF X86 ARCHITECTURE ON X86_64
  • 15. x86 emulation on x86_64 architecture • Using Binary Translation… • They are possible and (nearly) practical!
  • 16. Why “x86 on x86_64”? • Architecture is very similar – No need to execute normal instruction by 3 instructions (just 1 or 2) • Have extra memory – x86 emulation on x86_64 requires 44GB of virtual memory range, but it is easy to allocate in 64-bit mode. • Have extra registers! – R8~R15 registers can be used for extra emulation context including trace log pointer…
  • 17. How to “emulate” x86? (1) PUSH EBP MOV EBP, ESP MOV EAX, [EBP+8] MOV EDX, [EBP+12] MOV EAX, [EAX*4+EDX] POP EBP RET
  • 18. How to “emulate” x86? (1) PUSH EBP MOV [RCX+RBP-4], EBX LEA EBP, [EBP-4] MOV EBP, ESP MOV EBX, EBP MOV EAX, [EBP+8] MOV EAX, [RCX+RBX+8] MOV EDX, [EBP+12] MOV EDX, [RCX+RBX+12] MOV EAX, [EAX*4+EDX] LEA R14D, [EAX*4+EDX] MOV EAX, [RCX+R14] POP EBP MOV EBX, [RCX+RBP] LEA EBP, [EBP+4] RET (Return Intrinsics)
  • 19. How to “emulate” x86? (2) • Register Remapping – ESP → EBP/RBP (Stack in x86_64 is 8-bytes) – EBP → EBX/RBX (To reduce cost of stack reference) • RCX : Base address of 32-bit virtual memory – All virtual memory range! • R14/R14D : Temporary Register • R15 : Widely Used by Emulation System
  • 20. Using Binary Translation… • Full instruction/memory tracing of x86! – Including execution path, memory read/write… • Very high overhead but it is worth doing.
  • 21. What For? • Detecting some kind of interferences – Exploits – Hooks – (Table/Memory) Modification • Reverse Engineering – Can Trace Everything! • Anti-reverse engineering techniques can be detected – Protocol Reversing (File, Network…) – Algorithm reversing and finding • Finding algorithms are useful for anti-DRM.
  • 22. How to “emulate” x86 with tracing? (1) PUSH EBP MOV [RCX+RBP-4], EBX LEA EBP, [EBP-4] MOV EBP, ESP MOV EBX, EBP MOV EAX, [EBP+8] MOV EAX, [RCX+RBX+8] MOV [R13], EAX LEA R13, [R13+4] MOV EDX, [EBP+12] MOV EDX, [RCX+RBX+12] MOV [R13], EDX LEA R13, [R13+4] MOV EAX, [EAX*4+EDX] LEA R14D, [EAX*4+EDX] MOV EAX, [RCX+R14] MOV [R13], EAX LEA R13, [R13+4] POP EBP MOV EBX, [RCX+RBP] MOV [R13], EBX LEA R13, [R13+4] LEA EBP, [EBP+4] RET (Return Intrinsics)
  • 23. How to “emulate” x86 with tracing? (2) • R13 : Trace Log Pointer – Result of Memory Read – Address of Branch • 1~5 instructions for emulating normal instructions – If translation program is “optimized”, required number of instructions can be reduced.
  • 24. Is it practical? • Nearly. – Current Performance Index w/o Disk-write stalls: Pentium 4 1.5GHz ≧ Core i7 3.0GHz in emulation > Pentium III 1.0GHz • Not enough for full-system emulation but enough for user-mode-emulation! • Faster than any tracing methods before (Like debuggers such as OllyDbg, IDA Pro…)
  • 25. Limitations / Considerations • x86 segmentation and addressing – x86_64 is constrained “flat memory model” – High overhead to emulate segment limit • VERY FAST Disks are required – Fortunately, writing trace log is almost “sequential-write” so RAID using HDD is useful • Consumes much of resources – Requires much of memory
  • 26. When will be available? • Currently, only experimental programs are working… – Not “practical” programs… • I hope… Q2, 2010