Information Leaks. Kyriakos Kyriakou

Size: px
Start display at page:

Download "Information Leaks. Kyriakos Kyriakou"

Transcription

1 Information Leaks Kyriakos Kyriakou University of Cyprus EPL 682: Advanced Security Topics 1

2 Just-in-time Code Reuse On the effectiveness of Fine-Grained Address Space Layout Randomization Kevin Z. Snow, Fabian Monrose, Lucas Davi, Alexandra Dmitrienko, Christopher Liebchen, Ahmad-Reza Sadeghi University of Cyprus EPL 682: Advanced Security Topics 2

3 Abstract University of Cyprus EPL 682: Advanced Security Topics 3

4 Fine-grained address space layout randomization (ASLR) has recently been proposed as a method of efficiently mitigating runtime attacks. University of Cyprus EPL 682: Advanced Security Topics 4

5 Solution To introduce the design and implementation of a framework based on a novel attack strategy, dubbed just-in-time code reuse, that undermines the benefits of fine-grained ASLR. University of Cyprus EPL 682: Advanced Security Topics 5

6 Fine-grained ASLR may not be as promising as first thought. University of Cyprus EPL 682: Advanced Security Topics 6

7 Historical Overview Introduction University of Cyprus EPL 682: Advanced Security Topics 7

8 Attackers ultimate goal is to exploit vulnerabilities and provide the ability to redirect program logic within the vulnerable application (ASLR, DEP) University of Cyprus EPL 682: Advanced Security Topics 8

9 Exploitation defenses practices through time Shellcode, return address, stack Overwriting alternative control-flow constructs Redirect execution to existing shared-library functions, chaining together short instruction sequences ending with ret (gadgets, ROP) Memory disclosure problem Canary NX bit ASLR? University of Cyprus EPL 682: Advanced Security Topics 9

10 Background Review the basis of important concepts University of Cyprus EPL 682: Advanced Security Topics 10

11 1 Code Reuse Attacks University of Cyprus EPL 682: Advanced Security Topics 11

12 The general principle of any code reuse attack Redirect the logical program flow to instructions already present in memory, then use those instructions to provide alternative program logic University of Cyprus EPL 682: Advanced Security Topics 12

13 Basic principle of code reuse attacks An example of a ROP attack on the heap using a sequence of single-instruction gadgets 13

14 2 Randomization for Exploit Mitigation University of Cyprus EPL 682: Advanced Security Topics 14

15 What is ASLR and how it works? University of Cyprus EPL 682: Advanced Security Topics 15

16 The basic idea of address space layout randomization (ASLR) refer to a new stack memory allocator that adds a random pad for stack objects larger than 16 bytes. Start address of an executable is relocated between consecutive runs of the application. Current ASLR schemes randomize the base (start) address of segments such as the stack, heap, libraries, and the executable itself University of Cyprus EPL 682: Advanced Security Topics 16

17 As a result, an adversary must guess the location of the functions and instruction sequences needed for successful deployment of her code reuse attack. Today, ASLR is enabled on nearly all modern operating systems such as Windows, Linux, ios, or Android. University of Cyprus EPL 682: Advanced Security Topics 17

18 Fine-Grained Memory and Code Randomization University of Cyprus EPL 682: Advanced Security Topics 18

19 Today ASLR suffer from two main problems 1. The entropy of 32bit systems is too low 2. all ASLR solutions are vulnerable to memory disclosure attacks Since current ASLR implementations only randomize on a per-module level, disclosing a single address within a module effectively reveals the location of every piece of code within that module University of Cyprus EPL 682: Advanced Security Topics 19

20 Solution To confound these attacks, a number of fine-grained ASLR and code randomization schemes have recently appeared in the academic literature University of Cyprus EPL 682: Advanced Security Topics 20

21 The underlying idea in these works is to randomize the data and code structure by shuffling functions or basic blocks (ideally for each program run) The location of all gadgets is randomized and the disclosure of a single address no longer allows an adversary to deploy a code reuse attack. University of Cyprus EPL 682: Advanced Security Topics 21

22 Assumptions and Adversarial Model University of Cyprus EPL 682: Advanced Security Topics 22

23 An adversary actions may enumerated in two stages 1. exercise a vulnerability entry point 2. execute arbitrary malicious computations Modern stack and heap mitigations do eliminate categories of attack supporting stage one, but these mitigations are not comprehensive (ie. exploitable vulnerabilities still exist) University of Cyprus EPL 682: Advanced Security Topics 23

24 Assumptions for the target platform uses the following mechanisms to mitigate the execution of malicious computations Non-Executable Memory JIT Mitigations Export Address Table Access Filtering Base Address Randomization Strong Fine-Grained ASLR randomization scheme i. Permutes the order of functions and basic blocks ii. Swaps registers and replaces instructions iii. Randomizes the location of each instruction iv. Performs randomizations upon each run of an application University of Cyprus EPL 682: Advanced Security Topics 24

25 Current Problems with ASLR not usually applied to every executable or library, thereby allowing an adversary to leverage the non-randomized code parts for a conventional code reuse attack. current systems do not enforce fine-grained randomization. University of Cyprus EPL 682: Advanced Security Topics 25

26 The trend is Enabling ASLR for all applications, even for the operating system kernel as deployed in Windows 8 University of Cyprus EPL 682: Advanced Security Topics 26

27 What the proposed framework can do or offer? even given all these fortified defenses, the framework for code reuse attacks can readily undermine the security provided by these techniques an adversary will enjoy a simpler and more streamlined exploit development process than ever before builds the entire payload on-the-fly compatible with all OS revisions. University of Cyprus EPL 682: Advanced Security Topics 27

28 We only assume that the adversary can.. 1. Conform memory disclosure vulnerability to the interface that reveals values at an absolute address 2. Discover a single code pointer University of Cyprus EPL 682: Advanced Security Topics 28

29 Overview of Just-In-Time Code Reuse JIT Code Reuse University of Cyprus EPL 682: Advanced Security Topics 29

30 Exploiting a memory disclosure multiple times.. violates implicit assumptions of the fine-grained exploit mitigation model enables the adversary to iterate over mapped memory to search for all necessary gadgets on-the-fly University of Cyprus EPL 682: Advanced Security Topics 30

31 to bypass fine-grained exploit mitigation techniques, the authors designed and built a prototype exploit framework that aptly demonstrates one instantiation, called JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 31

32 Code Injection Attack Workflow Utilizing just-in-time code reuse against a script-enabled application protected by finegrained memory (or code) randomization. 32

33 HOW? University of Cyprus EPL 682: Advanced Security Topics 33

34 A. Mapping Code Page Memory JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 34

35 Challenge 1 University of Cyprus EPL 682: Advanced Security Topics 35

36 Lies in developing a reliable method for automatically searching through memory for code without causing a crash University of Cyprus EPL 682: Advanced Security Topics 36

37 Challenge 12 University of Cyprus EPL 682: Advanced Security Topics 37

38 To enumerate any information found in this initial page of code that reliably identifies additional pages of code University of Cyprus EPL 682: Advanced Security Topics 38

39 Algorithm 1 HarvestCodePages Given an initial code page, recursively disassemble pages and discover direct and indirect pointers to other mapped code pages. It is a recursive search over discovered code pages that results in the set of unique code page virtual addresses along with associated data. Iteration continues only until all the requisite information to build a payload has been acquired. 39

40 B. API Function Discovery JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 40

41 Challenge University of Cyprus EPL 682: Advanced Security Topics 41

42 Lies in the fact that an exploit will inevitably need to interact with operating system APIs to enact any significant effect. University of Cyprus EPL 682: Advanced Security Topics 42

43 The solution The favored method of interacting with the OS is through API calls because of the relative stability across OS revisions. [as in kernel32.dll] (not system calls) Discover the virtual addresses of API Functions used in the attacker-supplied program (Step ❸) Proposed code page harvesting gives unfettered access to a large amount of application code. This offers a unique opportunity for automatically discovering a diverse set of API function pointers. (Step ❷) University of Cyprus EPL 682: Advanced Security Topics 43

44 C. Gadget Discovery JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 44

45 Thus far we have automatically mapped a significant portion of the vulnerable application s code layout and collected API function pointers required by the exploit writer s designated program. University of Cyprus EPL 682: Advanced Security Topics 45

46 Challenge University of Cyprus EPL 682: Advanced Security Topics 46

47 Lies in accumulating a set of concrete gadgets to use as building blocks for the just-in-time code reuse payload & Fine-grained exploit mitigations may metamorphose instructions on each execution. University of Cyprus EPL 682: Advanced Security Topics 47

48 The solution In Step ❹ they efficiently collect sequences of instructions by adapting the Galileo algorithm proposed by Shacham to iterate over the harvested code pages from Step ❷ and populate an instruction prefix tree structure. Using criteria for useful gadgets University of Cyprus EPL 682: Advanced Security Topics 48

49 Algorithm 2 VerifyGadget Automatically match a sequence of instructions to a gadget s semantic definition. 49

50 University of Cyprus EPL 682: Advanced Security Topics 50

51 D. Just-In-Time Compilation JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 51

52 Challenge University of Cyprus EPL 682: Advanced Security Topics 52

53 Lies in using the dynamically discovered API function pointers and collection of concrete gadgets to satisfy the exploit writer s target program (Step ❶), then generate a payload to execute (Step ❻) University of Cyprus EPL 682: Advanced Security Topics 53

54 The solution A dynamic compilation is required to ensure we can use a plethora of gadget types to build the final payload The JIT Gadget Compiler proposed is like a traditional compiler, except that compilation is embedded directly within an exploit script with a subset of concrete instructions available for code generation Next, they perform a lazy search over all possible gadget combinations that implement a program statement, as well as a search over all schedules and register combinations. The final payload is serialized to a structure accessible from the script, and control is returned to the exploit writer s code (Step ❻) University of Cyprus EPL 682: Advanced Security Topics 54

55 E. Implementation JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 55

56 University of Cyprus EPL 682: Advanced Security Topics 56

57 Evaluation JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 57

58 A. On Code Page Harvesting JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 58

59 To perform the evaluation, they used memory snapshots created using a custom library. The snapshots contain all process memory, metadata indicating if a page is marked as executable code, and auxiliary information on which pages belong to the application or a shared library. University of Cyprus EPL 682: Advanced Security Topics 59

60 University of Cyprus EPL 682: Advanced Security Topics 60

61 University of Cyprus EPL 682: Advanced Security Topics 61

62 B. On Gadget Coverage JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 62

63 They were able to find all the gadgets required in their proof of concept exploit. They found that we could generate a payload from 78% of the initial code pages, and 67% of the initial starting points additionally yielded a StackPivotG, which is required for many exploits. University of Cyprus EPL 682: Advanced Security Topics 63

64 University of Cyprus EPL 682: Advanced Security Topics 64

65 To reinforce the point that gadget discovery is not hindered by fine-grained mitigation techniques, they conducted an experiment using the in-place binary code randomizer. The framework discovers slightly more gadgets in the randomized libraries than the original unmodified DLLs. University of Cyprus EPL 682: Advanced Security Topics 65

66 C. On API Function Discovery JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 66

67 By calling VirtualProtect is the most direct way to undermine non-executable memory They found that within the Internet Explorer 8 process memory (including all libraries), there were only 15 distinct call sites to VirtualProtect. They found that call sites for LoadLibrary and GetProcAddress functions were readily available within the Internet Explorer memory 391 instances of GetProcAddress and 340 instances of LoadLibrary. University of Cyprus EPL 682: Advanced Security Topics 67

68 D. On Runtime Performance JIT-ROP University of Cyprus EPL 682: Advanced Security Topics 68

69 JIT-ROP was able to locate a pivot within 10 pages, all required APIs in 19 pages, and the requisite gadgets for a payload within 50 pages a total running time of 22.5 seconds. University of Cyprus EPL 682: Advanced Security Topics 69

70 University of Cyprus EPL 682: Advanced Security Topics 70

71 The proposed framework runs incredibly fast when natively compiled code pages are traversed, gadgets are collected, APIs are resolved, and a payload is compiled in a fraction of a second. University of Cyprus EPL 682: Advanced Security Topics 71

72 Potential Mitigations Suggestions University of Cyprus EPL 682: Advanced Security Topics 72

73 Suggestions that would render this attack ineffective Re-randomize code pages at a high rate; the disclosed pages might be re-randomized before the just-in-time pay-load executes (randomization costs problem) Fortify defenses that hinder the first stage (i.e. the entry point) of a runtime attack Apply an Instruction set randomization (ISR), which mitigates code injection attacks by encrypting the binary s code pages with a random key and decrypting them on-the-fly. To prevent control-flow attacks is the enforcement of controlflow integrity (CFI), which mitigates runtime attacks regardless of whether the program suffers from vulnerabilities. University of Cyprus EPL 682: Advanced Security Topics 73

74 Conclusion University of Cyprus EPL 682: Advanced Security Topics 74

75 In this paper, they introduce a novel framework that undermines fine-grained randomization techniques by using a just-in-time code reuse strategy. They repeatedly abuse a memory disclosure to map an application s memory layout on-the-fly. It dynamically discover API functions and gadgets, and JIT-compile a target program using those gadgets all within a script environment at the time an exploit is launched. University of Cyprus EPL 682: Advanced Security Topics 75

76 Moving on University of Cyprus EPL 682: Advanced Security Topics 76

77 Hacking Blind Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh University of Cyprus EPL 682: Advanced Security Topics 77

78 Abstract University of Cyprus EPL 682: Advanced Security Topics 78

79 Return Oriented Programming (ROP) The attacker knows the location of useful gadgets, because binary and distribution are available University of Cyprus EPL 682: Advanced Security Topics 79

80 What if the binary remains unknown to the attacker? University of Cyprus EPL 682: Advanced Security Topics 80

81 It is possible to write remote stack buffer overflow exploits without possessing a copy of the target binary or source code, against services that restart after a crash. University of Cyprus EPL 682: Advanced Security Topics 81

82 Solution Blind ROP (BROP) attack remotely finds enough ROP gadgets to perform a write system call and transfers the vulnerable binary over the network, after which an exploit can be completed using known techniques. University of Cyprus EPL 682: Advanced Security Topics 82

83 The source code is available for everyone Open Source is most within reach Attackers can audit the code to find vulnerabilities Usually proprietary software that none has access to see the source code Hacking this software is also possible, but harder Attackers can use fuzz testing and reverse engineering University of Cyprus EPL 682: Advanced Security Topics 83

84 Simplest possible vulnerability: Stack buffer Overflows bugs such as these go unnoticed in proprietary software, where the source (and binary) has not been under the heavy scrutiny of the public and security specialists University of Cyprus EPL 682: Advanced Security Topics 84

85 Challenge University of Cyprus EPL 682: Advanced Security Topics 85

86 Lies in developing a methodology for exploiting these vulnerabilities when information about the target binary is limited University of Cyprus EPL 682: Advanced Security Topics 86

87 One advantage attackers often have Many servers restart their worker processes after a crash for robustness University of Cyprus EPL 682: Advanced Security Topics 87

88 They present a new attack, Blind Return Oriented Programming (BROP), that takes advantage of these situations to build exploits for proprietary services for which both the binary and source are unknown. University of Cyprus EPL 682: Advanced Security Topics 88

89 BROP attack assumptions A server application with stack vulnerability One that is restarted after a crash Runs 64-bit Linux with ASLR, non-executable (NX) memory, and stack canaries enabled University of Cyprus EPL 682: Advanced Security Topics 89

90 Position Independent Executables (PIE) are an output of the hardened package build process. A PIE binary and all of its dependencies are loaded into random locations within virtual memory each time the application is executed. University of Cyprus EPL 682: Advanced Security Topics 90

91 The attack is enabled by two new techniques 1. Generalized stack reading: this generalizes a known technique, used to leak canaries, to also leak saved return addresses in order to defeat ASLR on 64-bit even when Position Independent Executables (PIE) are used 2. Blind ROP: this technique remotely locates ROP gadgets Both techniques share the idea of using a single stack vulnerability to leak information based on whether a server process crashes or not. The stack reading technique overwrites the stack byte-by-byte with possible guess values, until the correct one is found and the server does not crash. University of Cyprus EPL 682: Advanced Security Topics 91

92 The Blind ROP attack remotely finds enough gadgets to perform the write system call, after which the server s binary can be transferred from memory to the attacker s socket. At this point, canaries, ASLR and NX have been defeated and the exploit can proceed using known techniques. University of Cyprus EPL 682: Advanced Security Topics 92

93 The BROP attack enables robust, general-purpose exploits for three new scenarios: 1. Hacking proprietary closed-binary services One may notice a crash when using a remote service or discover one through remote fuzz testing. 2. Hacking a vulnerability in an open-source library thought to be used in a proprietary closed-binary service A popular SSL library for example may have a stack vulnerability and one may speculate that it is being used by a proprietary service. 3. Hacking an open-source server for which the binary is unknown This applies to manually compiled installations or source-based distributions such as Gentoo University of Cyprus EPL 682: Advanced Security Topics 93

94 Braille makes BROP attacks highly automated University of Cyprus EPL 682: Advanced Security Topics 94

95 Their overall contribution 1. A technique to defeat ASLR on servers (generalized stack reading). 2. A technique to remotely find ROP gadgets (BROP) so that software can be attacked when the binary is unknown. 3. Braille: a tool that automatically constructs an exploit given input on how to trigger a stack overflow on a server 4. The first public exploit for nginx s recent vulnerability, that is generic, 64-bit, and defeats (full/pie) ASLR, canaries and NX. University of Cyprus EPL 682: Advanced Security Topics 95

96 Their overall contribution 5. Suggestions for defending against BROP attacks. In summary, ASLR must be applied to all executable segments (PIE) and re-randomization must occur after each crash (at odds with fork-only servers). Holding the binary from the attacker or purposefully altering it may not be an effective security countermeasure. University of Cyprus EPL 682: Advanced Security Topics 96

97 Historical Overview University of Cyprus EPL 682: Advanced Security Topics 97

98 Exploitation defenses practices through time Shellcode, return address, stack Structured exception handlers (SEH) Redirect execution to existing shared-library functions, chaining together short instruction sequences ending with ret (gadgets, ROP) Memory disclosure problem Canary NX bit ASLR? University of Cyprus EPL 682: Advanced Security Topics 98

99 ROP Tutorial University of Cyprus EPL 682: Advanced Security Topics 99

100 University of Cyprus EPL 682: Advanced Security Topics 100

101 University of Cyprus EPL 682: Advanced Security Topics 101

102 Buffer Overflows Today University of Cyprus EPL 682: Advanced Security Topics 102

103 An attacker must fulfill at least two requirements in order to gain full control of a remote program s execution: 1. To defeat NX, the attacker must know where gadgets reside inside the program executable 2. To defeat ASLR, the attacker must de-randomize the location at which the executable s text segment is actually loaded in memory University of Cyprus EPL 682: Advanced Security Topics 103

104 The proposed stack reading technique makes it possible to attack PIE servers that do not rerandomize after crash. University of Cyprus EPL 682: Advanced Security Topics 104

105 University of Cyprus EPL 682: Advanced Security Topics 105

106 BROP Environment University of Cyprus EPL 682: Advanced Security Topics 106

107 BROP attack makes the following assumptions and requires the following environment: A stack vulnerability and knowledge of how to trigger it A server application that restarts after a crash What s the thread model? University of Cyprus EPL 682: Advanced Security Topics 107

108 The thread model is an attacker that.. knows an input string that crashes a server due to a stack overflow bug is able to overwrite a variable length of bytes including a return instruction pointer knows the source or binary of the server is able to crash the server as many times as he wishes while conducting the attack, and the server must restart is able to distinguish when a server crashes prematurely, e.g., by noticing that the socket closes without receiving a response If the server is compiled with the PIE flag, the server must be a forking daemon and must restart without using execve. The same is true for overflows where the canary must be modified by the exploit. University of Cyprus EPL 682: Advanced Security Topics 108

109 Attack Outline University of Cyprus EPL 682: Advanced Security Topics 109

110 The BROP attack has the following phases: 1. Stack reading: read the stack to leak canaries and a return address to defeat ASLR 2. Blind ROP: find enough gadgets to invoke write and control its arguments 3. Build the exploit: dump enough of the binary to find enough gadgets to build a shellcode, and launch the final exploit University of Cyprus EPL 682: Advanced Security Topics 110

111 Stack Reading: ASLR de-randomization University of Cyprus EPL 682: Advanced Security Topics 111

112 Exploits must have a method of defeating ASLR for configurations where PIE is used. They present a new stack reading technique that generalizes a known technique used for leaking canaries. University of Cyprus EPL 682: Advanced Security Topics 112

113 The basic idea 1. Overflow a single byte of the canary with value x 2. If x is correct, the server does not crash 3. The algorithm is repeated for all possible 256 byte values until it is found (128 tries on average) 4. The attack continues for the next byte until all 8 canary bytes (on 64-bit) are leaked University of Cyprus EPL 682: Advanced Security Topics 113

114 University of Cyprus EPL 682: Advanced Security Topics 114

115 University of Cyprus EPL 682: Advanced Security Topics 115

116 BROP Attack University of Cyprus EPL 682: Advanced Security Topics 116

117 BROP Attack Allows writing exploits without possessing the target binary. It introduces techniques to find ROP gadgets remotely and optimizations to make the attack practical. University of Cyprus EPL 682: Advanced Security Topics 117

118 BROP Attack Outline A. The pieces of a puzzle B. Finding gadgets and the stop gadget C. Identifying gadgets D. Finding the Procedure Linking Table (PLT) E. Controlling rdx via strcmp F. Finding write G. Concluding the attack H. Attack Summary I. First principles attack J. Other low-level details University of Cyprus EPL 682: Advanced Security Topics 118

119 A. The pieces of a puzzle University of Cyprus EPL 682: Advanced Security Topics 119

120 The goal is to find enough gadgets to invoke write University of Cyprus EPL 682: Advanced Security Topics 120

121 The write system call takes three arguments: a socket, a buffer and a length Arguments are passed in rdi, rsi and rdx registers, and the system call number is stored in the rax register. University of Cyprus EPL 682: Advanced Security Topics 121

122 The following gadgets are therefore needed: 1. pop rdi; ret (socket) 2. pop rsi; ret (buffer) 3. pop rdx; ret (length) 4. pop rax; ret (write syscall number) 5. syscall University of Cyprus EPL 682: Advanced Security Topics 122

123 University of Cyprus EPL 682: Advanced Security Topics 123

124 University of Cyprus EPL 682: Advanced Security Topics 124

125 The optimized attack therefore requires: 1. Finding the BROP gadget 2. Finding the PLT. Finding the entry for write. Finding the entry for strcmp. University of Cyprus EPL 682: Advanced Security Topics 125

126 B. Finding Gadgets University of Cyprus EPL 682: Advanced Security Topics 126

127 The basic idea in finding gadgets remotely is to scan the application s text segment by overwriting the saved return address with an address pointing to text and inspecting program behavior. A stop gadget is anything that would cause the program to block, like an infinite loop or a blocking system call (like sleep). University of Cyprus EPL 682: Advanced Security Topics 127

128 University of Cyprus EPL 682: Advanced Security Topics 128

129 C. Identifying Gadgets University of Cyprus EPL 682: Advanced Security Topics 129

130 How to classify gadgets? By controlling the stack layout and inspecting program behavior University of Cyprus EPL 682: Advanced Security Topics 130

131 We define three values that the attacker can place on the stack: Probe Stop Trap The address of the gadget being scanned. The address of a stop gadget that will not crash The address of non-executable memory that will cause a crash (e.g., 0x0). University of Cyprus EPL 682: Advanced Security Topics 131

132 The idea is that by varying the position of the stop and trap on the stack, one can deduce the instructions being executed by the gadget, either because the trap or stop will execute, causing a crash or no crash respectively. University of Cyprus EPL 682: Advanced Security Topics 132

133 Here are some examples and possible stack layouts: probe, stop, traps (trap, trap,... ) Will find gadgets that do not pop the stack like ret or xor rax, rax; ret probe, trap, stop, traps Will find gadgets that pop exactly one stack word like pop rax; ret or pop rdi; ret probe, stop, stop, stop, stop, stop, stop, stop, traps Will find gadgets that pop up to six words (e.g., the BROP gadget) University of Cyprus EPL 682: Advanced Security Topics 133

134 University of Cyprus EPL 682: Advanced Security Topics 134

135 D. Finding the Procedure Linking Table (PTL) University of Cyprus EPL 682: Advanced Security Topics 135

136 To control the third argument (rdx) one needs to find a call to strcmp, which sets rdx to the length of the string compared. The PLT is a jump table at the beginning of the executable used for all external calls (e.g., libc). University of Cyprus EPL 682: Advanced Security Topics 136

137 University of Cyprus EPL 682: Advanced Security Topics 137

138 Most of the PLT entries will not cause a crash regardless of arguments because they are system calls that return EFAULT on invalid parameters. The stack layout to find a PLT entry will be: probe, stop, trap. University of Cyprus EPL 682: Advanced Security Topics 138

139 E. Controlling rdx via strcmp University of Cyprus EPL 682: Advanced Security Topics 139

140 The attacker can identify PLT entries by exercising each entry with different arguments and seeing how the function performs. The first two arguments can be controlled thanks to the BROP gadget. University of Cyprus EPL 682: Advanced Security Topics 140

141 strcmp for example has the following behavior and signature, where bad is an invalid memory location (e.g., 0x0) and readable is a readable pointer (e.g., an address in.text): strcmp(bad, bad): crash strcmp(bad, readable): crash strcmp(readable, bad): crash strcmp(readable, readable): no crash The attacker finds strcmp by finding an entry that responds to the previously mentioned signature. University of Cyprus EPL 682: Advanced Security Topics 141

142 F. Finding write University of Cyprus EPL 682: Advanced Security Topics 142

143 The attacker so far can control the first three arguments to any call: the first two via the BROP gadget, and the third one indirectly via strcmp. write can now trivially be found by scanning each PLT entry and forcing a write to the socket and checking whether the write occurred. University of Cyprus EPL 682: Advanced Security Topics 143

144 The only complication is figuring out the file descriptor number for the socket. There are two approaches: 1. chaining multiple writes each with different file descriptor numbers in a single ROP chain, or 2. opening multiple connections and using a relatively high file descriptor number in hope that it will match one of the connections. They use both techniques in combination. University of Cyprus EPL 682: Advanced Security Topics 144

145 G. Concluding the attack University of Cyprus EPL 682: Advanced Security Topics 145

146 At this point the attacker can write the entire.text segment from memory to the attacker s socket, disassemble it, and find more gadgets. The attacker can also dump the symbol table and find useful functions in the PLT like dup2 and execve. University of Cyprus EPL 682: Advanced Security Topics 146

147 Generally speaking the attacker will need to: 1. Redirect the socket to standard input / output The attacker can use dup2 or close, followed by either dup or fcntl(f_dupfd). These are often in the PLT. 2. Find /bin/sh in memory An effective technique is to find a writable memory region like the environment, environ, from the symbol table, and read /bin/sh from the attacker s socket to that address. 3. execve the shell If execve is not in the PLT, the attacker will need to transfer more of the binary to find a pop rax; ret and syscall gadget. University of Cyprus EPL 682: Advanced Security Topics 147

148 H. Attack summary University of Cyprus EPL 682: Advanced Security Topics 148

149 The optimized BROP attack is as follows: 1. Find where the executable is loaded. Either 0x for non-pie executables (default) or stack read a saved return address. 2. Find a stop gadget. This is typically a blocking system call (like sleep or read) in the PLT. The attacker finds the PLT in this step too. 3. Find the BROP gadget. The attacker can now control the first two arguments to calls. 4. Find strcmp in the PLT. The attacker can now control the first three arguments to calls. 5. Find write in the PLT. The attacker can now dump the entire binary to find more gadgets. 6. Build a shellcode and exploit the server. University of Cyprus EPL 682: Advanced Security Topics 149

150 I. First principles attack University of Cyprus EPL 682: Advanced Security Topics 150

151 The attack outline: 1. Find all pop x; ret gadgets. 2. Find a syscall gadget. 3. Identify the pop gadgets previously found University of Cyprus EPL 682: Advanced Security Topics 151

152 The attack outline: The attacker starts by finding a stop gadget and all pop x; ret instructions. The difficulty is now in identifying the pop instructions and finding a syscall gadget. The idea is to identify the pop instructions based on system call behavior after tweaking system call arguments, in a similar way as to how strcmp was found in the optimized attack. University of Cyprus EPL 682: Advanced Security Topics 152

153 There is a bootstrap problem because to find syscall one must control the system call number (rax), so one must have a priori identified pop rax; ret University of Cyprus EPL 682: Advanced Security Topics 153

154 The solution Chain all pop instructions found by the attacker, popping the desired system call number, and one of them will likely be rax The system call to use is pause() which takes no arguments and so ignores all other registers. It also stops program execution until a signal is raised and so it acts as a stop gadget, making it identifiable The attacker can now append the probe address for syscall to the pop chain to find a system call gadget Once an address that makes the program pause is found, the attacker can eliminate the pops one by one to find which one controls rax University of Cyprus EPL 682: Advanced Security Topics 154

155 At this point the attacker has the address of a syscall gadget and a pop rax; ret gadget. University of Cyprus EPL 682: Advanced Security Topics 155

156 The attacker also holds a list of unidentified pops. These are identified by using the following system calls University of Cyprus EPL 682: Advanced Security Topics 156

157 One can now call write and continue the attack by dumping the.text segment and finding more gadgets University of Cyprus EPL 682: Advanced Security Topics 157

158 J. Other low level details University of Cyprus EPL 682: Advanced Security Topics 158

159 In this section they list a number of not so obvious low-level attack details, many of which added to the attack s stability: a) Stack reading with zeros b) Further strcmp verification c) Dealing with small buffers d) Dealing with few event-based workers University of Cyprus EPL 682: Advanced Security Topics 159

160 Implementation University of Cyprus EPL 682: Advanced Security Topics 160

161 The BROP attack was implemented in a tool called Braille that automatically goes from a crash to a remote shell. It is written in 2,000 lines of Ruby code. Braille is essentially a meta-exploit that takes a driver function that can crash a server, and figures out all the information needed to build an exploit. University of Cyprus EPL 682: Advanced Security Topics 161

162 Evaluation University of Cyprus EPL 682: Advanced Security Topics 162

163 The BROP attack was tested in three scenarios: 1. An open-source SSL library with a known stack vulnerability (yassl). This mimics the scenario where one is attacking a proprietary service that is believed to use a vulnerable open-source component. As a sample target we used an older version of MySQL that used yassl. 2. An open-source software with a known stack vulnerability (nginx), manually compiled from source. In this scenario the attacker knows the source of the entire server but does not hold the binary. 3. A toy closed-binary proprietary service with a stack vulnerability. This was written by a colleague and both the binary and source were kept secret. Ideally we would have tested this against a real-world proprietary service but it would have been difficult to do so legally University of Cyprus EPL 682: Advanced Security Topics 163

164 They ran Braille against all three attack scenarios, without any application-specific optimizations, and the attack succeeded in all cases. University of Cyprus EPL 682: Advanced Security Topics 164

165 Evaluation aspects 1. Performance: number of requests and time. 2. Stability: how robust the attack is. 3. Attack paired with source-code knowledge: whether having access to the source code (but not the binary) can make the attack better University of Cyprus EPL 682: Advanced Security Topics 165

166 University of Cyprus EPL 682: Advanced Security Topics 166

167 University of Cyprus EPL 682: Advanced Security Topics 167

168 Limitations University of Cyprus EPL 682: Advanced Security Topics 168

169 The BROP Attack has its limitations Applied only to simple stack overflows. Stack reading assumes that the attacker can overflow at a byte granularity and controls the last byte being overflown. Assumes that the same machine and process can be hit after each attempt. Relies on a number of workers being available and not ending up in a situation where all workers become stuck in an infinite loop. University of Cyprus EPL 682: Advanced Security Topics 169

170 BROP Prevention University of Cyprus EPL 682: Advanced Security Topics 170

171 Defenses mechanisms that will prevent the BROP Attack A. Rerandomization The most basic protection against the BROP attack is to rerandomize canaries and ASLR as often as possible. It is important that any child processes forked are randomized independently so that any information learned from one child cannot be used against another one. They suggest servers write a new canary before entering a per-request function. University of Cyprus EPL 682: Advanced Security Topics 171

172 Defenses mechanisms that will prevent the BROP Attack B. Sleep on crash In some situations, servers should not respawn, but in practice users and developers find this an unacceptable solution. Modern Linux desktops use systemd to monitor services and automatically restart services on failures. Developers should be cautious about which remote services they really need or want to restart automatically to reduce the attack surface. University of Cyprus EPL 682: Advanced Security Topics 172

173 Defenses mechanisms that will prevent the BROP Attack C. ROP protections Control Flow Integrity (CFI), prevents return oriented programming in general by enforcing the control flow graph. There are many other similar techniques that can be applied. University of Cyprus EPL 682: Advanced Security Topics 173

174 Defenses mechanisms that will prevent the BROP Attack D. Compiler Techniques Many modern compilers support inserting runtime bounds checks on buffers. University of Cyprus EPL 682: Advanced Security Topics 174

175 The main problem with all these solutions is that they may suffer as much as a 2x performance slowdown, and as such they are used mostly for testing University of Cyprus EPL 682: Advanced Security Topics 175

176 Conclusion University of Cyprus EPL 682: Advanced Security Topics 176

177 They show that, under the right conditions, it is possible to write exploits without any knowledge of the target binary or source code University of Cyprus EPL 682: Advanced Security Topics 177

178 To sum up 1. Their attack is able to defeat ASLR, NX and stack canaries on modern 64-bit Linux servers 2. They present two new techniques: a) generalized stack reading: which defeats full ASLR on 64-bit systems b) BROP attack: which is able to remotely find ROP gadgets. 3. Braille, can take under 4,000 requests to spawn a shell, under 20 minutes, tested against real versions of yassl+mysql and nginx with known vulnerabilities, and a toy proprietary service running an unknown binary University of Cyprus EPL 682: Advanced Security Topics 178

179 To sum up 4. ASLR is only effective when it is applied to all code segments in the binary (including PIE) 5. Security through obscurity, where the binary is unknown or randomized, can only slow but not prevent buffer overflow attacks 6. To defend against their attack, they suggest that systems should rerandomize ASLR and canaries after any crash, and that no library or executable should be exempt from ASLR University of Cyprus EPL 682: Advanced Security Topics 179

180 Thank you for your time Feel free to ask any questions University of Cyprus EPL 682: Advanced Security Topics 180

Hacking Blind BROP. Presented by: Brooke Stinnett. Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh

Hacking Blind BROP. Presented by: Brooke Stinnett. Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh Hacking Blind BROP Presented by: Brooke Stinnett Article written by: Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazie`res, Dan Boneh Overview Objectives Introduction to BROP ROP recap BROP key phases

More information

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University Hacking Blind Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh Stanford University Hacking 101 Exploit GET /0xDEAD HTTP/1.0 shell $ cat /etc/passwd root:x:0:0:::/bin/sh sorbo:x:6:9:pac:/bin/sh

More information

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University

Hacking Blind. Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh. Stanford University Hacking Blind Andrea Bittau, Adam Belay, Ali Mashtizadeh, David Mazières, Dan Boneh Stanford University Abstract We show that it is possible to write remote stack buffer overflow exploits without possessing

More information

Inject malicious code Call any library functions Modify the original code

Inject malicious code Call any library functions Modify the original code Inject malicious code Call any library functions Modify the original code 2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks 2 3 Sadeghi, Davi TU Darmstadt

More information

It s a TRaP: Table Randomization and Protection against Function-Reuse Attacks

It s a TRaP: Table Randomization and Protection against Function-Reuse Attacks It s a TRaP: Table Randomization and Protection against Function-Reuse Attacks Stephen Crane, Stijn Volckaert, Felix Schuster, Christopher Liebchen, Per Larsen, Lucas Davi, Ahmad-Reza Sadeghi, Thorsten

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2017 CS 161 Computer Security Discussion 2 Question 1 Software Vulnerabilities (15 min) For the following code, assume an attacker can control the value of basket passed into eval basket.

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2011 CS 161 Computer Security Discussion 1 January 26, 2011 Question 1 Buffer Overflow Mitigations Buffer overflow mitigations generally fall into two categories: (i) eliminating the cause

More information

CSE 127: Computer Security. Memory Integrity. Kirill Levchenko

CSE 127: Computer Security. Memory Integrity. Kirill Levchenko CSE 127: Computer Security Memory Integrity Kirill Levchenko November 18, 2014 Stack Buffer Overflow Stack buffer overflow: writing past end of a stackallocated buffer Also called stack smashing One of

More information

Software Security II: Memory Errors - Attacks & Defenses

Software Security II: Memory Errors - Attacks & Defenses 1 Software Security II: Memory Errors - Attacks & Defenses Chengyu Song Slides modified from Dawn Song 2 Administrivia Lab1 Writeup 3 Buffer overflow Out-of-bound memory writes (mostly sequential) Allow

More information

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable)

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable) Software Security Requirements General Methodologies Hardware Firmware Software Protocols Procedure s Applications OS Cloud Attack Trees is one of the inside requirement 1. Attacks 2. Evaluation 3. Mitigation

More information

PRACTICAL CONTROL FLOW INTEGRITY & RANDOMIZATION FOR BINARY EXECUTABLES

PRACTICAL CONTROL FLOW INTEGRITY & RANDOMIZATION FOR BINARY EXECUTABLES PRACTICAL CONTROL FLOW INTEGRITY & RANDOMIZATION FOR BINARY EXECUTABLES Christos Tselas, AM:875 Elisjana Ymeralli, AM:801 Ioanna Ramoutsaki, AM: 812 Vasilis Glabedakis, AM: 2921 cs-457 Department: Computer

More information

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Return-oriented Programming Professor Trent Jaeger 1 Anatomy of Control-Flow Exploits 2 Anatomy of Control-Flow Exploits Two steps in control-flow

More information

Shuffler: Fast and Deployable Continuous Code Re-Randomization

Shuffler: Fast and Deployable Continuous Code Re-Randomization Shuffler: Fast and Deployable Continuous Code Re-Randomization David Williams-King, Graham Gobieski, Kent Williams-King, James P. Blake, Xinhao Yuan, Patrick Colp, Michelle Zheng, Vasileios P. Kemerlis,

More information

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras Week 08 Lecture 38 Preventing Buffer Overflow Attacks Hello.

More information

Outline. Format string attack layout. Null pointer dereference

Outline. Format string attack layout. Null pointer dereference CSci 5271 Introduction to Computer Security Day 5: Low-level defenses and counterattacks Stephen McCamant University of Minnesota, Computer Science & Engineering Null pointer dereference Format string

More information

Isomeron: Code Randomization Resilient to (Just-In-Time) Return-Oriented Programming

Isomeron: Code Randomization Resilient to (Just-In-Time) Return-Oriented Programming Isomeron: Code Randomization Resilient to (Just-In-Time) Return-Oriented Programming Lucas Davi, Christopher Liebchen, Ahmad-Reza Sadeghi CASED/Technische Universität Darmstadt, Germany Email: {lucas.davi,christopher.liebchen,

More information

Outline. Heap meta-data. Non-control data overwrite

Outline. Heap meta-data. Non-control data overwrite Outline CSci 5271 Introduction to Computer Security Day 5: Low-level defenses and counterattacks Stephen McCamant University of Minnesota, Computer Science & Engineering Non-control data overwrite Heap

More information

Return-orientated Programming

Return-orientated Programming Return-orientated Programming or The Geometry of Innocent Flesh on the Bone: Return-into-libc without Function Calls (on the x86) Hovav Shacham, CCS '07 Return-Oriented oriented Programming programming

More information

Vulnerability Analysis I:

Vulnerability Analysis I: Vulnerability Analysis I: Exploit Hardening Made Easy Surgically Returning to Randomized Lib(c) Mitchell Adair September 9 th, 2011 Outline 1 Background 2 Surgically Returning to Randomized lib(c) 3 Exploit

More information

Software Vulnerabilities August 31, 2011 / CS261 Computer Security

Software Vulnerabilities August 31, 2011 / CS261 Computer Security Software Vulnerabilities August 31, 2011 / CS261 Computer Security Software Vulnerabilities...1 Review paper discussion...2 Trampolining...2 Heap smashing...2 malloc/free...2 Double freeing...4 Defenses...5

More information

The Geometry of Innocent Flesh on the Bone

The Geometry of Innocent Flesh on the Bone The Geometry of Innocent Flesh on the Bone Return-into-libc without Function Calls (on the x86) Hovav Shacham hovav@cs.ucsd.edu CCS 07 Technical Background Gadget: a short instructions sequence (e.x. pop

More information

Just-in-Time Code Reuse

Just-in-Time Code Reuse Just-in-Time Code Reuse The more things change, the more they stay the same Kevin Z. Snow 1 Luca Davi 2 & A. Dmitrienko 2 C. Liebchen 2 F. Monrose 1 A.-R. Sadeghi 2 1 Department of Computer Science University

More information

Is Exploitation Over? Bypassing Memory Protections in Windows 7

Is Exploitation Over? Bypassing Memory Protections in Windows 7 Is Exploitation Over? Bypassing Memory Protections in Windows 7 Alexander Sotirov alex@sotirov.net About me Exploit development since 1999 Published research into reliable exploitation techniques: Heap

More information

Inline Reference Monitoring Techniques

Inline Reference Monitoring Techniques Inline Reference Monitoring Techniques In the last lecture, we started talking about Inline Reference Monitors. The idea is that the policy enforcement code runs with the same address space as the code

More information

SoK: Eternal War in Memory

SoK: Eternal War in Memory SoK: Eternal War in Memory László Szekeres, Mathias Payer, Tao Wei, Dawn Song Presenter: Wajih 11/7/2017 Some slides are taken from original S&P presentation 1 What is SoK paper? Systematization of Knowledge

More information

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Module: Return-oriented Programming. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Return-oriented Programming Professor Trent Jaeger 1 1 Anatomy of Control-Flow Exploits Two steps in control-flow exploitation First -- attacker

More information

CNIT 127: Exploit Development. Ch 14: Protection Mechanisms. Updated

CNIT 127: Exploit Development. Ch 14: Protection Mechanisms. Updated CNIT 127: Exploit Development Ch 14: Protection Mechanisms Updated 3-25-17 Topics Non-Executable Stack W^X (Either Writable or Executable Memory) Stack Data Protection Canaries Ideal Stack Layout AAAS:

More information

Software Security: Buffer Overflow Defenses

Software Security: Buffer Overflow Defenses CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Defenses Fall 2017 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann, Dan Halperin,

More information

CSE 127: Computer Security Control Flow Hijacking. Kirill Levchenko

CSE 127: Computer Security Control Flow Hijacking. Kirill Levchenko CSE 127: Computer Security Control Flow Hijacking Kirill Levchenko October 17, 2017 Control Flow Hijacking Defenses Avoid unsafe functions Stack canary Separate control stack Address Space Layout Randomization

More information

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned Other array problems CSci 5271 Introduction to Computer Security Day 4: Low-level attacks Stephen McCamant University of Minnesota, Computer Science & Engineering Missing/wrong bounds check One unsigned

More information

Advanced Systems Security: Program Diversity

Advanced Systems Security: Program Diversity Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA Advanced Systems Security:

More information

Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit

Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit about a generic way to exploit Linux targets written by Kingcope Introduction In May 2013 a security advisory was announced

More information

Lecture 08 Control-flow Hijacking Defenses

Lecture 08 Control-flow Hijacking Defenses Lecture 08 Control-flow Hijacking Defenses Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Slides adapted from Miller, Bailey, and Brumley Control Flow Hijack: Always control + computation

More information

Bypassing Browser Memory Protections

Bypassing Browser Memory Protections Bypassing Browser Memory Protections Network Security Instructor: Dr. Shishir Nagaraja September 10, 2011. 1 Introduction to the topic A number of memory protection mechanisms like GS, SafeSEH, DEP and

More information

This time. Defenses and other memory safety vulnerabilities. Everything you ve always wanted to know about gdb but were too afraid to ask

This time. Defenses and other memory safety vulnerabilities. Everything you ve always wanted to know about gdb but were too afraid to ask This time We will continue Buffer overflows By looking at Overflow Defenses and other memory safety vulnerabilities Everything you ve always wanted to know about gdb but were too afraid to ask Overflow

More information

Practical and Efficient Exploit Mitigation for Embedded Devices

Practical and Efficient Exploit Mitigation for Embedded Devices Practical and Efficient Exploit Mitigation for Embedded Devices Matthias Neugschwandtner IBM Research, Zurich Collin Mulliner Northeastern University, Boston Qualcomm Mobile Security Summit 2015 1 Embedded

More information

6.858 Lecture 3. char *p = malloc(256); char *q = p + 256; char ch = *q; //Does this raise an exception? //Hint: How big is the baggy bound for p?

6.858 Lecture 3. char *p = malloc(256); char *q = p + 256; char ch = *q; //Does this raise an exception? //Hint: How big is the baggy bound for p? Baggy bounds continued: Example code (assume that slot_size=16) 6.858 Lecture 3 char *p = malloc(44); //Note that the nearest power of 2 (i.e., //64 bytes) are allocated. So, there are //64/(slot_size)

More information

Defeating Code Reuse Attacks with Minimal Tagged Architecture. Samuel Fingeret. B.S., Massachusetts Institute of Technology (2014)

Defeating Code Reuse Attacks with Minimal Tagged Architecture. Samuel Fingeret. B.S., Massachusetts Institute of Technology (2014) Defeating Code Reuse Attacks with Minimal Tagged Architecture by Samuel Fingeret B.S., Massachusetts Institute of Technology (2014) Submitted to the Department of Electrical Engineering and Computer Science

More information

Lecture 10 Code Reuse

Lecture 10 Code Reuse Lecture 10 Code Reuse Computer and Network Security 4th of December 2017 Computer Science and Engineering Department CSE Dep, ACS, UPB Lecture 10, Code Reuse 1/23 Defense Mechanisms static & dynamic analysis

More information

Lecture Embedded System Security A. R. Darmstadt, Runtime Attacks

Lecture Embedded System Security A. R. Darmstadt, Runtime Attacks 2 ARM stands for Advanced RISC Machine Application area: Embedded systems Mobile phones, smartphones (Apple iphone, Google Android), music players, tablets, and some netbooks Advantage: Low power consumption

More information

Survey of Cyber Moving Targets. Presented By Sharani Sankaran

Survey of Cyber Moving Targets. Presented By Sharani Sankaran Survey of Cyber Moving Targets Presented By Sharani Sankaran Moving Target Defense A cyber moving target technique refers to any technique that attempts to defend a system and increase the complexity of

More information

Honours/Master/PhD Thesis Projects Supervised by Dr. Yulei Sui

Honours/Master/PhD Thesis Projects Supervised by Dr. Yulei Sui Honours/Master/PhD Thesis Projects Supervised by Dr. Yulei Sui Projects 1 Information flow analysis for mobile applications 2 2 Machine-learning-guide typestate analysis for UAF vulnerabilities 3 3 Preventing

More information

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract Play with FILE Structure Yet Another Binary Exploitation Technique An-Jie Yang (Angelboy) angelboy@chroot.org Abstract To fight against prevalent cyber threat, more mechanisms to protect operating systems

More information

Robust Shell Code Return Oriented Programming and HeapSpray. Zhiqiang Lin

Robust Shell Code Return Oriented Programming and HeapSpray. Zhiqiang Lin CS 6V81-05: System Security and Malicious Code Analysis Robust Shell Code Return Oriented Programming and HeapSpray Zhiqiang Lin Department of Computer Science University of Texas at Dallas April 16 th,

More information

Isomeron: Code Randomization Resilient to (Just-In-Time) Return-Oriented Programming

Isomeron: Code Randomization Resilient to (Just-In-Time) Return-Oriented Programming Isomeron: Code Randomization Resilient to (Just-In-Time) Return-Oriented Programming Lucas Davi, Christopher Liebchen, Ahmad-Reza Sadeghi CASED/Technische Universität Darmstadt, Germany Email: {lucas.davi,christopher.liebchen,

More information

Buffer overflow background

Buffer overflow background and heap buffer background Comp Sci 3600 Security Heap Outline and heap buffer Heap 1 and heap 2 3 buffer 4 5 Heap Outline and heap buffer Heap 1 and heap 2 3 buffer 4 5 Heap Address Space and heap buffer

More information

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks

2 Sadeghi, Davi TU Darmstadt 2012 Secure, Trusted, and Trustworthy Computing Chapter 6: Runtime Attacks Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include injection of malicious code Reasons for runtime attacks

More information

Lecture 1: Buffer Overflows

Lecture 1: Buffer Overflows CS5431 Computer Security Practicum Spring 2017 January 27, 2017 1 Conficker Lecture 1: Buffer Overflows Instructor: Eleanor Birrell In November 2008, a new piece of malware was observed in the wild. This

More information

kguard++: Improving the Performance of kguard with Low-latency Code Inflation

kguard++: Improving the Performance of kguard with Low-latency Code Inflation kguard++: Improving the Performance of kguard with Low-latency Code Inflation Jordan P. Hendricks Brown University Abstract In this paper, we introduce low-latency code inflation for kguard, a GCC plugin

More information

Countermeasures in Modern Operating Systems. Yves Younan, Vulnerability Research Team (VRT)

Countermeasures in Modern Operating Systems. Yves Younan, Vulnerability Research Team (VRT) Countermeasures in Modern Operating Systems Yves Younan, Vulnerability Research Team (VRT) Introduction Programs in C/C++: memory error vulnerabilities Countermeasures (mitigations): make exploitation

More information

Remix: On-demand Live Randomization

Remix: On-demand Live Randomization Remix: On-demand Live Randomization Yue Chen, Zhi Wang, David Whalley, Long Lu* Florida State University, Stony Brook University* Background Buffer Overflow -> Code Injection Attack Background Buffer Overflow

More information

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS)

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS) Beyond Stack Smashing: Recent Advances in Exploiting Buffer Overruns Jonathan Pincus(MSR) and Brandon Baker (MS) Buffer Overflows and How they Occur Buffer is a contiguous segment of memory of a fixed

More information

Security and Privacy in Computer Systems. Lecture 5: Application Program Security

Security and Privacy in Computer Systems. Lecture 5: Application Program Security CS 645 Security and Privacy in Computer Systems Lecture 5: Application Program Security Buffer overflow exploits More effective buffer overflow attacks Preventing buffer overflow attacks Announcement Project

More information

String Oriented Programming Exploring Format String Attacks. Mathias Payer

String Oriented Programming Exploring Format String Attacks. Mathias Payer String Oriented Programming Exploring Format String Attacks Mathias Payer Motivation Additional protection mechanisms prevent many existing attack vectors Format string exploits are often overlooked Drawback:

More information

Memory Safety (cont d) Software Security

Memory Safety (cont d) Software Security Memory Safety (cont d) Software Security CS 161: Computer Security Prof. Raluca Ada Popa January 17, 2016 Some slides credit to David Wagner and Nick Weaver Announcements Discussion sections and office

More information

Selected background on ARM registers, stack layout, and calling convention

Selected background on ARM registers, stack layout, and calling convention Selected background on ARM registers, stack layout, and calling convention ARM Overview ARM stands for Advanced RISC Machine Main application area: Mobile phones, smartphones (Apple iphone, Google Android),

More information

Software Security: Buffer Overflow Attacks

Software Security: Buffer Overflow Attacks CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Attacks (continued) Autumn 2018 Tadayoshi (Yoshi) Kohno yoshi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann,

More information

Advanced Buffer Overflow

Advanced Buffer Overflow Pattern Recognition and Applications Lab Advanced Buffer Overflow Ing. Davide Maiorca, Ph.D. davide.maiorca@diee.unica.it Computer Security A.Y. 2016/2017 Department of Electrical and Electronic Engineering

More information

How to Sandbox IIS Automatically without 0 False Positive and Negative

How to Sandbox IIS Automatically without 0 False Positive and Negative How to Sandbox IIS Automatically without 0 False Positive and Negative Professor Tzi-cker Chiueh Computer Science Department Stony Brook University chiueh@cs.sunysb.edu 1/10/06 Blackhat Federal 2006 1

More information

HideM: Protecting the Contents of Userspace Memory in the Face of Disclosure Vulnerabilities

HideM: Protecting the Contents of Userspace Memory in the Face of Disclosure Vulnerabilities HideM: Protecting the Contents of Userspace Memory in the Face of Disclosure Vulnerabilities Jason Gionta, William Enck, Peng Ning 1 JIT-ROP 2 Two Attack Categories Injection Attacks Code Integrity Data

More information

Leveraging CVE for ASLR Bypass & RCE. Gal De Leon & Nadav Markus

Leveraging CVE for ASLR Bypass & RCE. Gal De Leon & Nadav Markus Leveraging CVE-2015-7547 for ASLR Bypass & RCE Gal De Leon & Nadav Markus 1 Who We Are Nadav Markus, Gal De-Leon Security researchers @ PaloAltoNetworks Vulnerability research and exploitation Reverse

More information

On The Effectiveness of Address-Space Randomization. H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh Stanford University CCS 2004

On The Effectiveness of Address-Space Randomization. H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh Stanford University CCS 2004 On The Effectiveness of Address-Space Randomization H. Shacham, M. Page, B. Pfaff, E.-J. Goh, N. Modadugu, and D. Boneh Stanford University CCS 2004 Code-Injection Attacks Inject malicious executable code

More information

Meltdown or "Holy Crap: How did we do this to ourselves" Meltdown exploits side effects of out-of-order execution to read arbitrary kernelmemory

Meltdown or Holy Crap: How did we do this to ourselves Meltdown exploits side effects of out-of-order execution to read arbitrary kernelmemory Meltdown or "Holy Crap: How did we do this to ourselves" Abstract Meltdown exploits side effects of out-of-order execution to read arbitrary kernelmemory locations Breaks all security assumptions given

More information

Security Workshop HTS. LSE Team. February 3rd, 2016 EPITA / 40

Security Workshop HTS. LSE Team. February 3rd, 2016 EPITA / 40 Security Workshop HTS LSE Team EPITA 2018 February 3rd, 2016 1 / 40 Introduction What is this talk about? Presentation of some basic memory corruption bugs Presentation of some simple protections Writing

More information

Missing the Point(er): On the Effectiveness of Code Pointer Integrity 1

Missing the Point(er): On the Effectiveness of Code Pointer Integrity 1 2015 IEEE Symposium on Security and Privacy Missing the Point(er): On the Effectiveness of Code Pointer Integrity 1 Isaac Evans, Sam Fingeret, Julián González, Ulziibayar Otgonbaatar, Tiffany Tang, Howard

More information

Jump Over ASLR: Attacking Branch Predictors to Bypass ASLR

Jump Over ASLR: Attacking Branch Predictors to Bypass ASLR Jump Over ASLR: Attacking Branch Predictors to Bypass ASLR Presentation by Eric Newberry and Youssef Tobah Paper by Dmitry Evtyushkin, Dmitry Ponomarev, and Nael Abu-Ghazaleh 1 Motivation Buffer overflow

More information

Introduction to software exploitation ISSISP 2017

Introduction to software exploitation ISSISP 2017 Introduction to software exploitation ISSISP 2017 1 VM https://drive.google.com/open?id=0b8bzf4ybu s1kltjsnlnwqjhss1e (sha1sum: 36c32a596bbc908729ea9333f3da10918e24d767) Login / pass: issisp / issisp 2

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Stefan Savage, Fall 2018, Lecture 4 Low Level Software Security II: Format Strings, Shellcode, & Stack Protection Review Function arguments and local variables are stored on the

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Alex Gantman, Spring 2018, Lecture 4 Low Level Software Security II: Format Strings, Shellcode, & Stack Protection Review Function arguments and local variables are stored on

More information

CS 6V Control-Flow Integrity Principles, Implementations, and Applications. Sureshbabu Murugesan

CS 6V Control-Flow Integrity Principles, Implementations, and Applications. Sureshbabu Murugesan CS 6V81-05 Control-Flow Integrity Principles, Implementations, and Applications Sureshbabu Murugesan Department of Computer Science University of Texas at Dallas February 29 th, 2012 Outline 1 Overview

More information

CSE 127 Computer Security

CSE 127 Computer Security CSE 127 Computer Security Stefan Savage, Spring 2018, Lecture 4 Low Level Software Security II: Format Strings, Shellcode, & Stack Protection Review Function arguments and local variables are stored on

More information

Cyber Moving Targets. Yashar Dehkan Asl

Cyber Moving Targets. Yashar Dehkan Asl Cyber Moving Targets Yashar Dehkan Asl Introduction An overview of different cyber moving target techniques, their threat models, and their technical details. Cyber moving target technique: Defend a system

More information

Secure Systems 2.0: Revisiting and Rethinking the Challenges of Secure System Design. Todd Austin University of Michigan

Secure Systems 2.0: Revisiting and Rethinking the Challenges of Secure System Design. Todd Austin University of Michigan Secure Systems 2.0: Revisiting and Rethinking the Challenges of Secure System Design Todd Austin University of Michigan The Security Arms Race Question: Why are systems never safe? We deploy our designs

More information

Exploits and gdb. Tutorial 5

Exploits and gdb. Tutorial 5 Exploits and gdb Tutorial 5 Exploits and gdb 1. Buffer Vulnerabilities 2. Code Injection 3. Integer Attacks 4. Advanced Exploitation 5. GNU Debugger (gdb) Buffer Vulnerabilities Basic Idea Overflow or

More information

Smashing the Buffer. Miroslav Štampar

Smashing the Buffer. Miroslav Štampar Smashing the Buffer Miroslav Štampar (mstampar@zsis.hr) Summary BSidesVienna 2014, Vienna (Austria) November 22nd, 2014 2 Buffer overflow (a.k.a.) Buffer overrun An anomaly where a program, while writing

More information

New York University CSCI-UA : Advanced Computer Systems: Spring 2016 Midterm Exam

New York University CSCI-UA : Advanced Computer Systems: Spring 2016 Midterm Exam New York University CSCI-UA.480-008: Advanced Computer Systems: Spring 2016 Midterm Exam This exam is 75 minutes. Stop writing when time is called. You must turn in your exam; we will not collect it. Do

More information

Outline. Memory Exploit

Outline. Memory Exploit Outline CS 6V81-05: System Security and Malicious Code Analysis Robust Shell Code Return Oriented Programming and HeapSpray Zhiqiang Lin Department of Computer Science University of Texas at Dallas April

More information

Confinement (Running Untrusted Programs)

Confinement (Running Untrusted Programs) Confinement (Running Untrusted Programs) Chester Rebeiro Indian Institute of Technology Madras Untrusted Programs Untrusted Application Entire Application untrusted Part of application untrusted Modules

More information

Software Security: Buffer Overflow Attacks (continued)

Software Security: Buffer Overflow Attacks (continued) CSE 484 / CSE M 584: Computer Security and Privacy Software Security: Buffer Overflow Attacks (continued) Spring 2015 Franziska (Franzi) Roesner franzi@cs.washington.edu Thanks to Dan Boneh, Dieter Gollmann,

More information

Abstraction Recovery for Scalable Static Binary Analysis

Abstraction Recovery for Scalable Static Binary Analysis Abstraction Recovery for Scalable Static Binary Analysis Edward J. Schwartz Software Engineering Institute Carnegie Mellon University 1 The Gap Between Binary and Source Code push mov sub movl jmp mov

More information

Lecture Notes: Unleashing MAYHEM on Binary Code

Lecture Notes: Unleashing MAYHEM on Binary Code Lecture Notes: Unleashing MAYHEM on Binary Code Rui Zhang February 22, 2017 1 Finding Exploitable Bugs 1.1 Main Challenge in Exploit Generation Exploring enough of the state space of an application to

More information

Exercise 6: Buffer Overflow and return-into-libc Attacks

Exercise 6: Buffer Overflow and return-into-libc Attacks Technische Universität Darmstadt Fachbereich Informatik System Security Lab Prof. Dr.-Ing. Ahmad-Reza Sadeghi M.Sc. David Gens Exercise 6: Buffer Overflow and return-into-libc Attacks Course Secure, Trusted

More information

Undermining Information Hiding (And What to do About it)

Undermining Information Hiding (And What to do About it) Undermining Information Hiding (And What to do About it) Enes Göktaş, Robert Gawlik, Benjamin Kollenda, Elias Athanasopoulos, Georgios Portokalidis, Cristiano Giuffrida, Herbert Bos Overview Mitigating

More information

Exploiting and Protecting Dynamic Code Generation

Exploiting and Protecting Dynamic Code Generation Exploiting and Protecting Dynamic Code Generation Chengyu Song Georgia Institute of Technology csong84@gatech.edu Chao Zhang UC Berkeley chaoz@berkeley.edu Tielei Wang, Wenke Lee Georgia Institute of Technology

More information

in memory: an evolution of attacks Mathias Payer Purdue University

in memory: an evolution of attacks Mathias Payer Purdue University in memory: an evolution of attacks Mathias Payer Purdue University Images (c) MGM, WarGames, 1983 Memory attacks: an ongoing war Vulnerability classes according to CVE Memory

More information

Modern Buffer Overflow Prevention Techniques: How they work and why they don t

Modern Buffer Overflow Prevention Techniques: How they work and why they don t Modern Buffer Overflow Prevention Techniques: How they work and why they don t Russ Osborn CS182 JT 4/13/2006 1 In the past 10 years, computer viruses have been a growing problem. In 1995, there were approximately

More information

Advanced Buffer Overflow

Advanced Buffer Overflow Pattern Recognition and Applications Lab Advanced Buffer Overflow Ing. Davide Maiorca, Ph.D. davide.maiorca@diee.unica.it Computer Security A.Y. 2017/2018 Department of Electrical and Electronic Engineering

More information

Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include

Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include 2 Runtime attacks are major threats to today's applications Control-flow of an application is compromised at runtime Typically, runtime attacks include injection of malicious code Reasons for runtime attacks

More information

Exploiting Stack Buffer Overflows Learning how blackhats smash the stack for fun and profit so we can prevent it

Exploiting Stack Buffer Overflows Learning how blackhats smash the stack for fun and profit so we can prevent it Exploiting Stack Buffer Overflows Learning how blackhats smash the stack for fun and profit so we can prevent it 29.11.2012 Secure Software Engineering Andreas Follner 1 Andreas Follner Graduated earlier

More information

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions?

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? Jeroen van Beek 1 Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? 2 Inadequate OS and application security: Data abuse Stolen information Bandwidth

More information

CMPSC 497 Buffer Overflow Vulnerabilities

CMPSC 497 Buffer Overflow Vulnerabilities Systems and Internet Infrastructure Security Network and Security Research Center Department of Computer Science and Engineering Pennsylvania State University, University Park PA CMPSC 497 Buffer Overflow

More information

Stack Vulnerabilities. CS4379/5375 System Security Assurance Dr. Jaime C. Acosta

Stack Vulnerabilities. CS4379/5375 System Security Assurance Dr. Jaime C. Acosta 1 Stack Vulnerabilities CS4379/5375 System Security Assurance Dr. Jaime C. Acosta Part 1 2 3 An Old, yet Still Valid Vulnerability Buffer/Stack Overflow ESP Unknown Data (unused) Unknown Data (unused)

More information

CS 161 Computer Security

CS 161 Computer Security Paxson Spring 2013 CS 161 Computer Security Discussion 2 January 30, 2013 Question 1 Buffer Overflow Mitigations (10 min) Buffer overflow mitigations generally fall into two categories: (i) eliminating

More information

Hackveda Training - Ethical Hacking, Networking & Security

Hackveda Training - Ethical Hacking, Networking & Security Hackveda Training - Ethical Hacking, Networking & Security Day1: Hacking windows 7 / 8 system and security Part1 a.) Windows Login Password Bypass manually without CD / DVD b.) Windows Login Password Bypass

More information

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions?

Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? Jeroen van Beek 1 Why bother? Default configurations Buffer overflows Authentication mechanisms Reverse engineering Questions? 2 Inadequate OS and application security: Data abuse Stolen information Bandwidth

More information

Runtime Integrity Checking for Exploit Mitigation on Embedded Devices

Runtime Integrity Checking for Exploit Mitigation on Embedded Devices Runtime Integrity Checking for Exploit Mitigation on Embedded Devices Matthias Neugschwandtner IBM Research, Zurich eug@zurich.ibm.com Collin Mulliner Northeastern University, Boston collin@mulliner.org

More information

Module: Advanced Program Vulnerabilities and Defenses. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Module: Advanced Program Vulnerabilities and Defenses. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security CSE543 - Introduction to Computer and Network Security Module: Advanced Program Vulnerabilities and Defenses Professor Trent Jaeger 29 Anatomy of Control-Flow Exploits Two steps in control-flow exploitation

More information

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES

BUFFER OVERFLOW DEFENSES & COUNTERMEASURES BUFFER OVERFLOW DEFENSES & COUNTERMEASURES CMSC 414 FEB 01 2018 RECALL OUR CHALLENGES How can we make these even more difficult? Putting code into the memory (no zeroes) Finding the return address (guess

More information

Readactor: Practical Code Randomization Resilient to Memory Disclosure

Readactor: Practical Code Randomization Resilient to Memory Disclosure 2015 IEEE Symposium on Security and Privacy Readactor: Practical Code Randomization Resilient to Memory Disclosure Stephen Crane, Christopher Liebchen, Andrei Homescu, Lucas Davi, Per Larsen, Ahmad-Reza

More information

Buffer overflow prevention, and other attacks

Buffer overflow prevention, and other attacks Buffer prevention, and other attacks Comp Sci 3600 Security Outline 1 2 Two approaches to buffer defense Aim to harden programs to resist attacks in new programs Run time Aim to detect and abort attacks

More information