SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
SEH overwrite and its
exploitability
Shuichiro Suzuki
Fourteenforty Research Institute Inc.
Research Engineer
Agenda
• Theme and Goal
• Review of SEH overwrites
• Protection mechanisms for SEH overwrites
• Bypassing protection mechanisms.
• Demonstration
• Conclusion
Theme and goal
Theme
• SEH overwriting is one of the major methods for exploiting
Windows software.
• We already have several protection mechanisms for SEH overwrites.
• Is the protection provided by DEP and SEHOP enough?
• How about the protection from SafeSEH and SEHOP?
Goal
• To reveal which combinations of the known protection mechanisms
for SEH overwrites are really effective.
• On the way to the goal, I will show you that we can bypass SafeSEH
and Software DEP and Hardware DEP and SEHOP, all at the same
time, under certain conditions.
Target environment
• Windows XP SP3
• Windows Vista SP1
• Windows 7
• 32bit processes on x86
• 32bit processes on x64 (WOW64)
• Visual Studio 2008 was used to compile all the
programs in this presentation.
Review of SEH Overwrite
About SEH
• SEH is “Structured Exception Handling”
• Exception handling system provided by
Windows
int test(void){
__try{
// Exception may occur here
}
__except( EXCEPTION_EXECUTE_HANDLER ){
// This handles the exception
}
return 0;
}
Inside Windows Exception Dispatching
0x0012ff50
0x0012ff7C
ExceptionList
FS Register
NT_TIB
0x0012ff90
0x0401790
0x0408800
Stack
EXCEPTION_RECORD
typedef struct _EXCEPTION_RECORD{
struct _EXCEPTION_RECORD *_next;
PEXCEPTION_ROUTINE _handler;
} EXCEPTION_RECORD;
SEH chain
0xffffffff
0x070BBCC
Thread Information
Block
_next
_handler
SEH Overwrite Attack
0x0012ff50
0x0401790
Stack Process Memory Space
Module(EXE or DLL)
Handler1
Buffer
Overflow!
0x0505690
Stack after an exception handler is called
0x0401790
Stack
0x909006eb
EXCEPTION_DISPOSITION __cdecl _except_handler (
struct _EXCEPTION_RECORD *_ExceptionRecord,
void * _EstablisherFrame,
struct _CONTEXT *_ContextRecord,
void * _DispatcherContext
);
ESP
_DispatcherContext
_ContextRecord
_EstablisherFrame
_ExceptionRecord
Address to return
_handler
ESP+8
pop eax
pop eax
retn
Attackers Arbitrary Code
Protection mechanisms
Protection mechanisms
• /GS
• SafeSEH
• SoftwareDEP
• SEHOP
• Hardware DEP
• ASLR
/GS
• Stack Guard by Visual Studio compiler
• This checks if a buffer overflow occurs before
returning from a function.
• This is irrelevant to SEH overwrites because an
exception can be generated before the check.
Protection mechanisms
SEH overwrites specific
SafeSEH
Handler1 0x00002550
Handler2 0x00049080
Handler3 …
… …
A module protected by SafeSEH
Handler1
Handler2
0x00002550
0x00049080
Header
Code
“pop,pop,ret” sequence
×
Weakness of SafeSEH
Module
SafeSEH Protected
Module
Not SafeSEH Protected
pop pop ret×
pop pop ret
pop pop ret
pop pop ret
Memory Space
Data area
without executable attribute
Data area
with executable attribute
Data area in a module
Modules not protected by SafeSEH
From Thunderbird 2.0.0.23
* All modules in Thunderbird 3.0.3 are compiled with /SafeSEH
pop pop ret in the wild
From thunderbird.exe
Additional check by Software DEP
Module
SafeSEH Protected
Module
Not SafeSEH Protected
pop pop ret×
pop pop ret
pop pop ret
pop pop ret
Memory Space
Data area
without executable attribute
Data area
with executable attribute
Data area in a module
Weekness
Software DEP
0: kd> dt nt!_KEXECUTE_OPTIONS
+0x000 ExecuteDisable : Pos 0, 1 Bit
+0x000 ExecuteEnable : Pos 1, 1 Bit
+0x000 DisableThunkEmulation : Pos 2, 1 Bit
+0x000 Permanent : Pos 3, 1 Bit
+0x000 ExecuteDispatchEnable : Pos 4, 1 Bit
+0x000 ImageDispatchEnable : Pos 5, 1 Bit
+0x000 DisableExceptionChainValidation : Pos 6, 1 Bit
+0x000 Spare : Pos 7, 1 Bit
KPROCESS structure
_KEXECUTE_OPTIONS
Software DEP
pop pop ret×
pop pop ret
pop pop ret
pop pop ret
Memory Space
×
×
Data area in a module×
Module
SafeSEH Protected
Module
Not SafeSEH Protected
Data area
without executable attribute
Data area
with executable attribute
Memory Space
0x00405600
SEHOP
0x12ff50
0x0012ff90
0x04224550
0x0701790
0x12ffe4
0x0701790
0xffffffff
FinalExceptionHandler
0x909006eb
×
Overwrite!
NTDLL.DLL
Module 2
pop pop ret
Module 1
Proper Handler
SEH Chain
Stack
SEH overwrites protection
Protection mechanisms
Generic protections
Hardware DEP and ASLR
• Hardware DEP prevents code without
executable attribute from being executed.
• ASLR has several impacts on the SEH
overwrites.( Explain later )
Bypassing protection
mechanisms
SafeSEH and Software DEP
pop pop ret
pop pop ret
pop pop ret
pop pop ret
Memory Space
Data area in a module
pop pop ret×
pop pop ret
pop pop ret
pop pop ret
Memory Space
Data area in a module
×
×
×
×
×
×
×
×
Module SafeSEH Protected
Module Not SafeSEH
Protected
Non module area (Data
area)
Non module area
with executable attribute
Bypassing SEHOP
• It is weak if the address of a buffer overflow
and FinalExceptionHandler is known.
• Attackers can recreate a proper SEH chain.
0x00405600
0x12ff50
0x0012ff90
0x04224550
0x0701790
0x12ffe4
0x0701790
0xffffffff
FinalExceptionHandler
0x12ff50
Overwrite!
Bypassing Hardware DEP
• Return-into-libc
• Return-oriented programming VirutalAlloc
Stack
Args for
VirtualAlloc
memcpy
Args for
memcpy
CreateFile
Args for
CreateFile
...
ESP
Buffer overflow
Bypass /GS, SafeSEH, Software DEP,
Hardware DEP, SEHOP
• Recreate SEH Chain (bypassing SEHOP)
• Overwritten exception handler address must be in a
module which is not SafeSEH enabled ( bypassing
SafeSEH )
• Create a stack to execute desired code ( bypassing
Hardware DEP )
• To execute the code using the stack above, we have to
set an exception handler to some stack rewind and
return instructions ( bypassing Hardware DEP )
• Trigger an exception
Recreating the SEH Chain and
Setting the Exception Handler Address
0x0012ff50
0x0401790
Stack Process Memory Space
Module(EXE or DLL) No SafeSEH
Buffer
0xffffffff
FinalExceptionHandler
Module(EXE or DLL)
Handler1
SEH Chain
Exception!
0xffffffff
FinalExceptionHandler
0x0505690
0x0012ff4C
Attackers Arbitrary Code
and Data
Good instruction to bypass Hardware
DEP
0x0012ff50
Module(EXE or DLL) No
SafeSEH
Buffer
0x0505690
0xffffffff
FinalExceptionHandler
Module(EXE or DLL)
Handler1
add esp, 0x0C24
retn
Exception Information
0x0c24
Attackers Arbitrary
Code
Stack Process Memory Space
Create proper stack for return-into-libc
0x0012ff50
Module(EXE or DLL) No
SafeSEH
Buffer
0x0505690
0xffffffff
FinalExceptionHandler
Module(EXE or DLL)
Handler1
add esp, 0x0C24
retn
Exception Information
0x0c24
Attackers Arbitrary
Code
Stack Process Memory Space
0x00401110
0x30000000
0x00000800
0x00003000
0x00000040
0x30000000
0x30000000
0x0012F758
0x00000800
Address of VirtualAlloc
Address of memcpy
Address to be allocated
The size to be allocated
MEM_COMMIT|MEM_RESERVE
PAGE_EXECUTE_READWRITE
Address to return after memcpy
Dest to copy
Src of copy
The size to be copied
0x7c8622A4
Exception handlers which can be used
0x0012ff50
Module(EXE or DLL) No
SafeSEH
Buffer
0x0505690
0xffffffff
FinalExceptionHandler
Module(EXE or DLL)
Handler1
add esp, 0x0C24
retn
Exception Information
0x0CF8
Attackers Arbitrary
Code
Stack Process Memory Space
0x00401110
0x30000000
0x00000800
0x00003000
0x00000040
0x30000000
0x30000000
0x0012F758
0x00000800
Address of VirtualAlloc
Address of memcpy
Address to be allocated
The size to be allocated
MEM_COMMIT|MEM_RESERVE
PAGE_EXECUTE_READWRITE
Address to return after memcpy
Dest to copy
Src of copy
The size to be copied
0x7c8622A4
add esp, 0x0024
retn
Doesn’t work
Too small rewind
add esp, 0xFF24
retn
May be too big.
Depends on the stack size.
add esp, 0x0CF8
retn
Example of “add esp + retn”
From Thunderbird 2.0.0.23
Summarize the condition
• The address of the stack where buffer overflow occurs is known.
• The address of the FinalExceptionHandler in ntdll.dll is known.
• A process has a module not protected by /SafeSEH
• “add esp + retn” instructions which matches followings can be
found in the module.
– The amount of “add esp” rewind is larger than the stack made by
windows exception dispatcher.
– The amount of “add esp” rewind is smaller than the stack size when
the exception handler is called.
• The address of VirtualAlloc and memcpy is known ( or some
alternatives can be used).
• Attacker can write 0x00 on the stack by using buffer overflow, which
means string functions can’t be used to exploit. ( At least the
method I showed here can not be used if this doesn’t match)
Demonstration
• Demonstration on Windows 7
• I assumed that “add esp,0x0c24 – retn” can be
found in a non /SafeSEH protected module.
• /GS, Software DEP , Hardware DEP, SEHOP are
all enabled.
• ASLR is disabled.
Importance of ASLR
• Makes it difficult to recreate proper SEH chain
• Makes it difficult to find “add esp + retn”
instructions at a fixed address.
• Makes it difficult to set FinalExceptionHandler
address in the last element of SEH chain.
Conclusion
Protections Windows XP SP3 Windows Vista SP1 Windows 7
/GS + SafeSEH
Exploitable by using
data area as an
exception handler
Exploitable
by using data area as an
exception handler
Exploitable
by using data area as an
exception handler
/GS + SafeSEH + Software
DEP
If all modules are
SafeSEH protected its
difficult to exploit
If all modules are SafeSEH
protected its difficult to
exploit
If all modules are SafeSEH
protected its difficult to
exploit
/GS + Software DEP +
Hardware DEP
Exploitable by Return-
into-libc or Return-
oriented programming
Exploitable by Return-into-
libc or Return-oriented
programming
Exploitable by Return-into-
libc or Return-oriented
programming
/GS + Software DEP +
SEHOP
-
Exploitable by recreating
proper SEH chain
Exploitable by recreating
proper SEH chain
/GS + SafeSEH + SEHOP -
Exploitable by recreating
proper SEH chain and using
data area as an exception
handler
Exploitable by recreating
proper SEH chain and using
data area as an exception
handler
/GS + Software DEP +
SEHOP + Hardware DEP
-
Exploitable by recreating
proper SEH Chain and using
data area and return-oriented
programming
Exploitable by recreating
proper SEH Chain and using
data area and return-
oriented programming
/GS + SEHOP + ASLR - Difficult to exploit Difficult to exploit
/GS + Software DEP +
SEHOP + Hardware DEP +
ASLR
- Difficult to exploit Difficult to exploit
ASLR + DEP
• “Bypassing Browser Memory Protections”
( Alexander Sotirov, Mark Dowd ) shows how
to bypass them.
• But it was without SEHOP
Questions?

Mais conteúdo relacionado

Mais procurados (20)

Attacking thru HTTP Host header
Attacking thru HTTP Host headerAttacking thru HTTP Host header
Attacking thru HTTP Host header
 
Postman
PostmanPostman
Postman
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
RESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and JenkinsRESTful API Testing using Postman, Newman, and Jenkins
RESTful API Testing using Postman, Newman, and Jenkins
 
Py.test
Py.testPy.test
Py.test
 
Core java Essentials
Core java EssentialsCore java Essentials
Core java Essentials
 
Selenium Concepts
Selenium ConceptsSelenium Concepts
Selenium Concepts
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Introduction to selenium
Introduction to seleniumIntroduction to selenium
Introduction to selenium
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
JAVA PPT Part-1 BY ADI.pdf
JAVA PPT Part-1 BY ADI.pdfJAVA PPT Part-1 BY ADI.pdf
JAVA PPT Part-1 BY ADI.pdf
 
CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING
CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMINGCS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING
CS3391 OOP UT-I T3 FEATURES OF OBJECT ORIENTED PROGRAMMING
 
Robot Framework Introduction
Robot Framework IntroductionRobot Framework Introduction
Robot Framework Introduction
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Pentesting ReST API
Pentesting ReST APIPentesting ReST API
Pentesting ReST API
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application Security
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
 

Semelhante a SEH overwrite and its exploitability

Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Elvin Gentiles
 
Reversing & malware analysis training part 11 exploit development advanced
Reversing & malware analysis training part 11   exploit development advancedReversing & malware analysis training part 11   exploit development advanced
Reversing & malware analysis training part 11 exploit development advancedAbdulrahman Bassam
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyPriyanka Aash
 
VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkAmr Thabet
 
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]securityxploded
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...Hackito Ergo Sum
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022Stefano Stabellini
 
You're Off the Hook: Blinding Security Software
You're Off the Hook: Blinding Security SoftwareYou're Off the Hook: Blinding Security Software
You're Off the Hook: Blinding Security SoftwareCylance
 
13_14_MeltdownSpectre.pptx
13_14_MeltdownSpectre.pptx13_14_MeltdownSpectre.pptx
13_14_MeltdownSpectre.pptxPramodhN3
 
Debugging With Id
Debugging With IdDebugging With Id
Debugging With Idguest215c4e
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyPriyanka Aash
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013midnite_runr
 
Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedCysinfo Cyber Security Community
 
Post-mortem Debugging of Windows Applications
Post-mortem Debugging of  Windows ApplicationsPost-mortem Debugging of  Windows Applications
Post-mortem Debugging of Windows ApplicationsGlobalLogic Ukraine
 
Linux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/OLinux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/OYourHelper1
 
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP ChainsExploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP ChainsAjin Abraham
 
High Reliabilty Systems
High Reliabilty SystemsHigh Reliabilty Systems
High Reliabilty SystemsLloydMoore
 

Semelhante a SEH overwrite and its exploitability (20)

Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
 
Reversing & malware analysis training part 11 exploit development advanced
Reversing & malware analysis training part 11   exploit development advancedReversing & malware analysis training part 11   exploit development advanced
Reversing & malware analysis training part 11 exploit development advanced
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
 
VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development Framework
 
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
 
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022System Device Tree and Lopper: Concrete Examples - ELC NA 2022
System Device Tree and Lopper: Concrete Examples - ELC NA 2022
 
You're Off the Hook: Blinding Security Software
You're Off the Hook: Blinding Security SoftwareYou're Off the Hook: Blinding Security Software
You're Off the Hook: Blinding Security Software
 
13_14_MeltdownSpectre.pptx
13_14_MeltdownSpectre.pptx13_14_MeltdownSpectre.pptx
13_14_MeltdownSpectre.pptx
 
Advanced Windows Exploitation
Advanced Windows ExploitationAdvanced Windows Exploitation
Advanced Windows Exploitation
 
Debugging With Id
Debugging With IdDebugging With Id
Debugging With Id
 
Finding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated DisassemblyFinding Xori: Malware Analysis Triage with Automated Disassembly
Finding Xori: Malware Analysis Triage with Automated Disassembly
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
 
Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advanced
 
fg.workshop: Software vulnerability
fg.workshop: Software vulnerabilityfg.workshop: Software vulnerability
fg.workshop: Software vulnerability
 
Post-mortem Debugging of Windows Applications
Post-mortem Debugging of  Windows ApplicationsPost-mortem Debugging of  Windows Applications
Post-mortem Debugging of Windows Applications
 
Linux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/OLinux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/O
 
Failure Of DEP And ASLR
Failure Of DEP And ASLRFailure Of DEP And ASLR
Failure Of DEP And ASLR
 
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP ChainsExploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
Exploit Research and Development Megaprimer: DEP Bypassing with ROP Chains
 
High Reliabilty Systems
High Reliabilty SystemsHigh Reliabilty Systems
High Reliabilty Systems
 

Mais de FFRI, Inc.

Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARMAppearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARMFFRI, Inc.
 
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARMAppearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARMFFRI, Inc.
 
TrustZone use case and trend (FFRI Monthly Research Mar 2017)
TrustZone use case and trend (FFRI Monthly Research Mar 2017) TrustZone use case and trend (FFRI Monthly Research Mar 2017)
TrustZone use case and trend (FFRI Monthly Research Mar 2017) FFRI, Inc.
 
Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...
Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...
Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...FFRI, Inc.
 
An Overview of the Android Things Security (FFRI Monthly Research Jan 2017)
An Overview of the Android Things Security (FFRI Monthly Research Jan 2017) An Overview of the Android Things Security (FFRI Monthly Research Jan 2017)
An Overview of the Android Things Security (FFRI Monthly Research Jan 2017) FFRI, Inc.
 
Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016)
Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016) Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016)
Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016) FFRI, Inc.
 
An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)
An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)
An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)FFRI, Inc.
 
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...FFRI, Inc.
 
Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)
Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)
Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)FFRI, Inc.
 
Black Hat USA 2016 Survey Report (FFRI Monthly Research 2016.8)
Black Hat USA 2016  Survey Report (FFRI Monthly Research 2016.8)Black Hat USA 2016  Survey Report (FFRI Monthly Research 2016.8)
Black Hat USA 2016 Survey Report (FFRI Monthly Research 2016.8)FFRI, Inc.
 
About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7)
About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7) About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7)
About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7) FFRI, Inc.
 
Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)
Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)
Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)FFRI, Inc.
 
Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)
Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)
Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)FFRI, Inc.
 
ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...
ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...
ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...FFRI, Inc.
 
CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)
CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)
CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)FFRI, Inc.
 
Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...
Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...
Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...FFRI, Inc.
 
Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)
Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)
Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)FFRI, Inc.
 
A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)
A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)
A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)FFRI, Inc.
 
Security of Windows 10 IoT Core(FFRI Monthly Research 201506)
Security of Windows 10 IoT Core(FFRI Monthly Research 201506)Security of Windows 10 IoT Core(FFRI Monthly Research 201506)
Security of Windows 10 IoT Core(FFRI Monthly Research 201506)FFRI, Inc.
 
Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...
Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...
Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...FFRI, Inc.
 

Mais de FFRI, Inc. (20)

Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARMAppearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
 
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARMAppearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
Appearances are deceiving: Novel offensive techniques in Windows 10/11 on ARM
 
TrustZone use case and trend (FFRI Monthly Research Mar 2017)
TrustZone use case and trend (FFRI Monthly Research Mar 2017) TrustZone use case and trend (FFRI Monthly Research Mar 2017)
TrustZone use case and trend (FFRI Monthly Research Mar 2017)
 
Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...
Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...
Android Things Security Research in Developer Preview 2 (FFRI Monthly Researc...
 
An Overview of the Android Things Security (FFRI Monthly Research Jan 2017)
An Overview of the Android Things Security (FFRI Monthly Research Jan 2017) An Overview of the Android Things Security (FFRI Monthly Research Jan 2017)
An Overview of the Android Things Security (FFRI Monthly Research Jan 2017)
 
Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016)
Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016) Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016)
Black Hat Europe 2016 Survey Report (FFRI Monthly Research Dec 2016)
 
An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)
An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)
An Example of use the Threat Modeling Tool (FFRI Monthly Research Nov 2016)
 
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
STRIDE Variants and Security Requirements-based Threat Analysis (FFRI Monthly...
 
Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)
Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)
Introduction of Threat Analysis Methods(FFRI Monthly Research 2016.9)
 
Black Hat USA 2016 Survey Report (FFRI Monthly Research 2016.8)
Black Hat USA 2016  Survey Report (FFRI Monthly Research 2016.8)Black Hat USA 2016  Survey Report (FFRI Monthly Research 2016.8)
Black Hat USA 2016 Survey Report (FFRI Monthly Research 2016.8)
 
About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7)
About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7) About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7)
About security assessment framework “CHIPSEC” (FFRI Monthly Research 2016.7)
 
Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)
Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)
Black Hat USA 2016 Pre-Survey (FFRI Monthly Research 2016.6)
 
Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)
Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)
Black Hat Asia 2016 Survey Report (FFRI Monthly Research 2016.4)
 
ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...
ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...
ARMv8-M TrustZone: A New Security Feature for Embedded Systems (FFRI Monthly ...
 
CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)
CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)
CODE BLUE 2015 Report (FFRI Monthly Research 2015.11)
 
Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...
Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...
Latest Security Reports of Automobile and Vulnerability Assessment by CVSS v3...
 
Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)
Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)
Black Hat USA 2015 Survey Report (FFRI Monthly Research 201508)
 
A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)
A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)
A Survey of Threats in OS X and iOS(FFRI Monthly Research 201507)
 
Security of Windows 10 IoT Core(FFRI Monthly Research 201506)
Security of Windows 10 IoT Core(FFRI Monthly Research 201506)Security of Windows 10 IoT Core(FFRI Monthly Research 201506)
Security of Windows 10 IoT Core(FFRI Monthly Research 201506)
 
Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...
Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...
Trend of Next-Gen In-Vehicle Network Standard and Current State of Security(F...
 

Último

Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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 TerraformAndrey Devyatkin
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

SEH overwrite and its exploitability

  • 1. SEH overwrite and its exploitability Shuichiro Suzuki Fourteenforty Research Institute Inc. Research Engineer
  • 2. Agenda • Theme and Goal • Review of SEH overwrites • Protection mechanisms for SEH overwrites • Bypassing protection mechanisms. • Demonstration • Conclusion
  • 3. Theme and goal Theme • SEH overwriting is one of the major methods for exploiting Windows software. • We already have several protection mechanisms for SEH overwrites. • Is the protection provided by DEP and SEHOP enough? • How about the protection from SafeSEH and SEHOP? Goal • To reveal which combinations of the known protection mechanisms for SEH overwrites are really effective. • On the way to the goal, I will show you that we can bypass SafeSEH and Software DEP and Hardware DEP and SEHOP, all at the same time, under certain conditions.
  • 4. Target environment • Windows XP SP3 • Windows Vista SP1 • Windows 7 • 32bit processes on x86 • 32bit processes on x64 (WOW64) • Visual Studio 2008 was used to compile all the programs in this presentation.
  • 5. Review of SEH Overwrite
  • 6. About SEH • SEH is “Structured Exception Handling” • Exception handling system provided by Windows int test(void){ __try{ // Exception may occur here } __except( EXCEPTION_EXECUTE_HANDLER ){ // This handles the exception } return 0; }
  • 7. Inside Windows Exception Dispatching 0x0012ff50 0x0012ff7C ExceptionList FS Register NT_TIB 0x0012ff90 0x0401790 0x0408800 Stack EXCEPTION_RECORD typedef struct _EXCEPTION_RECORD{ struct _EXCEPTION_RECORD *_next; PEXCEPTION_ROUTINE _handler; } EXCEPTION_RECORD; SEH chain 0xffffffff 0x070BBCC Thread Information Block _next _handler
  • 8. SEH Overwrite Attack 0x0012ff50 0x0401790 Stack Process Memory Space Module(EXE or DLL) Handler1 Buffer Overflow! 0x0505690
  • 9. Stack after an exception handler is called 0x0401790 Stack 0x909006eb EXCEPTION_DISPOSITION __cdecl _except_handler ( struct _EXCEPTION_RECORD *_ExceptionRecord, void * _EstablisherFrame, struct _CONTEXT *_ContextRecord, void * _DispatcherContext ); ESP _DispatcherContext _ContextRecord _EstablisherFrame _ExceptionRecord Address to return _handler ESP+8 pop eax pop eax retn Attackers Arbitrary Code
  • 11. Protection mechanisms • /GS • SafeSEH • SoftwareDEP • SEHOP • Hardware DEP • ASLR
  • 12. /GS • Stack Guard by Visual Studio compiler • This checks if a buffer overflow occurs before returning from a function. • This is irrelevant to SEH overwrites because an exception can be generated before the check.
  • 14. SafeSEH Handler1 0x00002550 Handler2 0x00049080 Handler3 … … … A module protected by SafeSEH Handler1 Handler2 0x00002550 0x00049080 Header Code “pop,pop,ret” sequence ×
  • 15. Weakness of SafeSEH Module SafeSEH Protected Module Not SafeSEH Protected pop pop ret× pop pop ret pop pop ret pop pop ret Memory Space Data area without executable attribute Data area with executable attribute Data area in a module
  • 16. Modules not protected by SafeSEH From Thunderbird 2.0.0.23 * All modules in Thunderbird 3.0.3 are compiled with /SafeSEH
  • 17. pop pop ret in the wild From thunderbird.exe
  • 18. Additional check by Software DEP Module SafeSEH Protected Module Not SafeSEH Protected pop pop ret× pop pop ret pop pop ret pop pop ret Memory Space Data area without executable attribute Data area with executable attribute Data area in a module Weekness
  • 19. Software DEP 0: kd> dt nt!_KEXECUTE_OPTIONS +0x000 ExecuteDisable : Pos 0, 1 Bit +0x000 ExecuteEnable : Pos 1, 1 Bit +0x000 DisableThunkEmulation : Pos 2, 1 Bit +0x000 Permanent : Pos 3, 1 Bit +0x000 ExecuteDispatchEnable : Pos 4, 1 Bit +0x000 ImageDispatchEnable : Pos 5, 1 Bit +0x000 DisableExceptionChainValidation : Pos 6, 1 Bit +0x000 Spare : Pos 7, 1 Bit KPROCESS structure _KEXECUTE_OPTIONS
  • 20. Software DEP pop pop ret× pop pop ret pop pop ret pop pop ret Memory Space × × Data area in a module× Module SafeSEH Protected Module Not SafeSEH Protected Data area without executable attribute Data area with executable attribute
  • 23. Hardware DEP and ASLR • Hardware DEP prevents code without executable attribute from being executed. • ASLR has several impacts on the SEH overwrites.( Explain later )
  • 25. SafeSEH and Software DEP pop pop ret pop pop ret pop pop ret pop pop ret Memory Space Data area in a module pop pop ret× pop pop ret pop pop ret pop pop ret Memory Space Data area in a module × × × × × × × × Module SafeSEH Protected Module Not SafeSEH Protected Non module area (Data area) Non module area with executable attribute
  • 26. Bypassing SEHOP • It is weak if the address of a buffer overflow and FinalExceptionHandler is known. • Attackers can recreate a proper SEH chain. 0x00405600 0x12ff50 0x0012ff90 0x04224550 0x0701790 0x12ffe4 0x0701790 0xffffffff FinalExceptionHandler 0x12ff50 Overwrite!
  • 27. Bypassing Hardware DEP • Return-into-libc • Return-oriented programming VirutalAlloc Stack Args for VirtualAlloc memcpy Args for memcpy CreateFile Args for CreateFile ... ESP Buffer overflow
  • 28. Bypass /GS, SafeSEH, Software DEP, Hardware DEP, SEHOP • Recreate SEH Chain (bypassing SEHOP) • Overwritten exception handler address must be in a module which is not SafeSEH enabled ( bypassing SafeSEH ) • Create a stack to execute desired code ( bypassing Hardware DEP ) • To execute the code using the stack above, we have to set an exception handler to some stack rewind and return instructions ( bypassing Hardware DEP ) • Trigger an exception
  • 29. Recreating the SEH Chain and Setting the Exception Handler Address 0x0012ff50 0x0401790 Stack Process Memory Space Module(EXE or DLL) No SafeSEH Buffer 0xffffffff FinalExceptionHandler Module(EXE or DLL) Handler1 SEH Chain Exception! 0xffffffff FinalExceptionHandler 0x0505690 0x0012ff4C Attackers Arbitrary Code and Data
  • 30. Good instruction to bypass Hardware DEP 0x0012ff50 Module(EXE or DLL) No SafeSEH Buffer 0x0505690 0xffffffff FinalExceptionHandler Module(EXE or DLL) Handler1 add esp, 0x0C24 retn Exception Information 0x0c24 Attackers Arbitrary Code Stack Process Memory Space
  • 31. Create proper stack for return-into-libc 0x0012ff50 Module(EXE or DLL) No SafeSEH Buffer 0x0505690 0xffffffff FinalExceptionHandler Module(EXE or DLL) Handler1 add esp, 0x0C24 retn Exception Information 0x0c24 Attackers Arbitrary Code Stack Process Memory Space 0x00401110 0x30000000 0x00000800 0x00003000 0x00000040 0x30000000 0x30000000 0x0012F758 0x00000800 Address of VirtualAlloc Address of memcpy Address to be allocated The size to be allocated MEM_COMMIT|MEM_RESERVE PAGE_EXECUTE_READWRITE Address to return after memcpy Dest to copy Src of copy The size to be copied 0x7c8622A4
  • 32. Exception handlers which can be used 0x0012ff50 Module(EXE or DLL) No SafeSEH Buffer 0x0505690 0xffffffff FinalExceptionHandler Module(EXE or DLL) Handler1 add esp, 0x0C24 retn Exception Information 0x0CF8 Attackers Arbitrary Code Stack Process Memory Space 0x00401110 0x30000000 0x00000800 0x00003000 0x00000040 0x30000000 0x30000000 0x0012F758 0x00000800 Address of VirtualAlloc Address of memcpy Address to be allocated The size to be allocated MEM_COMMIT|MEM_RESERVE PAGE_EXECUTE_READWRITE Address to return after memcpy Dest to copy Src of copy The size to be copied 0x7c8622A4 add esp, 0x0024 retn Doesn’t work Too small rewind add esp, 0xFF24 retn May be too big. Depends on the stack size. add esp, 0x0CF8 retn
  • 33. Example of “add esp + retn” From Thunderbird 2.0.0.23
  • 34. Summarize the condition • The address of the stack where buffer overflow occurs is known. • The address of the FinalExceptionHandler in ntdll.dll is known. • A process has a module not protected by /SafeSEH • “add esp + retn” instructions which matches followings can be found in the module. – The amount of “add esp” rewind is larger than the stack made by windows exception dispatcher. – The amount of “add esp” rewind is smaller than the stack size when the exception handler is called. • The address of VirtualAlloc and memcpy is known ( or some alternatives can be used). • Attacker can write 0x00 on the stack by using buffer overflow, which means string functions can’t be used to exploit. ( At least the method I showed here can not be used if this doesn’t match)
  • 35. Demonstration • Demonstration on Windows 7 • I assumed that “add esp,0x0c24 – retn” can be found in a non /SafeSEH protected module. • /GS, Software DEP , Hardware DEP, SEHOP are all enabled. • ASLR is disabled.
  • 36. Importance of ASLR • Makes it difficult to recreate proper SEH chain • Makes it difficult to find “add esp + retn” instructions at a fixed address. • Makes it difficult to set FinalExceptionHandler address in the last element of SEH chain.
  • 37. Conclusion Protections Windows XP SP3 Windows Vista SP1 Windows 7 /GS + SafeSEH Exploitable by using data area as an exception handler Exploitable by using data area as an exception handler Exploitable by using data area as an exception handler /GS + SafeSEH + Software DEP If all modules are SafeSEH protected its difficult to exploit If all modules are SafeSEH protected its difficult to exploit If all modules are SafeSEH protected its difficult to exploit /GS + Software DEP + Hardware DEP Exploitable by Return- into-libc or Return- oriented programming Exploitable by Return-into- libc or Return-oriented programming Exploitable by Return-into- libc or Return-oriented programming /GS + Software DEP + SEHOP - Exploitable by recreating proper SEH chain Exploitable by recreating proper SEH chain /GS + SafeSEH + SEHOP - Exploitable by recreating proper SEH chain and using data area as an exception handler Exploitable by recreating proper SEH chain and using data area as an exception handler /GS + Software DEP + SEHOP + Hardware DEP - Exploitable by recreating proper SEH Chain and using data area and return-oriented programming Exploitable by recreating proper SEH Chain and using data area and return- oriented programming /GS + SEHOP + ASLR - Difficult to exploit Difficult to exploit /GS + Software DEP + SEHOP + Hardware DEP + ASLR - Difficult to exploit Difficult to exploit
  • 38. ASLR + DEP • “Bypassing Browser Memory Protections” ( Alexander Sotirov, Mark Dowd ) shows how to bypass them. • But it was without SEHOP