Example Jump-Oriented Programming Attack

I have been working on Jump-Oriented Programming for some time now. There are papers out there but there was no concrete code examples that you could download and play with. So, I tried to create that. I took many shortcuts and avoided actual gadget discovery parts. I copied an example, that was supposed to work as it is, found in the Technical Report by Bletsch et. al, titled "Jump-Oriented Programming: A New Class of Code-Reuse Attack". Mainly, there are two reasons why it did not work:

Overwriting the return address instead of a jump buffer

In GNU LIBC, setjmp and longjmp implementations use PTR_MANGLE/PTR_DEMANGLE, which essentially XORs the values by a random value (per process). It is not the best defense but it is something. I didn't want to deal with it and used return-oriented approach for attack initiation. I simply disabled stack canaries (-fno-stack-protector) and modified a return address.

Embedding the gadgets in vulnerable code

I was unable to locate the gadgets used in their attack. I believe I found the same libc from Debian repositories. It had the same version, same file size but it did not have the same MD5 checksum. The dispatcher gadget was of particular importance to me. So, as I was trying to locate it in the libc, I discovered that there was a similar instruction but the source and destination operands were switched. My guess is, there was some confusion about AT&T syntax vs. Intel syntax. Nevertheless, the paper is a good read and I think what matters is the concept rather than exact instructions and bytes. Since I couldn't find their instructions, I just added them to my vulnerable code and used them as they were inside libc.


The attack code can be downloaded here.

< Go back

April, 2012.