SlideShare a Scribd company logo
case : kernel
 Peter Hlavaty - @zer0mem
 Senior security researcher at @K33nTeam
 2x kernel to system-calc pwn at pwn2own
 Wushu player 
 Kernel developer
 KEEN team -now
 AV company -before
 Speaker sometimes
 Bloging :
 zer0mem.sk
 k33nteam.org/blog
 github.com/zer0mem
 stack canaries
 NonPagedPoolNx
 SMEP
 (SMAP)
 KASLR, Pools, x64
 CFG
 bugs & types
 SAL annotation
 Boogie & VL
 C++ & compiler
 3rd party software becomes more and more attractive attack
vectors nowdays
 Antivirus software, 3rd party drivers, …
 Security awareness of developers should be obligatory!
 Vulnerability types
 Mitigation mechanisms
 Security features
 Non-secure software is kinda backdoor
 Easy bugs
 Abandoned security features
1. Local buffer on
stack
2. Not sufficient
boundary
checks
3. memcpy
4. Return address
pwned
5. Kernel pwn
Stack
OVERFLOWS
http://en.wikipedia.org/wiki/Stack_buffer_overflow
http://en.wikipedia.org/wiki/Buffer_overflow_protection
1. Psuedo-random
value placed
between local
variables &
return
2. Bad memcpy
results into
rewriting canary
3. Canary check
before using
return address
4. Pwn detected,
bsod instead of
windows pwn
Stack
CANARIES
.. by default ..
protect
 You can not overflow to
return or args without
altering canary
 You should not be able to
guess canary
 Means you can not
attack stack so easy
anymore
 Target local vars
 Target args by inner non-
canary-protected
method
 Canary leak
bypass
1. Code is special case
of data
2. If creating data with
EXEC
3. any data shipped
from user mode to
kernel can be
executed
4. Unless
NonPagedPoolNx
take place at
ExAllocatePool
DATA
vs
CODE
http://www.hiew.ru/
protect
 You can not execute data
anymore (unless
executable – but then
should not be data )
 Stack is not executable,
you have to find another
target
 Find RWE page
 Use ROP
 Alter page tables
 Force creation RWE page
+ leak
bypass
https://msdn.microsoft.com/en-us/library/windows/hardware/hh920391(v=vs.85).aspx
1. User mode
2. Kernel mode
3. Interaction via
syscalls
4. Needed to read
passed input
5. No need to
execute user
mode code with
kernel mode
privileges
cpl3
vs
cpl0
http://blogs.msdn.com/blogfiles/willy-peter_schaub/
windowslivewriter/unisachatteroperatingsystemconceptspart2_875b/system%20call.jpg
1. X86_CR4_SMEP
2. Execute user
mode code with
kernel mode
privileges results
in BSOD
3. Previously
heavily used as
exploitation
shortcut
SMEP
1. X86_CR4_SMAP
2. In syscall user
pass arguments
as well
3. Those arguments
have to be
readed
4. No unified
method for read
/ write those
inputs is
problem for
enabling SMAP
SMAP
protect
 Exec on cpl3 data in
supervisor mode will
BSOD
 Direct access on cpl3 data
in supervisor mode will
BSOD as well
 In exploitation you have to
use only kernel mode data
 That means you should to
have some sort of info leak
 SMAP not enabled on
windows yet
 ROP or alternatives
 Disable features (cr4)
 Use pool overflows
 Information leaks &
controlled data in kernel
 Or do not step to kernel,
just use RW capabilities
bypass
https://software.intel.com/en-us/isa-extensions
 Randomization
of module
addresses
 Randomization
of pool
addresses
 When you do
not know where
your target is
then is hard to
attack
KASLR
protect
 You should not be able to
predict where kernel
modules resides
 You should not be able
hardcode ROP chain
anymore
 You should not be able to
predict base of pools
 Info leak
 Timing attack
 Target pool overflows
 Target stack corruption
bypass
1. different pools in
kernel address
space
2. Pools are
containters for
different objects
3. X64 virtual
address space >
physical space
4. Can not touch
unused virtual
space, BSOD
otherwise
PooLseparation
&
x64 addrspace
http://www.alex-ionescu.com/?p=246
1. Randomized allocs
2. Big pools not
3. A lot of times direct
control for alloc &
free, from user
mode
4. Epic when data :
1 : 1
user : kernel
Alloc& Free
vs
pool managment
protect
 Separation of different
object – you can not touch
object from different pool
with pool overflow
 x64 address space
introduce a lot of gaps
(PAGE_NOACCESS), and
environment for better
usage of KASLR
 Pool spray far less effective
than before
 Leak base of pool &
Pool spray
 Timing attacks &
pool spray
 _LIST_ENTRY (related
bugs)
 Pool overflow
 Object, on the pool,
address leak
 Pool layout
bypass
Freed object A
But someone is still hold
reference to object A
Meanwhile changed state –
another object (/ data) take
freed objects A place
Object A used
afterwards
Many objects contains
*PLAIN* pointers – especially
*function pointers*
UAF & vtable
ROP overview
1. Attacker thinks at
assembly level
2. Reuse of existing
code
3. Need to setup right
context
4. stack & registers &
memory
5. Many code reused
6. Need to find good
pieces of code
1. Used for bypassing non-exec
stack
2. Widely used nowdays
http://seclists.org/bugtraq/1997/Aug/63
CFG overview
>> Implementation
1. Indirect calls check
2. in kernel mode not
so widely used yet,
hopefully will be …
soon …
3. bitmap &
registered
functions
ROP
vs
CFG
http://www.powerofcommunity.net/
poc2014/mj0011.pdf
http://blog.trendmicro.com/trendlabs-
security-intelligence/exploring-control-
flow-guard-in-windows-10/
protect
 Protect indirect calls
against (mainly) direct
ROP technique
 You have to use valid
function, in f.e. UAF bug
 regular functions driven
attack
 Stack pivoting
 Stack hooking
bypass
auto
 Pools
 SMEP
 KASLR
 Stack canaries
 NonPagedPoolNx
 SMAP (point of view)
 CFG
Code &/ Compiler
Even when mitigation in place, treat every bug as exploitable! Every
mitigation has its own weak point! Maybe we do not know how to
exploit it now, but someone else might …
 We are humans and making mistakes
 Many bugs in code, especially in large codebase
 OS introduce many defensive mechanism for
effectively mitigating techniques for exploiting bugs
 But every mitigation has its own limitation
 Biggest limitation is bug & developer itself
 Every developer should be aware of software security
problems :
 mitigation techniques, vulnerability classes, auditing
tools, security features
RACE
conditions
1. Shared resource
2. Multiple thread access
at same time
3. out-of-lock access
4. Convertable to another
vulnerability class!
5. Easy to make this bug
6. Hard to avoid
www.slideshare.net/PeterHlavaty/
racing-withdroids
Outof Boundary
1. Insufficient
boundary checks,
or not present at
all
2. Integer
over/under flows
in boundary
check
3. Arbitrary read /
write for
attacker
www.slideshare.net/PeterHlavaty/
attack-on-the-core
TOCTOU
1. In syscall is
provided pointer
to user mode
memory
2. This memory is
first checked and
pass by kernel
3. Another user /
kernel thread
change memory at
that pointer
4. Kernel accessing
changed memory
http:// j00ru.vexillium.org/?p=1695
http://gynvael.coldwind.pl/?id=503
Bufferoverflows
1. One of the most
common
vulnerability
class
2. One of the most
powerful
3. Can break
{ SMEP & SMAP
& KASLR } by
nature – ofc not
every overflow
http://confidence.org.pl/en/agenda/lecture/
when-something-overflowing/
1. Specify
arguments, ret
2. Boost static
checks!
3. Avoid *ANY*
warning!
4. Can detect a lot!
{
overflows,
out-of-bounds,
nulls, ..
}
Use SAL
https://msdn.microsoft.com/en-us/library/ms182032.aspx
https://technet.microsoft.com/zh-cn/subscriptions/
ms235402(v=vs.100).aspx
1. Verification language
2. C# (C)
3. Way to go!
4. Use boogie or Develop
your own VL ?
5. C++ ?
BOOGIE
http://research.microsoft.com/en-us/projects/boogie/
 Compiler can be your best friend
 Language is continuously evolving
 C++11
 common libraries: boost & stl
 Even windows kernel itself is moving (+-) towards c++
 Effective & clean architecture, design
 Hard to master it
 Maintaining large code base ++
 Make use of design patterns
 Rethink every time, but it does not mean to use them every
time as well…
 C++ :
 http://www.bogotobogo.com/cplusplus/multithreaded4_cplusplus11.php
 http://simhttp://www.bogotobogo.com/cplusplus/multithreaded4_cplusplus11.phpp
leprogrammer.com/2012/12/01/why-c-is-not-back/ (another point of view, good to
read)
 design patterns :
 https://sourcemaking.com/design_patterns
 programmers :
 http://danluu.com/new-cpu-features/
 http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html?m=1
 http://www.akkadia.org/drepper/cpumemory.pdf
 http://stackoverflow.com/questions/2794016/what-should-every-programmer-
know-about-security
 http://neilscomputerblog.blogspot.gr/2014/06/destroying-rop-gadgets-with-inline-
code.html?spref=tw
 Boogie :
 http://www.rosemarymonahan.com/specsharp/papers/SBMF2010.pdf
 http://www.zvonimir.info/2010/12/a-tutorial-for-running-boogie-and-z3-on-linux/
 http://www4.in.tum.de/~boehmes/hol-boogie-tphols-talk.pdf
 http://webcourse.cs.technion.ac.il/236800/Winter2010-2011/ho/WCFiles/Boogie.pdf
 In company reviews
 First make design & measure, then optimize
 Do multiple reviews of design & production code
 In company audits & fuzzing
 Unit testing
 White-box fuzzing
 Audit companies & consulting
 Let security guys to pinpoint problems which you may
likely to overlook
 Bug bounties
 Let more people boost security of your product
 We are hiring!
 Kernel & app sec
 A LOT of research
 mobile, pc
 M$, android, OSX ..
@K33nTeam
SPEICAL THANKS TO SKETCHES I was able to made 
http://pencil.evolus.vn/

More Related Content

What's hot

When is something overflowing
When is something overflowingWhen is something overflowing
When is something overflowing
Peter Hlavaty
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon china
Peter Hlavaty
 
Rainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could ExpectRainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could Expect
Peter Hlavaty
 
Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!
Peter Hlavaty
 
How to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One ExploitHow to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One Exploit
Jiahong Fang
 
How Safe is your Link ?
How Safe is your Link ?How Safe is your Link ?
How Safe is your Link ?
Peter Hlavaty
 
Memory Corruption: from sandbox to SMM
Memory Corruption: from sandbox to SMMMemory Corruption: from sandbox to SMM
Memory Corruption: from sandbox to SMM
Positive Hack Days
 
Hacking - high school intro
Hacking - high school introHacking - high school intro
Hacking - high school intro
Peter Hlavaty
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
zeroSteiner
 
Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Python
infodox
 
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
 
Packers
PackersPackers
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
Tamas K Lengyel
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NoSuchCon
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware Analysis
Tamas K Lengyel
 
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
CODE BLUE
 
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
Tamas K Lengyel
 
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Shota Shinogi
 
Modern Evasion Techniques
Modern Evasion TechniquesModern Evasion Techniques
Modern Evasion Techniques
Jason Lang
 
Fun With Dr Brown
Fun With Dr BrownFun With Dr Brown
Fun With Dr Brown
zeroSteiner
 

What's hot (20)

When is something overflowing
When is something overflowingWhen is something overflowing
When is something overflowing
 
Security research over Windows #defcon china
Security research over Windows #defcon chinaSecurity research over Windows #defcon china
Security research over Windows #defcon china
 
Rainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could ExpectRainbow Over the Windows: More Colors Than You Could Expect
Rainbow Over the Windows: More Colors Than You Could Expect
 
Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!Ice Age melting down: Intel features considered usefull!
Ice Age melting down: Intel features considered usefull!
 
How to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One ExploitHow to Root 10 Million Phones with One Exploit
How to Root 10 Million Phones with One Exploit
 
How Safe is your Link ?
How Safe is your Link ?How Safe is your Link ?
How Safe is your Link ?
 
Memory Corruption: from sandbox to SMM
Memory Corruption: from sandbox to SMMMemory Corruption: from sandbox to SMM
Memory Corruption: from sandbox to SMM
 
Hacking - high school intro
Hacking - high school introHacking - high school intro
Hacking - high school intro
 
Practical Windows Kernel Exploitation
Practical Windows Kernel ExploitationPractical Windows Kernel Exploitation
Practical Windows Kernel Exploitation
 
Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Python
 
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
 
Packers
PackersPackers
Packers
 
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
 
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the CoreNSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
NSC #2 - D3 02 - Peter Hlavaty - Attack on the Core
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware Analysis
 
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
For the Greater Good: Leveraging VMware's RPC Interface for fun and profit by...
 
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
 
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
Introduction of ShinoBOT (Black Hat USA 2013 Arsenal)
 
Modern Evasion Techniques
Modern Evasion TechniquesModern Evasion Techniques
Modern Evasion Techniques
 
Fun With Dr Brown
Fun With Dr BrownFun With Dr Brown
Fun With Dr Brown
 

Similar to Guardians of your CODE

Linux kernel-rootkit-dev - Wonokaerun
Linux kernel-rootkit-dev - WonokaerunLinux kernel-rootkit-dev - Wonokaerun
Linux kernel-rootkit-dev - Wonokaerunidsecconf
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio Cesare
 
Secure container: Kata container and gVisor
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisor
Ching-Hsuan Yen
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopTalk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
Quey-Liang Kao
 
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
Tamas K Lengyel
 
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
Tamas K Lengyel
 
1Buttercup On Network-based Detection of Polymorphic B.docx
 1Buttercup On Network-based Detection of Polymorphic B.docx 1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
aryan532920
 
Android memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfAndroid memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdf
VishalKumarJha10
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Scott K. Larson
 
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
DataStax
 
Sql Injections With Real Life Scenarious
Sql Injections With Real Life ScenariousSql Injections With Real Life Scenarious
Sql Injections With Real Life Scenarious
Francis Alexander
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
Alexandre Rafalovitch
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Lucidworks
 
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
 
Tracer Evaluation
Tracer EvaluationTracer Evaluation
Tracer Evaluation
Qiao Han
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
Aaron Hnatiw
 
Report on hacking blind
Report on hacking blindReport on hacking blind
Report on hacking blind
NikitaAndhale
 
Jvm architecture
Jvm architectureJvm architecture
Jvm architecture
Chirag Pal
 
Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?
Javier Tallón
 

Similar to Guardians of your CODE (20)

Linux kernel-rootkit-dev - Wonokaerun
Linux kernel-rootkit-dev - WonokaerunLinux kernel-rootkit-dev - Wonokaerun
Linux kernel-rootkit-dev - Wonokaerun
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
Secure container: Kata container and gVisor
Secure container: Kata container and gVisorSecure container: Kata container and gVisor
Secure container: Kata container and gVisor
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopTalk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
 
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
 
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
 
1Buttercup On Network-based Detection of Polymorphic B.docx
 1Buttercup On Network-based Detection of Polymorphic B.docx 1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
 
Android memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfAndroid memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdf
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
 
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
A Detailed Look At cassandra.yaml (Edward Capriolo, The Last Pickle) | Cassan...
 
Sql Injections With Real Life Scenarious
Sql Injections With Real Life ScenariousSql Injections With Real Life Scenarious
Sql Injections With Real Life Scenarious
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
 
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)
 
Tracer Evaluation
Tracer EvaluationTracer Evaluation
Tracer Evaluation
 
Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016Racing The Web - Hackfest 2016
Racing The Web - Hackfest 2016
 
Report on hacking blind
Report on hacking blindReport on hacking blind
Report on hacking blind
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Jvm architecture
Jvm architectureJvm architecture
Jvm architecture
 
Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?Mitigating overflows using defense in-depth. What can your compiler do for you?
Mitigating overflows using defense in-depth. What can your compiler do for you?
 

Recently uploaded

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 

Recently uploaded (20)

OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 

Guardians of your CODE

  • 2.  Peter Hlavaty - @zer0mem  Senior security researcher at @K33nTeam  2x kernel to system-calc pwn at pwn2own  Wushu player   Kernel developer  KEEN team -now  AV company -before  Speaker sometimes  Bloging :  zer0mem.sk  k33nteam.org/blog  github.com/zer0mem
  • 3.  stack canaries  NonPagedPoolNx  SMEP  (SMAP)  KASLR, Pools, x64  CFG  bugs & types  SAL annotation  Boogie & VL  C++ & compiler
  • 4.  3rd party software becomes more and more attractive attack vectors nowdays  Antivirus software, 3rd party drivers, …  Security awareness of developers should be obligatory!  Vulnerability types  Mitigation mechanisms  Security features  Non-secure software is kinda backdoor  Easy bugs  Abandoned security features
  • 5.
  • 6. 1. Local buffer on stack 2. Not sufficient boundary checks 3. memcpy 4. Return address pwned 5. Kernel pwn Stack OVERFLOWS http://en.wikipedia.org/wiki/Stack_buffer_overflow http://en.wikipedia.org/wiki/Buffer_overflow_protection
  • 7. 1. Psuedo-random value placed between local variables & return 2. Bad memcpy results into rewriting canary 3. Canary check before using return address 4. Pwn detected, bsod instead of windows pwn Stack CANARIES .. by default ..
  • 8. protect  You can not overflow to return or args without altering canary  You should not be able to guess canary  Means you can not attack stack so easy anymore  Target local vars  Target args by inner non- canary-protected method  Canary leak bypass
  • 9. 1. Code is special case of data 2. If creating data with EXEC 3. any data shipped from user mode to kernel can be executed 4. Unless NonPagedPoolNx take place at ExAllocatePool DATA vs CODE http://www.hiew.ru/
  • 10. protect  You can not execute data anymore (unless executable – but then should not be data )  Stack is not executable, you have to find another target  Find RWE page  Use ROP  Alter page tables  Force creation RWE page + leak bypass https://msdn.microsoft.com/en-us/library/windows/hardware/hh920391(v=vs.85).aspx
  • 11. 1. User mode 2. Kernel mode 3. Interaction via syscalls 4. Needed to read passed input 5. No need to execute user mode code with kernel mode privileges cpl3 vs cpl0 http://blogs.msdn.com/blogfiles/willy-peter_schaub/ windowslivewriter/unisachatteroperatingsystemconceptspart2_875b/system%20call.jpg
  • 12. 1. X86_CR4_SMEP 2. Execute user mode code with kernel mode privileges results in BSOD 3. Previously heavily used as exploitation shortcut SMEP
  • 13. 1. X86_CR4_SMAP 2. In syscall user pass arguments as well 3. Those arguments have to be readed 4. No unified method for read / write those inputs is problem for enabling SMAP SMAP
  • 14. protect  Exec on cpl3 data in supervisor mode will BSOD  Direct access on cpl3 data in supervisor mode will BSOD as well  In exploitation you have to use only kernel mode data  That means you should to have some sort of info leak  SMAP not enabled on windows yet  ROP or alternatives  Disable features (cr4)  Use pool overflows  Information leaks & controlled data in kernel  Or do not step to kernel, just use RW capabilities bypass https://software.intel.com/en-us/isa-extensions
  • 15.  Randomization of module addresses  Randomization of pool addresses  When you do not know where your target is then is hard to attack KASLR
  • 16. protect  You should not be able to predict where kernel modules resides  You should not be able hardcode ROP chain anymore  You should not be able to predict base of pools  Info leak  Timing attack  Target pool overflows  Target stack corruption bypass
  • 17. 1. different pools in kernel address space 2. Pools are containters for different objects 3. X64 virtual address space > physical space 4. Can not touch unused virtual space, BSOD otherwise PooLseparation & x64 addrspace http://www.alex-ionescu.com/?p=246
  • 18. 1. Randomized allocs 2. Big pools not 3. A lot of times direct control for alloc & free, from user mode 4. Epic when data : 1 : 1 user : kernel Alloc& Free vs pool managment
  • 19. protect  Separation of different object – you can not touch object from different pool with pool overflow  x64 address space introduce a lot of gaps (PAGE_NOACCESS), and environment for better usage of KASLR  Pool spray far less effective than before  Leak base of pool & Pool spray  Timing attacks & pool spray  _LIST_ENTRY (related bugs)  Pool overflow  Object, on the pool, address leak  Pool layout bypass
  • 20. Freed object A But someone is still hold reference to object A Meanwhile changed state – another object (/ data) take freed objects A place Object A used afterwards Many objects contains *PLAIN* pointers – especially *function pointers* UAF & vtable
  • 21. ROP overview 1. Attacker thinks at assembly level 2. Reuse of existing code 3. Need to setup right context 4. stack & registers & memory 5. Many code reused 6. Need to find good pieces of code
  • 22. 1. Used for bypassing non-exec stack 2. Widely used nowdays http://seclists.org/bugtraq/1997/Aug/63
  • 24. >> Implementation 1. Indirect calls check 2. in kernel mode not so widely used yet, hopefully will be … soon … 3. bitmap & registered functions ROP vs CFG http://www.powerofcommunity.net/ poc2014/mj0011.pdf http://blog.trendmicro.com/trendlabs- security-intelligence/exploring-control- flow-guard-in-windows-10/
  • 25. protect  Protect indirect calls against (mainly) direct ROP technique  You have to use valid function, in f.e. UAF bug  regular functions driven attack  Stack pivoting  Stack hooking bypass
  • 26.
  • 27. auto  Pools  SMEP  KASLR  Stack canaries  NonPagedPoolNx  SMAP (point of view)  CFG Code &/ Compiler Even when mitigation in place, treat every bug as exploitable! Every mitigation has its own weak point! Maybe we do not know how to exploit it now, but someone else might …
  • 28.  We are humans and making mistakes  Many bugs in code, especially in large codebase  OS introduce many defensive mechanism for effectively mitigating techniques for exploiting bugs  But every mitigation has its own limitation  Biggest limitation is bug & developer itself  Every developer should be aware of software security problems :  mitigation techniques, vulnerability classes, auditing tools, security features
  • 29.
  • 30. RACE conditions 1. Shared resource 2. Multiple thread access at same time 3. out-of-lock access 4. Convertable to another vulnerability class! 5. Easy to make this bug 6. Hard to avoid www.slideshare.net/PeterHlavaty/ racing-withdroids
  • 31. Outof Boundary 1. Insufficient boundary checks, or not present at all 2. Integer over/under flows in boundary check 3. Arbitrary read / write for attacker www.slideshare.net/PeterHlavaty/ attack-on-the-core
  • 32. TOCTOU 1. In syscall is provided pointer to user mode memory 2. This memory is first checked and pass by kernel 3. Another user / kernel thread change memory at that pointer 4. Kernel accessing changed memory http:// j00ru.vexillium.org/?p=1695 http://gynvael.coldwind.pl/?id=503
  • 33. Bufferoverflows 1. One of the most common vulnerability class 2. One of the most powerful 3. Can break { SMEP & SMAP & KASLR } by nature – ofc not every overflow http://confidence.org.pl/en/agenda/lecture/ when-something-overflowing/
  • 34.
  • 35. 1. Specify arguments, ret 2. Boost static checks! 3. Avoid *ANY* warning! 4. Can detect a lot! { overflows, out-of-bounds, nulls, .. } Use SAL https://msdn.microsoft.com/en-us/library/ms182032.aspx https://technet.microsoft.com/zh-cn/subscriptions/ ms235402(v=vs.100).aspx
  • 36. 1. Verification language 2. C# (C) 3. Way to go! 4. Use boogie or Develop your own VL ? 5. C++ ? BOOGIE http://research.microsoft.com/en-us/projects/boogie/
  • 37.  Compiler can be your best friend  Language is continuously evolving  C++11  common libraries: boost & stl  Even windows kernel itself is moving (+-) towards c++  Effective & clean architecture, design  Hard to master it  Maintaining large code base ++  Make use of design patterns  Rethink every time, but it does not mean to use them every time as well…
  • 38.  C++ :  http://www.bogotobogo.com/cplusplus/multithreaded4_cplusplus11.php  http://simhttp://www.bogotobogo.com/cplusplus/multithreaded4_cplusplus11.phpp leprogrammer.com/2012/12/01/why-c-is-not-back/ (another point of view, good to read)  design patterns :  https://sourcemaking.com/design_patterns  programmers :  http://danluu.com/new-cpu-features/  http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html?m=1  http://www.akkadia.org/drepper/cpumemory.pdf  http://stackoverflow.com/questions/2794016/what-should-every-programmer- know-about-security  http://neilscomputerblog.blogspot.gr/2014/06/destroying-rop-gadgets-with-inline- code.html?spref=tw  Boogie :  http://www.rosemarymonahan.com/specsharp/papers/SBMF2010.pdf  http://www.zvonimir.info/2010/12/a-tutorial-for-running-boogie-and-z3-on-linux/  http://www4.in.tum.de/~boehmes/hol-boogie-tphols-talk.pdf  http://webcourse.cs.technion.ac.il/236800/Winter2010-2011/ho/WCFiles/Boogie.pdf
  • 39.  In company reviews  First make design & measure, then optimize  Do multiple reviews of design & production code  In company audits & fuzzing  Unit testing  White-box fuzzing  Audit companies & consulting  Let security guys to pinpoint problems which you may likely to overlook  Bug bounties  Let more people boost security of your product
  • 40.  We are hiring!  Kernel & app sec  A LOT of research  mobile, pc  M$, android, OSX .. @K33nTeam
  • 41. SPEICAL THANKS TO SKETCHES I was able to made  http://pencil.evolus.vn/