SlideShare a Scribd company logo
Stack-Based Buffer
Overflows
Joni Hall and Daniel Tumser
Overview
=>
Table of Contents
● Introduction
● Related Works
● Technical Aspects
● Careers and Jobs
● Social Impact
● Ethical Impact
● Conclusion
● References
Introduction
● occurs when a program writes to a memory address outside of (usually) a
fixed-length buffer
● results in data corruption, the stopping of a program, or the program to
operate incorrectly
● deliberately overflowing a buffer is an attack known as stack smashing
● can be exploited to inject executable code into the running program and
take control of the process
o gain unauthorized access to a computer
Related Works
● 1962 - Burroughs B5000 designed first implementation of memory segmentation
● 1978 - x86 Instruction Set Architecture memory segmentation introduced on Intel 8086
● 1996 - “Smashing the Stack for Fun and Profit” by Elias Levy published in Phrack issue 49
● 2001 - Code Red Worm exploits buffer overflow in Microsoft’s Internet Information Services
● 2003 - SQL Slammer Worm compromises machines running Microsoft SQL Server 2000
● 2003 - Buffer overflows in Xbox games allow unlicensed software to run on console
o followed by PS2
o followed by Nintendo Wii (this one specifically a Stack-Based Buffer Overflow)
Technical Aspects
● A logical stack
● Variable size memory
segment containing
function variables,
parameters, and
context
● Grows from higher
memory addresses to
lower addresses
● Divided into Stack
Frames via pointers
stored in CPU
registers
The Stack & Stack Frames
Technical Aspects
● Instruction Pointer (32-bit EIP or 64-bit RIP)
o Holds address of the next instruction to be executed
o Next address after a function call is pushed onto the stack
as the Return Address to continue execution when the
function completes/returns.
o Overwriting this is the danger of a stack buffer
overflow
● Stack Frame pointers
o EBP points to the address at the base of the stack frame
just above the return address
o ESP points to the top memory address of the stack frame
● There are more registers but not necessarily relevant in this
case
x86 Registers
eg.
EIP: 004013C2
EBP: 0028FEB8
ESP: 0028FE80
Technical Aspects
● A buffer is a block of memory for storing some
data
● A buffer on Youtube stores a portion of the video
that can be watched, and loads more as you go,
as well as makes sure enough has loaded to
compensate for some lost packets
(ex. “buffering”)
● In this case it’s a block of memory (character
arrays) for storing user input
● Buffers declared with Malloc(), Calloc(),
Realloc() will be stored in the Heap.
● The buffers created in this example go in the
Stack.
What’s a buffer?
Technical Aspects
With input strings of the proper length the
program executes as normal and returns without
error.
With a 2nd string input of length 22(+1 for string
terminator) it is overflowed and overwrites what is
immediately below that buffer in the stack. In this
case it overflows the 1st string input.
Function context (base pointer, return address)
isn’t overwritten, so program returns without an
exception thrown.
Examples’ Output
Technical Aspects
● OllyDbg with Vuln2.exe
loaded and execution
paused
● Window divided into 4
panes
o Top-left is the Code
memory segment
o Top-Right are CPU
registers
o Bottom-Reft is the
Data segment
o Bottom-Right is the
Stack
OllyDbg of Example
Technical Aspects
Stack Frame (no overflow)
Technical Aspects
Stack Frame (with overflow)
Technical Aspects
ContrastNo Overflow Overflowed
Technical Aspects
Same exact buffer overflow as in previous examples
but with user input instead of hardcoded strcpy()
Stack pane shows 10 bytes between end of our
overflowed buffer to the beginning of Return Address.
Return Addr is a pointer, x86 is 32-bit, so it’s a 4 byte
address. The 4 characters (8 hex digits) after the 10th
additional character will become the new return addr.
When function returns Return Addr is loaded into the
Instruction pointer
Overwriting Return Addr
Technical Aspects
EIP successfully overwritten with user input, in this case
four A characters, or hex-41.
User can now control program execution flow with the
Instruction pointer and execute code with this process’s
privileges.
Overwriting Return Addr
Career Impact & Job Outlook
Information Security Analyst
● 2012 - 2022 job growth
o +37%
o more than 2x the total of all occupations
● Median Salary
o $86, 170
o 2.4x total of all occupations
Vulnerability Analyst
Career Impact & Job Outlook
● Skills
o security risk management
o security intrusion detection
o IT security infrastructure
o security testing and auditing
o x86/x86_64 & Fuzzing*
● Minimum Qualifications
o Bachelor’s in CS,
Engineering or
Programming
o CompTIA Security+
Vulnerability Analyst
Career Impact & Job Outlook
Software Developer
● Job Growth 2012-2022
o +22%
o +222,600 jobs
● Median Salary
o $93,350
o x2.69 national median
Software Engineer
Career Impact & Job Outlook
Software Engineer
● Skills
○ Python
○ C
○ C++
○ UNIX
○ Linux
● Minimum Requirements
○ Bachelor’s Degree in
Computer Science or
Software Engineering
○ Programming experience
Social Impact
● Too esoteric for widespread social
impact
● Should affect coding practices of
CS and IT professionals
Write secure code.
Make your coworkers write secure code
Bounds check all the buffers
Ethical Impact
Code you produce is the responsibility of yourself
and the organization you produce it for.
Both have an ethical obligation to customers to
provide secure code.
To write secure code you need to understand the
vulnerability and how it’s exploited
Patch vulnerabilities that are discovered in
development or in the wild.
Vulnerability discovery and proofs of concept are
not illegal, and obtaining a Common
Vulnerabilities and Exposures (CVE) number for
your work looks great on a resume.
Vulnerability disclosure often negotiated and
timed with the software vendor for patching.
Exploiting vulnerabilities for unauthorized access
of computer systems still very illegal. Don’t do it
unless you’re cool with the risk of fines and prison
time.
Coding Vulnerability Analysis
Conclusion
● Overflowing a buffer may result in a program crash, program errors, or
data corruption
● CS and IT professionals should write more secure code to prevent it from
happening
● Exploiting a buffer overflow is one of the oldest ways to gain unauthorized
access to a computer
● Don’t do it unless you are okay with fines and prison time!
References
1. Erickson, Jon. Hacking: the Art of Exploitation. 2nd ed. San Francisco, Calif.: No Starch, 2008.
Print.
2. Koziol, Jack. The Shellcoder's Handbook: Discovering and Exploiting Security Holes.
Indianapolis, IN: Wiley Pub., 2004. Print.
3. Levy, Elias. "Smashing the Stack for Fun and Profit." Phrack 49 (1996). Phrack. Web. 1 July
2015. <http://phrack.org/issues/49/14.html#article>.
4. "Information Security Analyst Salary (United States)." Information Security Analyst Salary
(United States). Web. 5 July 2015.
<http://www.payscale.com/research/US/Job=Information_Security_Analyst/Salary>.
5. "Software Engineer Salary (United States)." Software Engineer Salary (United States). Web. 5
July 2015. <http://www.payscale.com/research/US/Job=Software_Engineer/Salary>.
6. Staff Contributor. "Sourcefire VRT Unveils Research on 25 Years of Vulnerabilities: 1988-2012 |
| Sourcefire Blog." Sourcefire, 5 Mar. 2013. Web. 5 July 2015.
<http://blog.sourcefire.com/Post/2013/03/05/1362499920-sourcefire-vrt-unveils-research-on--
years-of-vulnerabilities-/>.
Stack-Based Buffer
Overflows
Joni Hall and Daniel Tumser

More Related Content

PDF
Buffer overflow attacks
PPTX
Buffer overflow
PPTX
Anatomy of a Buffer Overflow Attack
PPTX
Buffer overflow
PPTX
Buffer overflow explained
PPTX
Buffer overflow attacks
PPTX
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
PDF
Buffer Overflow - Smashing the Stack
Buffer overflow attacks
Buffer overflow
Anatomy of a Buffer Overflow Attack
Buffer overflow
Buffer overflow explained
Buffer overflow attacks
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
Buffer Overflow - Smashing the Stack

What's hot (20)

PPTX
Buffer overflow attacks
PPTX
Reversing malware analysis training part4 assembly programming basics
PPTX
Linux binary analysis and exploitation
ODP
The Nightmare Fuzzing Suite and Blind Code Coverage Fuzzer
PDF
Dive into exploit development
PDF
SEH based buffer overflow vulnerability exploitation
PDF
Basic buffer overflow part1
PPTX
08 - Return Oriented Programming, the chosen one
PDF
Offensive cyber security: Smashing the stack with Python
PDF
Introduction to ida python
PPTX
How Safe is your Link ?
PDF
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
PPT
Buffer Overflow Countermeasures, DEP, Security Assessment
PDF
Return oriented programming
PPTX
Exploitation techniques and fuzzing
PDF
Breaking av software
PDF
JProfiler / an introduction
PDF
Embedded device hacking Session i
PPTX
Hacking - high school intro
PDF
Flash security past_present_future_final_en
Buffer overflow attacks
Reversing malware analysis training part4 assembly programming basics
Linux binary analysis and exploitation
The Nightmare Fuzzing Suite and Blind Code Coverage Fuzzer
Dive into exploit development
SEH based buffer overflow vulnerability exploitation
Basic buffer overflow part1
08 - Return Oriented Programming, the chosen one
Offensive cyber security: Smashing the stack with Python
Introduction to ida python
How Safe is your Link ?
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Buffer Overflow Countermeasures, DEP, Security Assessment
Return oriented programming
Exploitation techniques and fuzzing
Breaking av software
JProfiler / an introduction
Embedded device hacking Session i
Hacking - high school intro
Flash security past_present_future_final_en
Ad

Similar to Stack-Based Buffer Overflows (20)

PDF
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
PDF
Possibility of arbitrary code execution by Step-Oriented Programming
PPTX
Buffer overflow – Smashing The Stack
PPTX
T3_Embedded programing_07072022T3_Embedded programing_07072022.pptx
DOCX
Lab 2Lab ObjectivesThe objective for this lab is to review.docx
PPTX
Production Debugging at Code Camp Philly
PPTX
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
PDF
Exploit development 101 - Part 1 - Null Singapore
DOCX
Resume
PDF
Secure Coding Practices for Middleware
PPTX
Reverse engineering &amp; immunity debugger
PDF
Ceh v5 module 20 buffer overflow
PDF
Chapter three embedded system corse ppt AASTU.pdf
PPT
Itroduction about java
PDF
Download full ebook of Intel Debugger Command Reference Coll instant download...
DOCX
Chapter 1SyllabusCatalog Description Computer structu
PDF
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
PDF
Python for Machine Learning
PDF
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
PPTX
Parallel port programming
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
Possibility of arbitrary code execution by Step-Oriented Programming
Buffer overflow – Smashing The Stack
T3_Embedded programing_07072022T3_Embedded programing_07072022.pptx
Lab 2Lab ObjectivesThe objective for this lab is to review.docx
Production Debugging at Code Camp Philly
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Exploit development 101 - Part 1 - Null Singapore
Resume
Secure Coding Practices for Middleware
Reverse engineering &amp; immunity debugger
Ceh v5 module 20 buffer overflow
Chapter three embedded system corse ppt AASTU.pdf
Itroduction about java
Download full ebook of Intel Debugger Command Reference Coll instant download...
Chapter 1SyllabusCatalog Description Computer structu
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Python for Machine Learning
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Parallel port programming
Ad

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Approach and Philosophy of On baking technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
20250228 LYD VKU AI Blended-Learning.pptx
Spectroscopy.pptx food analysis technology
Empathic Computing: Creating Shared Understanding
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
Spectral efficient network and resource selection model in 5G networks
Building Integrated photovoltaic BIPV_UPV.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
sap open course for s4hana steps from ECC to s4
Approach and Philosophy of On baking technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development

Stack-Based Buffer Overflows

  • 3. Table of Contents ● Introduction ● Related Works ● Technical Aspects ● Careers and Jobs ● Social Impact ● Ethical Impact ● Conclusion ● References
  • 4. Introduction ● occurs when a program writes to a memory address outside of (usually) a fixed-length buffer ● results in data corruption, the stopping of a program, or the program to operate incorrectly ● deliberately overflowing a buffer is an attack known as stack smashing ● can be exploited to inject executable code into the running program and take control of the process o gain unauthorized access to a computer
  • 5. Related Works ● 1962 - Burroughs B5000 designed first implementation of memory segmentation ● 1978 - x86 Instruction Set Architecture memory segmentation introduced on Intel 8086 ● 1996 - “Smashing the Stack for Fun and Profit” by Elias Levy published in Phrack issue 49 ● 2001 - Code Red Worm exploits buffer overflow in Microsoft’s Internet Information Services ● 2003 - SQL Slammer Worm compromises machines running Microsoft SQL Server 2000 ● 2003 - Buffer overflows in Xbox games allow unlicensed software to run on console o followed by PS2 o followed by Nintendo Wii (this one specifically a Stack-Based Buffer Overflow)
  • 6. Technical Aspects ● A logical stack ● Variable size memory segment containing function variables, parameters, and context ● Grows from higher memory addresses to lower addresses ● Divided into Stack Frames via pointers stored in CPU registers The Stack & Stack Frames
  • 7. Technical Aspects ● Instruction Pointer (32-bit EIP or 64-bit RIP) o Holds address of the next instruction to be executed o Next address after a function call is pushed onto the stack as the Return Address to continue execution when the function completes/returns. o Overwriting this is the danger of a stack buffer overflow ● Stack Frame pointers o EBP points to the address at the base of the stack frame just above the return address o ESP points to the top memory address of the stack frame ● There are more registers but not necessarily relevant in this case x86 Registers eg. EIP: 004013C2 EBP: 0028FEB8 ESP: 0028FE80
  • 8. Technical Aspects ● A buffer is a block of memory for storing some data ● A buffer on Youtube stores a portion of the video that can be watched, and loads more as you go, as well as makes sure enough has loaded to compensate for some lost packets (ex. “buffering”) ● In this case it’s a block of memory (character arrays) for storing user input ● Buffers declared with Malloc(), Calloc(), Realloc() will be stored in the Heap. ● The buffers created in this example go in the Stack. What’s a buffer?
  • 9. Technical Aspects With input strings of the proper length the program executes as normal and returns without error. With a 2nd string input of length 22(+1 for string terminator) it is overflowed and overwrites what is immediately below that buffer in the stack. In this case it overflows the 1st string input. Function context (base pointer, return address) isn’t overwritten, so program returns without an exception thrown. Examples’ Output
  • 10. Technical Aspects ● OllyDbg with Vuln2.exe loaded and execution paused ● Window divided into 4 panes o Top-left is the Code memory segment o Top-Right are CPU registers o Bottom-Reft is the Data segment o Bottom-Right is the Stack OllyDbg of Example
  • 12. Technical Aspects Stack Frame (with overflow)
  • 14. Technical Aspects Same exact buffer overflow as in previous examples but with user input instead of hardcoded strcpy() Stack pane shows 10 bytes between end of our overflowed buffer to the beginning of Return Address. Return Addr is a pointer, x86 is 32-bit, so it’s a 4 byte address. The 4 characters (8 hex digits) after the 10th additional character will become the new return addr. When function returns Return Addr is loaded into the Instruction pointer Overwriting Return Addr
  • 15. Technical Aspects EIP successfully overwritten with user input, in this case four A characters, or hex-41. User can now control program execution flow with the Instruction pointer and execute code with this process’s privileges. Overwriting Return Addr
  • 16. Career Impact & Job Outlook Information Security Analyst ● 2012 - 2022 job growth o +37% o more than 2x the total of all occupations ● Median Salary o $86, 170 o 2.4x total of all occupations Vulnerability Analyst
  • 17. Career Impact & Job Outlook ● Skills o security risk management o security intrusion detection o IT security infrastructure o security testing and auditing o x86/x86_64 & Fuzzing* ● Minimum Qualifications o Bachelor’s in CS, Engineering or Programming o CompTIA Security+ Vulnerability Analyst
  • 18. Career Impact & Job Outlook Software Developer ● Job Growth 2012-2022 o +22% o +222,600 jobs ● Median Salary o $93,350 o x2.69 national median Software Engineer
  • 19. Career Impact & Job Outlook Software Engineer ● Skills ○ Python ○ C ○ C++ ○ UNIX ○ Linux ● Minimum Requirements ○ Bachelor’s Degree in Computer Science or Software Engineering ○ Programming experience
  • 20. Social Impact ● Too esoteric for widespread social impact ● Should affect coding practices of CS and IT professionals Write secure code. Make your coworkers write secure code Bounds check all the buffers
  • 21. Ethical Impact Code you produce is the responsibility of yourself and the organization you produce it for. Both have an ethical obligation to customers to provide secure code. To write secure code you need to understand the vulnerability and how it’s exploited Patch vulnerabilities that are discovered in development or in the wild. Vulnerability discovery and proofs of concept are not illegal, and obtaining a Common Vulnerabilities and Exposures (CVE) number for your work looks great on a resume. Vulnerability disclosure often negotiated and timed with the software vendor for patching. Exploiting vulnerabilities for unauthorized access of computer systems still very illegal. Don’t do it unless you’re cool with the risk of fines and prison time. Coding Vulnerability Analysis
  • 22. Conclusion ● Overflowing a buffer may result in a program crash, program errors, or data corruption ● CS and IT professionals should write more secure code to prevent it from happening ● Exploiting a buffer overflow is one of the oldest ways to gain unauthorized access to a computer ● Don’t do it unless you are okay with fines and prison time!
  • 23. References 1. Erickson, Jon. Hacking: the Art of Exploitation. 2nd ed. San Francisco, Calif.: No Starch, 2008. Print. 2. Koziol, Jack. The Shellcoder's Handbook: Discovering and Exploiting Security Holes. Indianapolis, IN: Wiley Pub., 2004. Print. 3. Levy, Elias. "Smashing the Stack for Fun and Profit." Phrack 49 (1996). Phrack. Web. 1 July 2015. <http://phrack.org/issues/49/14.html#article>. 4. "Information Security Analyst Salary (United States)." Information Security Analyst Salary (United States). Web. 5 July 2015. <http://www.payscale.com/research/US/Job=Information_Security_Analyst/Salary>. 5. "Software Engineer Salary (United States)." Software Engineer Salary (United States). Web. 5 July 2015. <http://www.payscale.com/research/US/Job=Software_Engineer/Salary>. 6. Staff Contributor. "Sourcefire VRT Unveils Research on 25 Years of Vulnerabilities: 1988-2012 | | Sourcefire Blog." Sourcefire, 5 Mar. 2013. Web. 5 July 2015. <http://blog.sourcefire.com/Post/2013/03/05/1362499920-sourcefire-vrt-unveils-research-on-- years-of-vulnerabilities-/>.