thank you very much thank you being here
and and also appreciates the organizer
to give me the opportunity to talk my
research so today my talk is arrow so
basically I will go through bunch of
code reuse techniques so we assume
people understand what's Olaf
I just quickly keeps the basic stuff and
introduce the other one research part so
my name is Zhang Li and from India so
I'm the security research and architect
in inter lab so we deliver a lots of
product includes the deep safe some
couples if you feature like I am Frank
Hari and also our victim delivers sjx so
I focus on unwinding and detecting
Prevention's or zero day so advanced
persistent attack this kind of stuff
with latest new simple feature so I did
some research for pet care couple years
ago talk how to assess the pet card with
the pet care decoder so we have the
white paper published at that time and
also I present at couple conference
before so now we talk about the return
oriented programming so I assume lots of
people already know that because this is
pretty popular content for research for
many years right
so I will go through the basic stuff
then we talk about the brown transfer
instruction after I will talk little bit
couple different Rob defense mechanism
and how to bypass that is different
gadget though and I also will talk about
little bit for some valid gadget and
also some powerful gadget from the wall
succe for by give luck
so Rob is the popular topic for many
years so I just leased couple reference
here so if you want to understand more
basically stuff you can read the content
here so that's couple couple talks from
different research that are very
excellent target so here I want to
introduce some information here about
the new rockin straw in apt so Robbie is
very popular right so we saw lots of
loss of drop paste extra but I want to
mention this one because this one is
special because in two years ago
actually
so yeah was one PDF zero day actually
include two vulnerability within
visiting one single file so this one is
the zero day was detect by Phi they
report by Phi so this one is very
special
interesting because the only use robbed
a jet with thought share code so that's
something we didn't see before because
really we talked about locked areas we
see how to use the Rob gadget to initial
the deliver next stage attack for
example enables or shareholders
collapsing right but this attack is very
frustrated the use pure rubber gadget to
replace the circle they don't need share
code then eventually just the wrongs or
maybe are you actually so here is the
example for rob cadet tell thirteen part
so again see the lab site is the first
vulnerability used by this zero day
review triggers or Rob danger to the
tech curtain like here
once the indirect off happen the coin to
here we push the reacts and pops the ESP
that's exactly the way to do the
staggering so they have another
explore to targeting sandbox pepper zero
day so we use another carrier here to
call ye acts and do very similar thing
push EDX and pop
yes P so this is a way people use your
job carrier to do the stack 30
of course this attack and lots of lots
of gadget if you want to understand more
you can search online lots of people
publish the eat here so today the topic
we want to discuss is is the rock gadget
is the way to only way to do that of
course not because you can see people do
a lot of research the retail aren't here
programming just a one-off survey to
deliver real skull right you can do the
return based you can do the trunk paste
and also you can do car based right so
basically that's a concept for drop and
the car
I also leads to the reference here that
two papers discuss this kind of attack
so let's think about the return call and
the charm the all the approach to real
scope right but if we think about the
vehicles from the branch transfer
perspective so we can found actually we
have lots of different combination or
different approach to do the branch
transfer to the rock real skull based on
transfer for example here we know we
have the written I actually we have near
returned we have written for Trump
that's very similar we have the
Keynesian job then we have the new job
Quadra of course we have the direct job
and English charm so your leave the
vulnerability happen with the into our
jump and also we have the call we have
the new car in the foie gras ingre
called drag car so the India calculate
is the problem for
some vulnerability sometimes of vanity
happened due to the kind of instruction
and we are that we also have to
interrupt written this is very different
one we will talk about later so we can
use the index written to some very cool
stuff so return is very straightforward
we can see here so basically we have
near return on the fire written the new
written talk used like many times in the
rock area we can do the second the
inside written right so the far we the
concept happen when you talk about
different mode you want to switch the
segment so I will discuss later we have
lots of slides covers or with me 10 or
gadget in wall 64 the windows windows a
certain to our window fixed wall paint
mode that's the compile phase amount to
run the service will feed application on
6 4 6 4 feet windows so for charm we
have the keynesian jar we have lots of
conditional job right so basically this
one can be used to construct some
languages so that's me you can have some
carriers linked by conditioned jump so
if you inspect the carriage from the
starting point that will be very long
gadget so we also have the near jump and
Foggia the fraud ramp also can be used
to speech the segment we of course we
have call into our car as a new kind of
park off the park also can be used to
switch the segment so iraq so this is
the interesting one because you know
surely areas will be used by kernel
space after you handles or the
userspace call then you can use area 310
for Cisco and of course when the
interrupt had been or some exception
happens the routine in color space also
need returned to your space with Iraq so
the area view automatically switch the
yes the code segment because you have to
return to these three those code
segments will include the privilege so
you have to recover to the user space
prove it so once the interrupter happens
for example if in drop happen when the
infra happens us if you will push a
bunch of seeing our stack for example
current SS ESP you flex yes VIP and
error code so for certain pit and
certain to emulation beat so only the
privilege changes we will push all kinds
of information otherwise we just push
the flag and the CSEA IP and the error
code but on c4p the Auggie's push SS
ESPE blacks yes the IP and the error
code if they have so now we talk about
the rock defense and that past part so
you know we have lots of defense already
means there and also some coming so for
example a couple years ago people did
some research for keeping sir platinum
chip answer to detect the raw and also a
couple of people used p.m. you use the
miss products these kind of seem to
identify the drop drop attack and of
course you know the latest windows
already includes the CFG the control
flow car that's in the Microsoft
released already and also some research
published some risk topic for hardware
assistance
CFI so control flow integrity and also
some shadow stack this kind of thing so
let's talk about couple different
defense pattern that we can discuss the
bypass so first thing we want to discuss
is the keep answer so you know capacitor
is the winner of the first blue hat
prize couple years ago so it's also the
first one to publicly use air we are the
last pronged record so that's the bunch
of information in intercept you can help
you get the latest branch record
information based on exactly we can
check the ROC ROC policy this kind of
scene and also this one mentions the
policy of parts the copper seat of
gadget so that means if you do return to
a virtual place the whip law is limited
tax data has the attack because think
about it early once the car happen call
instruction will push the return address
on the on the stack the address will be
the contacts in instruction
so once the return happens issues land
into the neck copper seed instruction
right so that's very basic policy and
also key bouncer use the run sequence of
the short schedule so that's very
interesting the assumes orc area the rob
dagger should be shot
that last very basic idea so here I list
the graph from their paper so the idea
basically is every time when you call
into the critical API for example what
report have so the view to the area
check and to bunch of policy check right
so that's the V key bouncer to the or
drop T pass
so because keep answer really rely on
through three paths
so first is area second is look call
procedure policy the run is a shortcut
yeah so let's talk about fer Presley so
OPR is some MSR in inter CPU so
basically you can enable area V the
debug control Mesa then use the ms.fer
silly act and that's not to select what
kind of reactor you want for example you
only want to monitor rinse three so
probably you want to disable in zero
path so this video you can set as one if
you don't want to record the GCC the
keynesian job the temples or GCC b2 as
as well so basically that's up to user
to configure via then eventually the AVR
regice
in MSR will keep the all data you want
of course we have some limitation
because we cannot keep lots of resource
for we are so based on architecture we
keep up to maybe today up to 32 or 16
MSR so here is the MSR you can use to
read the area theater so basically from
where dress is ones of branch happen
what's your address
and what sort to address and the tops is
because the city will keep changing the
area so the tops are as the index so you
will know these tops you know what's the
latest we are record and you can
spec to get couple different locks so
the basically idea to baptistry bouncer
here is the OPR history flash so this
one is exactly idea from inkless so in
crates from UC Berkeley published the
paper about this kind of research so he
used couple different v2 paths or have
we are with with the pistol flash so
here he leased couple different KJ for
example if he used a bunch of Trump and
the retail this kind of scene so they
could to flash the LG RVs the logic
after you did real stuff so that means
you give some critical part then you use
lots of gadget to flash the help er
because we only keep limited numbers so
then you just flash so they cannot guess
the record some record really hit
through the critical part so and also he
published couple different the another
way is the switch the context-based so
here is for example here like big low
like Zack so no because our BR is
crossed some resource cross all process
so that means if you do some looking or
something like that then other process
could be scheduled at that time we also
view mix air BIA record as latest one so
that means all records will belong to
another process so that's also one way
to do the air via flash and also he
mentioned a couple different ways so I
suggest people can read his paper later
to understand more approach so we
discuss couple different way to do the
area flash so we will focus on this kind
of new approach so first thing is here
if we are given the starting area
setting you enable
a car based approach so then we have
these kinds of valid gadget in existing
software to cause the cop so for example
if some vanellope happen when they
happen and you can control the yi acts
as a special number here the address
here so you return to this instruction
so this one will call the SP + 3 C so
look at this tak if the three see point
to the default then the code will come
to default so the info code has the
immediately in black branch e^x because
the yaks controlled by attacker so this
one applying to the 2 F 2 for example
here so they come back right so you can
do lots of loop for this one of course
you know this cop based approach the
stack will push push push
right so eventually you can control the
ESP plus 3 C point to the what repair
tag for example I'm going to water
further so this approach you see if the
cop cashed by area you can flush area
right if not caught by area you just go
into the area visas or paste or
rocket base data so and also you can
flash our BR plus probably with Iraq so
the Iraq is something different right
because area at worked for interest
based routine you early so the interrupt
could happen at any time so you don't
have to write return you can clearly
Stasi
return shoot listen to call procedure
instruction right but for area that
could be the interrupts could happen at
any place you cannot control right so
you can do this kind of scene if air BR
records the area then you can do lots of
areas based
flash so Africa if didn't you can
directly use the Arab gadget so the
rebounds
will not catch that if you didn't enable
so that's some new part so because today
people talk a lot for Rob and maybe drop
and but I didn't see people use the
area based data yeah so this one will be
very powerful in filter and also like we
mentioned previously we can use the call
procedure CAD yet to the area flash
right so for example very similar code
here we have the ax a air equals zero if
so someone will be happen greeting are
somehow caused the address to to f2 at
that time we keeps the stack as left
side likely so we do the in black coffee
exp plus 3 C so this one point to the
Nandi for example this one point to zone
98 a - so the 98 to view changes our
stack because during this push push and
the call you have three value on staff
so this one jobs the yes key so adjust
the SP and lam going through the stack
you can control now after that you do
return the return can return to course
and that means the call next instruction
right so like this then the SP can
continue + 2 + 8 and recheck the year
so if air equals zero we can continue so
with this kind of approach you just
flush the area with valid gadget right
the return only happen call proceed
instruction so you can easily bypass the
policy right so that means today people
still can use koppers it gadget to
deliver enough attack so actually the
nicholas Nicholas forms of UC Berkeley
and look us from the Germany are also
published
two different papers talked about this
kind of issue though the valid gadget is
enough to deliver the attack so beyond
the ERP so approach people also use the
branch based approach branch mister he
approach so cross where people publish
the in the mix written miss Paroo
approach on Sandy Bridge a couple years
ago on 15th 2013 I think so and I also
did some research for in Oaxaca in your
trunk faced miss per day so basically
the idea is if CPU keep the EMU running
so one thirds or performs premier is a
performance monitoring event you need so
in case people don't that so you can set
the config the EMU to catch the mystery
event so for we tend miss miss purty
based event that discussed by crossed
right people a couple years ago so you
know the return just return if you use
Iraq probably it cannot detect that
because you have to config so a p.m. you
and the p.m. you have to support this
kind of see and a very different scene
for areas in tribe had net arbitrary
place how do you know this one is in a
mystery or not right
probably with the arid area faced gadget
you can't have house right and also you
can couple or you have a couple
different approach to bypass miss per
day for example you do the in your car
you'd rather carry out under v10 that's
all follow the rule you just return to
expect either place those are returned
miss pertree never happen right so if
you do this kind of move you also can
finish the raw
culture yours of course that's really
depends on the on the rate here and the
how many calories you need if while to
us we gadget enough probably we can
figure this kind of can yet Valley
approach to team go to attack and also
you can use drop because Museum expire
you just focus on return you can get
struck to deliver sort of drop gaya so
and also we can use the cop drop drop
combined gadget to deliver attack for
example here the into a car into a car
control gadget and the return to the
interact romp and the change to another
gadget so and also you can do the into a
condo unit ramp and get for example here
for example here so you can use the
valid gadget here if you're coming to
this instruction the if the EDX is
controlled its acts control your ex know
and you react control then we can jump
to EDX if so u DX for example jump to
here then you can just that you actually
copies or provide from the ex2 the
argument are given one right so you can
do this kind of scene they will never
trigger the reason miss party because
that's all follow through if car and
push the return address on stack and if
return landing to the expected or
address so and also for in we are
calling in to our charm face to mean
spreading you can use couple different
way to avoid the miss per day sometimes
that's really it depends on the risk
condition so for control flow graph
because we have lived at the time so I
will not he's got too much so basically
the control flow car is approached from
Microsoft every time you do the into a
car if you check into a car to make sure
the into a call I need to the right
address lungfuls of function otherwise
if you block so couple people publish
the research here and also this year one
black hat we topic about control flow
graph so I
you can result reference and the also
for happy are based control flow
integration the approach is today we can
do absolute return right a car and the
job right so eventually it's possible
CPU provides the capability see Hardware
provides or kabillion see you only can
land in to some place with the surf at
tap for example if you return you should
return to some place to indicate this is
the place a lot written otherwise you
would gas fill it right so this paper
published by look at talk box or however
enhanced our document so basically the
thing here is Singapore's of policy if
you have to land in to the place with a
grass means that that's always valid
gadget right we try to sculpt so onion
handy gadget no you I impose return
to the car proceed instruction so
talking to the function entry the job
going to the place should be the landing
visit or call a label this kind of thing
so that's all belong to valid gadget
that means in future if we have this
kind of capability you have to use the
value gadget to in issues or attack
otherwise it doesn't work right so today
if you look at the rural attacks that's
all
almost based on running hundreds get
another approach could be used to
defense robbed in the shuttle stack that
means every time the call happens we put
the value on the stack shadow stack and
when we tell happens if we check that
and to make sure that smashed so that's
a pretty much very close to the with a
nice project because actually in rhythm
is in current CPU they have limited
buffer for shuttle stack very similar
stuff so but if he will do this kind of
scenes then that means you also rely on
the valid gadget you only can use valid
gadget to attack so now we totally read
about the valid gadget here so first
thing I want to discuss is Telfer
so we solve the case here the the use
the onion handy curve to lost actors
right so we will show how to do the very
planet based stealth parity and
announcing our new mission here is in
six for peace the area can be used to
the stack parity the thing is very
simple because every time the SS ESP you
flag and the CSG IP of course if you
have the error code via the view pooch
on the stack right well when the wreck
happened we will pop so as I can if you
push the some special value on ESP stack
as yes P then simply just directly
install the ESP has a stack so that's
pretty much very easily to do the
staring future especially in the 64 p OS
but here I want to show another approach
to the stack 13 because think about the
valid code ETF could have all kinds of
different logic so for example here
that's very interesting gadgets in your
software when you call this function
they do a bunch of thing but the most
interesting thing is they will use the
first parameter as ESP so thank you so
that means first time you call this one
you just push the first parameter as
what you want that is the directly
installed the value called ESP so
there's three forward to the step 13 so
after that you can do bunch of gadgets
for example call to the second parameter
then you'll cut through this kind of
valid instruction we call the stack
based function so that's pretty much
very easy to kick off the tank ferreting
so even we have all kinds of solution
when the valid gadget is enough so for
example mekin
last year did the talk talking the hat
so the basic idea here I want to
introduce is think bugs or cheat cheat
engine so today we use top screw this
can
right so think about if the job scripts
from the script level you call the
tongue function with the parameter the
protocol exactly per tab exactly like
some other API if we do the actually
rewrite we can change the callback of
vtable from the memory now every time
you call the some JavaScript object
based
messer so eventually we can redirect
that to the API call that means that's
the cost dimension me to call the API
from script level so this is the exact
topic him mentioned like intro
inter-dimensional excursion with that we
you never against the value gadget
because our cages creates by Rob our
engine now that's all valid code is here
the V just about how you call these
kinds of API as you want of course
probably you need so absolutely right
bond ability to change the V table like
that so this is a very interesting topic
so now I talk about some very
interesting stuff in war64 because I
only have six minutes I will go very
fast but we talked about the teapot so
what it's for is comes in you can run
those two so two bit code on 64-bit
windows right we have a couple different
component to support that so they have
three different components of wall since
fall and was evolving and also was in
France if you so this is very
interesting because this one is actually
controls the CPU mode switch so let's
look at that so before we have you code
we introduced the basic concepts for
logic address transfer to linear graph
so basically that's through the segment
and segment table this kind of thing so
every time as you know if you use a
segment selector they have
different definition for example here
that's that that's the index and this is
indicate that's in GD g TR ldt and also
up here
so the selecting itself let me use to
search in the GDP our duty to guess the
selector the other segment descriptor so
the sacrament is cook you'll have bunch
of definitions but here what interesting
thing is air beat so this one indicate
the code is 64-bit or 32-bit so this is
very interesting so now in 64-bit
windows they have bunch of different use
the Yoast bunch of different segments
but here the interesting part is in the
seconds 33 this one that gives four
seats for bit code the segment 23 that
that Kate Foster to be so this is very
interesting part so if you look at your
code how the transfer mode for example
we look at this one that's the watch ng
watch query over to memory so this point
is what's it for if you call this curve
in ant idea so to be an idea so we will
come to a pass of CFC 0 this point clip
1 address for the translation the switch
color so for example this one point to
here so this is very straightforward
that's a part of the use Trump Trump to
the address is the selector is 33 after
that our code will run in 64-bit mode so
after the finished part of request we
will switch back to the so to gate so
the use of our job also used in to a
part of switch back and also beyond that
they also could use the array I rescue
like that so because we're since
populate has different implementations
they have part of place in useless space
to use errors queue to return to the
different address so well now the
interesting thing happens so think about
the sort of beat codon six for peer code
share same memory space actually not
exactly shame but that means those
things also do be called belong to part
of things for be it
so insert of the code you can access six
four bit code in six more bit code also
you can access the default vehicle also
do video so that's not exactly similar
drive space but the overlap if you do
that that's very interesting because
symbols or 64-bit code compiler can try
that as six more bit code like little
bit and saluted but the problem is once
a signal different security code the
instruction as current mode for example
if secure in through gate now you run
the each puppet color now if the code up
code is cracked you just run the code as
sorted to be but the problem is the
original intention for this code is for
FIFA P so this is very interesting
problem so basically in current Windows
Microsoft implemented kind of seen as
theme has different segments but all
segments can access sing simple code so
that's that's a big problem because
think about the valid gadget means the
compiler compare that as area as well
right so now you get value code very
code is self compiled by 640 but the
code is CF
totally two different totally different
scene in Ruby's mode so that crossbow
that's a problem thank you so this is a
key point I want to make say even you
have all kinds of defense part but this
is a big problem because you cannot see
I compile the code of these all kinds of
policy in six for Pete you eventually
fix four bit binary but same code
section can be proved wrong at still
true
with total different meaning so that's
problem right and also the interesting
part here is simple as a native 64-bit
code itself even V is also to be wall
inside your still can switch from c4p
encode to 32-bit code that's a big
problem
so basically I've use skip bunch of
slides because I have linear time
so the key problem here is lots of onion
handy valid code could exist in was in
small so from solutely you can call a
bunch of their compiled as 64-bit code
but think about if you switch the
molecule from cells because see for that
means all internal code in certain base
could be available for 64-bit code may
be different meaning right and another
big problem here is even native c4
without war mode you'll still can
trigger the sort of beat segment because
probably the implement and be ready to
use later but that means in to six
copied application in fact at the bundle
breaking you can trigger that on still
do beat now you still can run so you be
yet if they have so that's very
interesting
so last thing I want to mention is we
talked about bunch of approach to defend
Castle Rock these kinds of attack so
actually the problem is today we still
cannot fully against this kind of attack
so from the contact perspective I want
to mention
probably miss some solution like branch
transfer exact control so think about
every time if the front transfer happens
we can have the mechanism to guide our
checks of some policy see this transfer
is valid or not probably that's the
approaching future we can scoffs the
rough attack the drop of hot rock or
whatever
a similar closing your space back so
quickly that's all thank you very much
[Applause]
so if you have questions we can discuss
Hawkman because I guess already raw of
that