---
type: Whitepaper
title: "The Devil is in the Constants: Bypassing Defenses in Browser JIT Engines"
description: JavaScript integer constants survive into a JIT engine generated code, so an attacker can encode x86 gadget bytes as immediate values and make Firefox or Internet Explorer emit a full ROP chain at run time, defeating ASLR, DEP and the undocumented JIT hardening in IE. Gadgets can also be located on the fly, and blinding every constant costs up to 80 percent more instructions.
resource: "https://www.ndss-symposium.org/wp-content/uploads/2017/09/09_1_2.pdf"
tags: [whitepaper, webseclist-reference, gadget-chain, rce, javascript-runtime, javascript, mitigation, owasp-a08-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-11T17:43:03+00:00"
status: stable
stale_after: 2027-08-11
sources:
  - id: original
    resource: "https://www.ndss-symposium.org/wp-content/uploads/2017/09/09_1_2.pdf"
    title: "The Devil is in the Constants: Bypassing Defenses in Browser JIT Engines"
    author: Michalis Athanasakis, Elias Athanasopoulos, Michalis Polychronakis, Georgios Portokalidis, Sotiris Ioannidis
also_at: []
authors:
  - Michalis Athanasakis
  - Elias Athanasopoulos
  - Michalis Polychronakis
  - Georgios Portokalidis
  - Sotiris Ioannidis
canonical_url: ""
cited_by:
  - "2015.md:70"
commit: ""
content_sha256: bf6e085029df8dad0d1e606a1fbfa0ec99cd135ae5b0c0ccbb92dae502facaee
depth: full
depth_reason: default
kind: whitepaper
language: ""
licence: unknown
original_url: "https://www.ndss-symposium.org/wp-content/uploads/2017/09/09_1_2.pdf"
published: ""
publisher: ""
publisher_english: ""
raw_sha256: 39957a59acc753930b70b718dc974f89bbaa0d8a2ecca144f927b150321568bc
retrieved_from: "https://www.ndss-symposium.org/wp-content/uploads/2017/09/09_1_2.pdf"
retrieved_kind: stored
retrieved_utc: "2026-08-11T17:43:03+00:00"
slug: devil-constants-bypassing-defenses-browser-jit-engines
snapshot: ""
title_english: ""
translation_file: ""
translation_of: ""
---

# The Devil is in the Constants: Bypassing Defenses in Browser JIT Engines

**The Devil is in the Constants: Bypassing Defenses in Browser JIT Engines** - Michalis Athanasakis, Elias Athanasopoulos, Michalis Polychronakis, Georgios Portokalidis, Sotiris Ioannidis, Publisher not stated.

- Published: date not stated
- Original: <https://www.ndss-symposium.org/wp-content/uploads/2017/09/09_1_2.pdf>
- Preserved from: https://www.ndss-symposium.org/wp-content/uploads/2017/09/09_1_2.pdf (stored) on 2026-08-11
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

The Devil is in the Constants: Bypassing Defenses
               in Browser JIT Engines
  Michalis Athanasakis Elias Athanasopoulos Michalis Polychronakis                                  Georgios Portokalidis Sotiris Ioannidis
     FORTH, Greece                    FORTH, Greece                 Stony Brook University Stevens Institute of Tech. FORTH, Greece
   michath@ics.forth.gr             elathan@ics.forth.gr           mikepo@cs.stonybrook.edu gportoka@stevens.edu sotiris@ics.forth.gr



    Abstract—Return-oriented programming (ROP) has become                           every day. Even users that prefer apps, instead of a general
the dominant form of vulnerability exploitation in both user                        purpose browser, unknowingly interact with browser compo-
and kernel space. Many defenses against ROP exploits exist,                         nents frequently used by app developers [1]. Their popularity
which can significantly raise the bar against attackers. Although
protecting existing code, such as applications and the kernel,                      is probably one of the reasons that they are such an attractive
might be possible, taking countermeasures against dynamic code,                     target for attackers and security researchers alike [2]–[4].
i.e., code that is generated only at run-time, is much harder.
Attackers have already started exploiting Just-in-Time (JIT)                        A. Problem Statement
engines, available in all modern browsers, to introduce their                          Attacks against browsers continue despite the fact that
(shell)code (either native code or re-usable gadgets) during JIT
compilation, and then taking advantage of it.                                       compromising binary software using buffer overflows and
    Recognizing this immediate threat, browser vendors started                      control-hijacking attacks is much harder today. Modern op-
employing defenses for hardening their JIT engines. In this paper,                  erating systems (OSs) include features like stack canaries [5],
we show that—no matter the employed defenses—JIT engines are                        non-executable pages [6], and address-space layout ran-
still exploitable using solely dynamically generated gadgets. We                    domization (ASLR) [7], which severely hinder exploitation.
demonstrate that dynamic ROP payload construction is possible
in two modern web browsers without using any of the available
                                                                                    Even code-reuse techniques such as return-oriented program-
gadgets contained in the browser binary or linked libraries. First,                 ming (ROP) [8] are not straightforward, since they require
we exploit an open source JIT engine (Mozilla Firefox) by feeding                   information-leak bugs to reveal the randomized location of
it malicious JavaScript, which once processed generates all re-                     code [9], [10] or legacy code and libraries that ASLR cannot
quired gadgets for running any shellcode successfully. Second, we                   randomize.
exploit a proprietary JIT engine, the one in the 64-bit Microsoft
Internet Explorer, which employs many undocumented, specially                          Recent works on control-flow integrity (CFI) [11], [12],
crafted defenses against JIT exploitation. We manage to bypass                      fine-grained code randomization [13]–[15], and run-time be-
all of them and create the required gadgets for running any                         havioral monitoring [16], [17] promise to protect software
shellcode successfully. All defensive techniques are documented                     from ROP-like attacks, but unfortunately they have been
in this paper to assist other researchers. Furthermore, besides                     also shown to be vulnerable to niche attacks [9], [18], [19].
showing how to construct ROP gadgets on-the-fly, we also show
how to discover them on-the-fly, rendering current randomization                    Other approaches that require application source code, such as
schemes ineffective. Finally, we perform an analysis of the most                    modular fine-grained CFI [20] and G-Free [21], offer greater
important defense currently employed, namely constant blinding,                     guarantees again control-flow hijacking attacks and ROP. So
which shields all three-byte or larger immediate values in the                      far, there are no documented attacks against these defenses,
JIT buffer for hindering the construction of ROP gadgets.                           so, in principle, they could protect our precious browsers in
Our analysis suggests that extending constant blinding to all
immediate values (i.e., shielding 1-byte and 2-byte constants)                      the future, even though one cannot make strong predictions.
dramatically decreases the JIT engine’s performance, introducing                       Unfortunately, even defenses that may be effective for
up to 80% additional instructions.                                                  conventional software are not always so for browsers. Modern
                                                                                    browsers dynamically generate code through just-in-time (JIT)
                            I. I NTRODUCTION                                        compilation to accelerate the execution of JavaScript (JS) code
  Web browsers are undoubtedly omnipresent. They are found                          at run time. Although defenses like the ones discussed above
on PCs, smartphones, tablets, smart TVs, gaming consoles,                           can be efficient in protecting existing code, code generation is
and elsewhere. Most Internet users probably use a browser                           frequently not handled and it is outside their threat model.
                                                                                       Attacks exploiting the JIT engines of browsers are not new.
Permission to freely reproduce all or part of this paper for noncommercial          Figure 1 depicts the evolution of attacks and defenses against
purposes is granted provided that copies bear this notice and the full citation     them. Originally, code and data were not separated by the
on the first page. Reproduction for commercial purposes is strictly prohibited
without the prior written consent of the Internet Society, the first-named author
                                                                                    code-generation engine, so both the generated native code
(for reproduction of an entire paper only), and the author’s employer if the        and the data it was operating on was placed on the same
paper was prepared within the scope of employment.                                  executable memory pages. It was enough for the attacker to
NDSS ’15, 8-11 February 2015, San Diego, CA, USA
Copyright 2015 Internet Society, ISBN 1-891562-38-X
                                                                                    place shellcode in a JavaScript array and then redirect the
http://dx.doi.org/10.14722/ndss.2015.23209                                          program’s control-flow to his shellcode in memory. Because
encapsulated gadget.                                                JavaScript program is compiled. The calling convention of
   Listing 2 shows a JavaScript program, which once executed,       VirtualProtect in Windows is the following. The func-
generates the gadgets required to compromise Mozilla Firefox.       tion takes 4 arguments using the %rcx, %rdx, %r8, and %r9
To do this, we first declare seven variables (lines 1-3). Each      registers. Therefore, assuming we control the stack, we need
variable is carefully initialized to host a gadget. The initializa- to introduce the gadgets shown in Listing 3. In Listing 3 we
tion takes place inside a long loop to trigger the JIT engine.      include an additional gadget, which pops %rax. This gadget
In Figure 4 we show how we influence the JIT output by              is not needed for calling VirtualProtect but for breaking
assigning particular immediate values to JavaScript variables.      a defense mechanism employed by Chakra as we will discuss
For example, assigning the value 12728721 to a variable will        later.
introduce the following assembly code once compiled:                   Apart from the gadgets we need for calling
   movl $0xc3c031 , 0 x6c8 (% eax )                                 VirtualProtect,         we also need an additional gadget
                                                                    for adjusting the stack. Usually, the vulnerability is related
  In hex this has the value of 0x06c8080c7c3c03100 to the heap, therefore we need to adjust the real stack to the
which includes 0xc3c031, which is a gadget for zeroing fake stack controlled by us, something that we commonly
%eax:                                                               call stack pivoting. We avoided discussing the stack-pivoting
   xor %eax , %eax ; r e t ;                                        gadget in Section IV, since in the case of Mozilla this gadget
                                                                    can be constructed trivially. Constructing the stack-pivoting
  In the same fashion we can construct all of the gadgets in IE is usually based on exchanging a register the attacker
contained in the ROP chain of Listing 1 and eventually call controls with %rsp, so that the stack pointer points to the
mprotect for making the shellcode executable.                       attacker’s fake stack. This exchange can be done using xchg,
            V. E XPLOITING I NTERNET E XPLORER                      which unfortunately is 2 bytes long, and with the additional
                                                                    ret instruction becomes a 3-byte gadget. As we show later
 1 pop %r8 ; r e t ;                                                in this section 3-byte gadgets cannot be constructed trivially
 2 pop %r9 ; r e t ;                                                (see “Long gadgets” later in this section). For constructing
 3 pop %r c x ; r e t ;
 4 pop %rdx ; r e t ;                                               the stack-pivoting gadget we need an additional requirement:
 5 pop %rax ; r e t ;                                               having control over %al. The reason is discussed later in this
   Listing 3. Required gadgets for calling VirtualProtect in Windowssection.
   (64-bit).
                                                                          C. Exploit Design Considerations
   In this section we present how we exploit a vulnerable
Internet Explorer (IE) in Microsoft Windows (64-bit) without                 Similarly to the approach we took in Section IV, we started
using any of the available gadgets contained in the binary or             with a compute-heavy loop to trigger the JavaScript JIT
DLLs used by the browser.                                                 compiler and a series of variable initializations, to introduce
                                                                          the desired gadgets in the JIT buffer once the loop is compiled.
A. Why Internet Explorer is different                                     However, IE is very different from Mozilla and such an
   Version 9 of IE has started employing a JavaScript JIT                 approach failed. IE’s JIT engine, Chakra, employs a number
engine called Chakra [34]. As IE is proprietary, little is known          of defenses which makes introducing gadgets in the JIT buffer
about its internals, and in particular how the JIT engine                 through immediate values in the JavaScript source impossible.
works. There are several issues that make carrying out an                 To make our attack work we had to reverse engineer Chakra’s
attack as the one presented in Section IV for IE significantly            defenses. We will discuss some of these defenses here and
harder. First, lack of source code makes understanding how                how we were able to circumvent them.
the JIT engine is triggered, where the JIT buffer is located,                  a) Constant Blinding: Any immediate value less than 2
and other related detail important for exploiting the engine,             bytes long is never emitted as is in the JIT buffer. Instead, it is
very difficult. Second, Chakra employs a series of defenses               XORed with a random value and then XORed again when it is
specifically introduced for preventing the generation of gadgets          actually used. For example, assume the following JavaScript
in the JIT buffer. Third, we want to exploit the 64 bit version           code:
of IE, which changes things in terms of calling conventions,                 var g a d g e t = 0 xc35841 ;
as fastcall is used, and the first function arguments are passed
through registers and not through the stack. In the rest of the           Once it is compiled, we would normally expect to see the
section we describe how we overcome these difficulties.                   following code in the JIT buffer:
B. Preparation                                                               mov %rcx , 1000000 c35841h
                                                                             mov qword p t r [ rax +48 h ] , %r c x
   As before, to exploit IE we must make the page that
holds the shellcode executable. This means that we need                   This code essentially puts the (immediate) value 0xc35841
to call VirtualProtect with the appropriate arguments,                    in %rcx, which we assume is the register that holds the value
and to accomplish this we must use the gadgets that will                  of the JavaScript variable gadget. This reflects the example
be introduced in the JIT buffer, once a properly crafted                  we discussed in Figure 4, where an immediate value (in our

                                                                      6
                                                                        16        }
    pop %r8                                                             17        return 0;
    add b y t e [% rax ] , %a l                                         18 }
                                                                        19
The important part is that Chakra has placed a conditional              20 e m i t g a d g e t s ( ) ;
jump which is followed if the overflow bit is set:                           Listing 4. The JavaScript program which once compiled will produce the
    j o 000051 f d 6 c 0 0 3 7                                               needed gadgets in the JIT buffer of IE.

Notice, that the addition following the pop instruction sets the           Now that we have presented the defenses employed by
overflow bit and thus the flow follows the conditional jump             Chakra, we will discuss how we introduce the needed gad-
which executes an access violation handler. To overcome this            gets in the JIT buffer for running the exploit. As already
we need to achieve two things:                                          mentioned we need to create four gadgets for loading %rcx,
                                                                        %rdx, %r8, and %r9, with the correct values for calling
   • Make sure that the code between the partially emitted
                                                                        VirtualProtect (see Listing 3). Two of the four gadgets
     gadget (the pop-part) does not alter the exploit’s logic
                                                                        (the ones for %rcx an %rdx) are only 2 bytes in length and
     (i.e., does not modify any of the registers from Listing 3).
                                                                        thus they can be created with the techniques we analyzed in
   • Somehow unset the overflow bit before the conditional
                                                                        Section IV (see lines 12 and 13 in Listing 4). The challenging
     jump.
                                                                        part is to create the other two for loading %r8 and %r9, which
   In one special case, for constructing the stack-pivoting
                                                                        are longer than 2 bytes.
gadget (which is a 3-byte gadget), it is sufficient to control
                                                                           These gadgets are emitted in the JIT buffer using JavaScript
%rax (specifically guarantee that its low part, %al, has a zero
                                                                        functions. Observe lines 1–7 in Listing 4. We implemented two
value), and thus avoid raising the overflow flag. This is why
                                                                        JavaScript functions, r8() and r9(), which simply return
we need to control %rax for exploiting IE, as we described
                                                                        a fixed value added to their single argument input. These
in the beginning of this section.
                                                                        functions, once compiled, produce the following code (for
     c) Code Diversification: Chakra adds another diversifi-
                                                                        example r9()):
cation layer in the JIT buffer by emitting a random number of
                                                                             add %eax , 5941 h
nop instructions. These instructions perform no useful com-                  j o 000000 D71F8F0132
putation, however they change the layout of the JIT buffer, and              mov %rcx , 1000000000000 h
                                                                             or %rax , %r c x
therefore, all important gadgets have a different location every             add %rsp , 30 h
time they are generated. This particular technique, inserting                pop %rbx
                                                                             pop %r s i
random nop instructions, has been also used for diversifying                 mov %rsp , %rbp
the Linux kernel layout [35]. Software diversification [36] has              pop %rbp
                                                                             ret
been a promising defense mechanism against exploitation, and
we have seen it applied with many different strategies [7], [13],       Now, if execution starts from the address of the immediate
[14], as well as used for preventing the attacks we discuss in          value (0x5941), a pop %r9 will be executed and control
this paper [24]. Unfortunately, recently we have seen at least          flow will eventually reach the ret instruction where the
two sophisticated techniques [9], [10], that can bypass fine-           (compiled) JavaScript function returns. The only problem is
grained randomization methods by exploiting information-leak            the conditional jump for the overflow bit which will be set.
bugs. Our work here is about generating the gadgets in a                To overcome this we use an additional gadget which sets %rax
heavily defended environment, such as Chakra, and not on                (line 11 in Listing 4). The complete JavaScript source for
techniques for discovering the process layout. Recall that with         introducing all needed gadgets in the JIT buffer is shown in
the wide adoption of ASLR all exploits need at least one                Listing 4 and the stack, along with the way the individual
information-leak bug for discovering the position of the needed         gadgets are chained, is depicted in Figure 6.
gadgets. The amount of information leakage depends of course
on the nature of the vulnerability.                                                          VI. D ISCOVERING THE G ADGETS
D. Exploit Implementation                                                  In Sections IV and V we demonstrated how someone can
                                                                        introduce ROP gadgets in the JIT buffer of Mozilla Firefox
 1 f u n c t i o n r8 ( addr ) {                                        and IE. However, for a successful attack, the adversary has
 2         r e t u r n a d d r + 0 x5841 ;
 3 }                                                                    to locate the position of each gadget in order to form the
 4                                                                      ROP chain, which will eventually compromise the vulnerable
 5 f u n c t i o n r9 ( addr ) {                                        program. In this section we investigate how this can be carried
 6         r e t u r n a d d r + 0 x5941 ;
 7 }                                                                    out successfully. Notice, that we assume that a fine-grained
 8                                                                      randomization scheme has been enabled, like Librando [24]
 9 function emit gadgets () {
10         f o r ( i = 0 ; i < 0 xc35841 ;   i ++) {                    or Chakra.
11                 r a x = 0 xc358 ;
12                 r c x = 0 xc359 ;                                    A. How Information Leaks Work
13                 rdx = 0 xc35a ;
14                 r8 ( 0 ) ;                                             All randomization schemes have an Achilles’ heel: infor-
15                 r9 ( 0 ) ;                                           mation leaks. An attacker can read the contents of a part of

                                                                    8
section in order to create a fully working exploit. The exploit              we do not account for additional code that will be executed for
creates all needed ROP gadgets in the JIT buffer, it locates                 preparing the blinding (i.e., calls to rand(), code analysis,
them one by one using an information-leakage vulnerability,                  and so on).
it builds the ROP chain, which once executed it makes a page                    Moreover, strategy (ii) is based on simply hiding the
hosting the shellcode executable, and, finally, compromises the              gadgets. This strategy has been adopted by many proposals
browser.                                                                     for countering software exploitation. Unfortunately, all these
 1 O = new O b j e c t ( ) ;                                                 strategies can be defeated either through a memory disclosure
 2 O.g1 = 0 xc358 ;                                                          bug [29], or by forcing the vulnerable application to place
 3 O.g2 = 0 xc359 ;                                                          attacker data, that is the generated code by the JavaScript
 4 f u n c t i o n f o o ( x ) { r e t u r n 0 x5841 ; }
 5 O.func = foo ;                                                            JIT compiler in our case, in predictable locations. The latter
    Listing 5. JavaScript code that generates a Object which memory layout isis comparable with heap spraying [30], where the attacker
    described in Figure 7.                                                   allocates many copies of his data in an attempt to ensure that
                                                                             one of the copies lands at a predictable memory address in
                                                                             the vulnerable program’s heap. This might sound improbable
                                 VII. D EFENSES
                                                                             but recent work in this field has shown that such memory
   In this section we discuss defenses. We first discuss existing disclosure attacks are both powerful and realizable, and they
defenses and their applicability and later we propose new can bypass even highly dynamic randomization schemes [15].
countermeasures based on our experience from building the In fact, in this paper we have demonstrated a similar technique
attacks presented in this paper.                                             for leaking the location of the JIT buffer (see Section VI),
                                                                             and discovering all constructed ROP gadgets, rendering all
A. Existing Defenses
                                                                             randomization schemes ineffective.
   So far, there are two ways to defend against the attacks                     One possible direction for mitigating ROP in general, and
we described: (i) preventing the construction of gadgets using thus the attacks presented in this paper, is Control-Flow
techniques such as constant blinding (see Section V), and (ii) Integrity (CFI). [37] This was initially a very promising
diversifying the JIT buffer so that the created gadgets cannot technique against code-reuse attacks, which quickly drove
be located. Both these strategies are used in IE’s JIT engine to implementations [11], [12], [16], [17] that support legacy
(Chakra) and Librando [24]. We have serious concerns that code and impose negligible overhead. Unfortunately, there are
these strategies may not actually constrain sophisticated and many concerns about the validity of these approaches [18],
determined attackers.                                                        [19], [31], [32], [38], therefore making the applicability
   As far as strategy (i) is concerned, we demonstrated its of CFI, especially the coarse-grained version, questionable.
weaknesses by realizing an actual attack on Chakra which Nevertheless, there are still efforts for applying fine-grained
bypasses constant blinding by constructing gadgets in short CFI in dynamic-code generation [20], which is essentially
immediate values of 1 and 2 byte. One could argue that very similar to JIT compilation, and possibly could be a
by applying constant blinding in all immediate values, no practical solution—as long as the overhead is reasonable—for
matter the size, could, in theory, stop the attack. This is countering the attacks presented in this paper.
correct, however, enforcing constant blinding in all immediate
values does not come for free. We perform our evaluation B. Proposed Defenses
using the SunSpider benchmarks suite. We log all the JIT
instructions that were actually executed in each test. We count                 Based on our experience while developing the attacks
how many instructions involve an immediate value (of 1                       presented   here we propose two defense mechanisms. Both,
or 2 bytes) and the respectively required CPU cycles. We                     require  code  analysis. Realizing these techniques is beyond the
extract this information from Intel’s manual, by matching                    scope  of  this paper and we believe further research is needed
instructions and corresponding cycles. Essentially, there are                for  implementing    them. Both techniques introduce overhead
three families of instructions that may involve an immedi-                   which   may   eventually nullify the gains from JIT compilation.
ate value, the distribution of which we depict in Figure 9. This is the reason why we believe that the attacks presented
Note that in all tests the instructions involving an immediate in this paper cannot be easily addressed.
value comprise a significant percentage, ranging between 18–                       d) JIT Analysis: The most obvious defense mechanism
52% of all executed instructions. Therefore applying constant is to enhance the JIT compiler with the techniques proposed
blinding to all immediate values is quite costly, introducing by G-Free [21] for eliminating all gadgets. This has as a major
an estimated overhead of 15% to 80%, as shown in Figure 8. advantage that the produced code is safe and gadget-free,
We assume that the JIT compiler emits (at least) two or six however this does not come for free. The code has to be further
more instructions for each instruction involving an immedi- processed for eliminating the gadgets, and the produced native
ate value, depending on whether the instruction has one or code will experience overheads compared to the non gadget-
two immediates. We match these additional instructions to free code. Last but not least, it is unclear if it actually easy
corresponding cycles and calculate the overhead as additional to apply G-Free techniques in code that is generated partially
cycles. Notice that this estimation is quite conservative, since and on-the-fly.

                                                                     10
the vulnerable program in an unintended behavior [8], [25],                                     X. ACKNOWLEDGMENTS
[26], [43], [44]. So far, the most practical defense mechanism
                                                                            We thank the anonymous reviewers for their valuable com-
for defeating code-reuse attacks is ASLR [7], which simply
                                                                          ments. This work was supported in part by the FP7-PEOPLE-
randomizes the process layout in the virtual space, so that
                                                                          2010-IOF project XHUNTER No. 273765 and by the US
the attacker cannot locate the existing code. Researchers have
                                                                          Air Force through Contract AFRL-FA8650-10-C-7024. Any
managed to bypass ASRL when the entropy is not enough or
                                                                          opinions, findings, conclusions or recommendations expressed
using information leaks [45]–[48]. Following the practice of
                                                                          herein are those of the authors, and do not necessarily reflect
ASLR, researchers developed more fine-grained randomization
                                                                          those of the US Government, or the Air Force.
schemes [13], [14], but again they were defeated by sophisti-
cated exploitation techniques based on information leaks [9]
                                                                                                       R EFERENCES
or on brute forcing crash-resistant processes [10].
   It seems that the most promising direction for countering               [1] Google, “WebView,” Android Developers API Reference, https://
code-reuse attacks is to eliminate the feasibility of code-reuse               developer.android.com/reference/android/webkit/WebView.html.
                                                                           [2] N. Joly, “Advanced exploitation of Internet Explorer 10 / Win-
itself. This can be done either by either re-writing the bi-                   dows 8 overflow (Pwn2Own 2013),” VUPEN Vulnerability Research
nary [11], [12] to respect its call-graph [37], either monitoring              Team (VRT) Blog, May 2013, http://www.vupen.com/blog/20130522.
at run-time [16], [17], or by re-compiling it for eliminating                  Advanced Exploitation of IE10 Windows8 Pwn2Own 2013.php.
                                                                           [3] A. Pelletier, “Advanced exploitation of Internet Explorer heap overflow
all code-reuse paths (gadgets) [21]. Although attacks for such                 (Pwn2Own 2012 exploit),” VUPEN Vulnerability Research Team (VRT)
systems have been demonstrated [18], [31], [32], we believe                    Blog, July 2012, http://www.vupen.com/blog/20120710.Advanced
that the bar for exploiting a binary has been significantly raised             Exploitation of Internet Explorer HeapOv CVE-2012-1876.php.
                                                                           [4] J. L. Obes and J. Schuh, “A tale of two pwnies,” The Chromium Blog,
by the community and that attackers have to discover new                       May 2012, http://blog.chromium.org/2012/05/tale-of-two-pwnies-part-
avenues for exploitation. One of this, is the one presented in                 1.html.
this paper: exploiting a program in an environment which is                [5] C. Cowan, C. Pu, D. Maier, H. Hinton, J. Walpole, P. Bakke, S. Beattie,
                                                                               A. Grier, P. Wagle, Q. Zhang et al., “Stackguard: Automatic adaptive
gadget free.                                                                   detection and prevention of buffer-overflow attacks,” in Proceedings of
   In parallel with this work, Song et al [49] show that                       the 7th USENIX Security Symposium, vol. 81, 1998, pp. 346–355.
JIT buffers can be exploited through code cache injection                  [6] S. Andersen and V. Abella, “Changes to functionality in microsoft
                                                                               windows xp service pack 2, part 3: Memory protection technologies,
techniques. This is possible if the JIT buffer is both writable                Data Execution Prevention,” Microsoft TechNet Library, September
and executable or even temporarily writable at times. This                     2004, http://technet.microsoft.com/en-us/library/bb457155.aspx.
threat is more realistic if the generated code is multi-threaded,          [7] PaX Team, “Address Space Layout Randomization (ASLR),” 2003, http:
                                                                               //pax.grsecurity.net/docs/aslr.txt.
because the switch between writable and executable leaves a                [8] H. Shacham, “The geometry of innocent flesh on the bone: Return-into-
time window for exploitation. They propose a new dynamic                       libc without function calls (on the x86),” in Proceedings of the 14th
code generation architecture which utilizes a separate process                 ACM conference on Computer and Communications security, October
                                                                               2007, pp. 552–61.
and shared memory to prevent such exploits.                                [9] K. Z. Snow, L. Davi, A. Dmitrienko, C. Liebchen, F. Monrose, and A.-R.
                                                                               Sadeghi, “Just-in-time code reuse: On the effectiveness of fine-grained
                                                                               address space layout randomization,” in Proceedings of the 34th IEEE
                      IX. C ONCLUSION                                          Symposium on Security and Privacy, May 2013.
                                                                          [10] A. Bittau, A. Belay, A. Mashtizadeh, D. Mazieres, and D. Boneh,
                                                                               “Hacking blind,” in Proceedings of the 35th IEEE Symposium on
   In this paper we introduced and demonstrated a method                       Security and Privacy, vol. 14, 2014.
to attack gadget-free binaries. We demonstrated our attack                [11] C. Zhang, T. Wei, Z. Chen, L. Duan, L. Szekeres, S. McCamant,
on Mozilla Firefox and Microsoft Internet Explorer, two of                     D. Song, and W. Zou, “Practical control flow integrity and randomization
                                                                               for binary executables,” in Proceedings of the 1013 Security and Privacy
the most widely used applications. Our starting assumption                     Symposium, 2013, pp. 559–573.
was that the binaries and shared libraries contain no gadgets             [12] M. Zhang and R. Sekar, “Control flow integrity for cots binaries,” in
that can be exploited. Our attack manages to introduce useful                  22nd USENIX Security Symposium, 2013.
                                                                          [13] V. Pappas, M. Polychronakis, and A. D. Keromytis, “Smashing the
gadgets by utilizing the JIT engine present in both browsers,                  gadgets: Hindering return-oriented programming using in-place code
but also present in other applications as well. Using the JIT                  randomization,” in Proceedings of the 2012 IEEE Symposium on Security
engine, we can create the required gadgets at run-time, inside                 and Privacy, 2012, pp. 601–615.
                                                                          [14] R. Wartell, V. Mohan, K. W. Hamlen, and Z. Lin, “Binary stirring:
the JIT buffer.                                                                Self-randomizing instruction addresses of legacy x86 binary code,” in
   Furthermore, we modified a technique based on already                       Proceedings of the 2012 ACM conference on Computer and communi-
published work [9] for discovering the gadgets at run-time by                  cations security. ACM, 2012, pp. 157–168.
                                                                          [15] A. K. Cristiano Giuffrida and A. S. Tanenbaum, “Enhanced operating
leaking the address of the JIT buffer. Our attack is powerful in               system security through efficient and fine-grained address space ran-
the sense that it allows the execution of any shellcode, since it              domization,” in Proceedings of the 21st USENIX Conference on Security
can change the access permissions of the data page holding the                 Symposium, 2012, pp. 40–55.
                                                                          [16] V. Pappas, M. Polychronakis, and A. D. Keromytis, “Transparent ROP
shellcode. Our techniques are able to exploit the JIT engine                   exploit mitigation using indirect branch tracing,” in Proceedings of the
of IE (Chakra), which incorporates a series of defense mecha-                  22nd USENIX Security Symposium, 2013, pp. 447–462.
nisms designed specifically to thwart such attacks. Finally, we           [17] Y. Cheng, Z. Zhou, M. Yu, X. Ding, and R. H. Deng, “ROPecker:
                                                                               A generic and practical approach for defending against ROP attacks,”
performed an extensive analysis and present details about the                  in Proceedings of the 2014 Network and Distributed System Security
undocumented defensive techniques of Chakra.                                   (NDSS) Symposium, February 2014.


                                                                     12
[18] E. Göktaş, E. Athanasopoulos, H. Bos, and G. Portokalidis, “Out of              [35] V. P. Kemerlis, G. Portokalidis, and A. D. Keromytis, “kguard:
     control: Overcoming control-flow integrity,” in Proceedings of the 35th                Lightweight kernel protection against return-to-user attacks,” in
     IEEE Symposium on Security and Privacy, May 2014.                                      Proceedings of the 21st USENIX Conference on Security Symposium,
[19] E. Göktaş, E. Athanasopoulos, M. Polychronakis, H. Bos, and G. Por-                  ser. Security’12. Berkeley, CA, USA: USENIX Association, 2012, pp.
     tokalidis, “Size does matter: Why using gadget-chain length to prevent                 39–39. [Online]. Available: http://dl.acm.org/citation.cfm?id=2362793.
     code-reuse attacks is hard,” in 23rd USENIX Security Symposium, 2014.                  2362832
[20] B. Niu and G. Tan, “Modular control-flow integrity,” in Proceedings               [36] P. Larsen, A. Homescu, S. Brunthaler, and M. Franz, “Sok: Automated
     of the 35th PLDI, 2014, pp. 577–587. [Online]. Available: http:                        software diversity,” in Proceedings of the 35th IEEE Symposium on
     //doi.acm.org/10.1145/2594291.2594295                                                  Security and Privacy, May 2014.
[21] K. Onarlioglu, L. Bilge, A. Lanzi, D. Balzarotti, and E. Kirda, “G-Free:          [37] M. Abadi, M. Budiu, U. Erlingsson, and J. Ligatti, “Control-flow
     Defeating return-oriented programming through gadget-less binaries,”                   integrity,” in Proceedings of the 12th ACM conference on Computer
     in Proceedings of the 26th Annual Computer Security Applications                       and Communications Security, 2005, pp. 340–353.
     Conference, 2010, pp. 49–58.                                                      [38] Nicholas Carlini and David Wagner, “Rop is still dangerous: Breaking
[22] D. Blazakis, “Interpreter exploitation,” in Proceedings of the 4th                     modern defenses,” in 23rd USENIX Security Symposium, 2014.
     USENIX Conference on Offensive Technologies, ser. WOOT’10.                        [39] A. One, “Smashing the stack for fun and profit,” Phrack magazine,
     Berkeley, CA, USA: USENIX Association, 2010, pp. 1–9. [Online].                        vol. 7, no. 49, p. 365, 1996.
     Available: http://dl.acm.org/citation.cfm?id=1925004.1925011                      [40] M. Frantzen and M. Shuey, “StackGhost: Hardware facilitated stack
[23] C. Rohlf and Y. Ivnitskiy, “Attacking clientside jit compilers,” Black Hat             protection,” in Proceedings of the 10th USENIX Security Symposium,
     USA, 2011.                                                                             August 2001, pp. 55–66.
[24] A. Homescu, S. Brunthaler, P. Larsen, and M. Franz, “Librando:
     transparent code randomization for just-in-time compilers,” in ACM                [41] P. Akritidis, C. Cadar, C. Raiciu, M. Costa, and M. Castro, “Preventing
     Conference on Computer and Communications Security, A.-R. Sadeghi,                     memory error exploits with wit,” in IEEE Symposium on Security and
     V. D. Gligor, and M. Yung, Eds. ACM, 2013, pp. 993–1004.                               Privacy, 2008, pp. 263–277.
[25] S. Checkoway, L. Davi, A. Dmitrienko, A.-R. Sadeghi, H. Shacham,                  [42] A. Slowinska, T. Stancescu, and H. Bos, “Body armor for binaries:
     and M. Winandy, “Return-oriented programming without returns,” in                      preventing buffer overflows without recompilation,” in Proceedings of
     Proceedings of the 17th ACM conference on Computer and Communi-                        USENIX Annual Technical Conference, Boston, MA, June 2012.
     cations Security, October 2010, pp. 559–72.                                       [43] M. Tran, M. Etheridge, T. Bletsch, X. Jiang, V. Freeh, and P. Ning, “On
[26] T. Bletsch, X. Jiang, V. W. Freeh, and Z. Liang, “Jump-oriented                        the expressiveness of return-into-libc attacks,” in Proceedings of the 14th
     programming: a new class of code-reuse attack,” in Proceedings of the                  international conference on Recent Advances in Intrusion Detection,
     6th ASIACCS, March 2011, pp. 30–40.                                                    2011, pp. 121–141.
[27] Microsoft, “The enhanced mitigation experience toolkit,” http://support.          [44] E. Buchanan, R. Roemer, H. Shacham, and S. Savage, “When good in-
     microsoft.com/kb/2458544.                                                              structions go bad: Generalizing return-oriented programming to RISC,”
[28] A. Portnoy, “Bypassing all of the things,” Exodus Intelligence,                        in Proceedings of CCS 2008, P. Syverson and S. Jha, Eds. ACM Press,
     https://www.exodusintel.com/files/Aaron Portnoy-Bypassing All Of                       Oct. 2008, pp. 27–38.
     The Things.pdf.                                                                   [45] H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh,
[29] F. J. Serna, “CVE-2012-0769, the case of the perfect info leak,” http:                 “On the effectiveness of address-space randomization,” in Proceedings
     //zhodiac.hispahack.com/my-stuff/security/Flash ASLR bypass.pdf.                       of the 11th ACM conference on Computer and Communications Security,
[30] DarkReading, “Heap spraying: Attackers’ latest weapon of choice,”                      2004, pp. 298–307.
     http://www.darkreading.com/security/vulnerabilities/showArticle.jhtml?            [46] R. Strackx, Y. Younan, P. Philippaerts, F. Piessens, S. Lachmund, and
     articleID=221901428, November 2009.                                                    T. Walter, “Breaking the memory secrecy assumption,” in Proceedings
[31] Lucas Davi, Ahmad-Reza Sadeghi, Daniel Lehman, and Fabian Mon-                         of the Second European Workshop on System Security, ser. EUROSEC
     rose, “Stitching the gadgets: On the ineffectiveness of coarse-grained                 ’09. New York, NY, USA: ACM, 2009, pp. 1–8. [Online]. Available:
     control-flow integrity protection,” in 23rd USENIX Security Symposium,                 http://dx.doi.org/10.1145/1519144.1519145
     2014.                                                                             [47] R. Hund, C. Willems, and T. Holz, “Practical timing side channel attacks
[32] Felix Schuster, Thomas Tendyck, Jannik Pewny, Andreas Maa, Martin                      against kernel space aslr,” in Security and Privacy (SP), 2013 IEEE
     Steegmanns, Moritz Contag, and Thorsten Holz, “Evaluating the effec-                   Symposium on. IEEE, 2013, pp. 191–205.
     tiveness of current anti-rop defenses,” in Proceedings of the Internation
                                                                                       [48] G. F. Roglia, L. Martignoni, R. Paleari, and D. Bruschi, “Surgically
     Conference on Research in Attacks, Intrusions, and Defenses (RAID),
                                                                                            returning to randomized lib (c),” in Computer Security Applications
     2014.
                                                                                            Conference, 2009. ACSAC’09. Annual. IEEE, 2009, pp. 60–69.
[33] E. J. Schwartz, T. Avgerinos, and D. Brumley, “Q: Exploit hardening
     made easy,” in Proceedings of the USENIX Security Symposium, 2011.                [49] C. Song, C. Zhang, T. Wang, W. Lee, and D. Melski, “Exploiting
[34] Microsoft MSDN, “Advances in javascript performance in ie10 and                        and protecting dynamic code generation,” in Proceedings of the 2015
     windows 8,” http://blogs.msdn.com/b/ie/archive/2012/06/13/advances-                    Network and Distributed System Security (NDSS) Symposium, February
     in-javascript-performance-in-ie10-and-windows-8.aspx.                                  2015.




                                                                                  13
