SlideShare a Scribd company logo
BUFFER
OVERFLOW
Course Code: MISS1201
Course Name: Intrusion Management and Ethical Hacking
Abu Juha Ahmed Muid
Roll: 2054911004
MISS-2020
Bangladesh University of Professionals
content
 What’s a buffer?
 What is buffer overflow?
 Use of the Stack
 Who is vulnerable to buffer overflow attacks?
 How do attackers exploit buffer overflows?
 What are the different types of buffer overflow attacks?
 Buffer Overflow Example
 The size and complexity of software systems is growing, increasing the number of
bugs. Many of these bugs constitute security vulnerabilities. Most common of
these bugs is the buffer overflow vulnerability
What’s a buffer?
 A buffer, or data buffer, is an area of physical memory
storage used to temporarily store data while it is being
moved from one place to another. These buffers typically live in
RAM memory. Computers frequently use buffers to help
improve performance; most modern hard drives take advantage
of buffering to efficiently access data, and many online services
also use buffers. For example, buffers are frequently used in
online video streaming to prevent interruption. When a video is
streamed, the video player downloads and stores perhaps 20%
of the video at a time in a buffer and then streams from that
buffer. This way, minor drops in connection speed or quick
service disruptions won’t affect the video stream performance.
 Buffers are designed to contain specific amounts of data. Unless
the program utilizing the buffer has built-in instructions to
discard data when too much is sent to the buffer, the program
will overwrite data in memory adjacent to the buffer.
What is buffer overflow?
 Buffer overflow is an anomaly that occurs when software writing data to a buffer overflows the buffer’s
capacity, resulting in adjacent memory locations being overwritten. In other words, too much information
is being passed into a container that does not have enough space, and that information ends up replacing
data in adjacent containers.
 Buffer overflows can be exploited by attackers with a goal of modifying a computer’s memory in order to
undermine or take control of program execution.
M I S S S T U D E N T
Use of the Stack
 The stack is a region in a program's memory space
that is only accessible from the top. There are two
operations, push and pop, to a stack. A push stores a
new data item on top of the stack, a pop removes the
top item. Every process has its own memory space (at
least in a decent OS), among them a stack region and
a heap region. The stack is used heavily to store local
variables and the return address of a function.
Use of the Stack
 The stack is a region in a program's memory space that is only accessible from the
top. There are two operations, push and pop, to a stack. A push stores a new data
item on top of the stack, a pop removes the top item. Every process has its own
memory space (at least in a decent OS), among them a stack region and a heap
region. The stack is used heavily to store local variables and the return address of a
function.
A
B
C
D D
C
B
A
Push Pop
Use of the Stack
Memory layout for a process.
Who is vulnerable to buffer overflow attacks?
 Certain coding languages are more susceptible to buffer overflow than others. C
and C++ are two popular languages with high vulnerability, since they contain no
built-in protections against accessing or overwriting data in their memory.
Windows, Mac OSX, and Linux all contain code written in one or both of these
languages.
 More modern languages like Java, PERL, and C# have built-in features that help
reduce the chances of buffer overflow, but cannot prevent it altogether.
How do attackers exploit buffer overflows?
 An attacker can deliberately feed a carefully crafted input into a program that will cause
the program to try and store that input in a buffer that isn’t large enough, overwriting
portions of memory connected to the buffer space. If the memory layout of the
program is well-defined, the attacker can deliberately overwrite areas known to contain
executable code. The attacker can then replace this code with his own executable code,
which can drastically change how the program is intended to work.
 For example if the overwritten part in memory contains a pointer (an object that points
to another place in memory) the attacker’s code could replace that code with another
pointer that points to an exploit payload. This can transfer control of the whole program
over to the attacker’s code.
What are the different types of buffer overflow
attacks?
 There are a number of different buffer overflow attacks which employ
different strategies and target different pieces of code.
 Stack overflow attack - This is the most common type of buffer overflow
attack and involves overflowing a buffer on the call stack.
 Heap overflow attack - This type of attack targets data in the open
memory pool known as the heap.
 Integer overflow attack - In an integer overflow, an arithmetic operation
results in an integer (whole number) that is too large for the integer type
meant to store it; this can result in a buffer overflow.
 Unicode overflow - A unicode overflow creates a buffer overflow by
inserting unicode characters into an input that expect ASCII characters.
How to protect against buffer overflow attacks
 Luckily, modern operating systems have runtime protections which help
mitigate buffer overflow attacks. Let’s explore 2 common protections that
help mitigate the risk of exploitation:
 Address space randomization - Randomly rearranges the
address space locations of key data areas of a process. Buffer overflow
attacks generally rely on knowing the exact location of important
executable code, randomization of address spaces makes that nearly
impossible.
 Data execution prevention - Marks certain areas of memory
either executable or non-executable, preventing an exploit from running
code found in a non-executable area.
 Software developers can also take precautions against buffer overflow
vulnerabilities by writing in languages that have built-in protections or
using special security procedures in their code.
Buffer Overflow Example
 Function: the calling function written by
the developer
 Parameters: the parameters needed by the
function
 Return: it tells the program what to do
after it has executed the function
 Basepointer: marks the start of a function
stack frame
 Buffer: the allocated space for data
 As you can see in the image above, memory is made of different parts. Between the stack and the heap,
there is a buffer area, which allows both to grow during run time.
 If we look at a stack in detail, we can see different sections:
Buffer Overflow Example
 In this example, we have a program that
allocated 20 bits of buffer. If we inject
more than that amount, say 30 bits, the
data will overflow.
 Because of the nature of the memory, the
data will overflow upwards towards the
function. Once it gets to the return
section, that is where the problems start.
 If an attacker injects data in the return
that points to the address of malicious
code, the program will run it, causing
severe consequences.
 Shellcodes are typically injected into computer memory by exploiting stack or
heap-based buffer overflows vulnerabilities, or format string attacks.
 GCC, the GNU Compiler Collection
 https://gcc.gnu.org/
 apt-get install gcc in linux
 GDB: The GNU Project Debugger
 https://www.gnu.org/software/gdb/
 apt-get install gdb
History

More Related Content

What's hot

Operating System Security
Operating System SecurityOperating System Security
Operating System Security
Ramesh Upadhaya
 
Ssrf
SsrfSsrf
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
Young Alista
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
Dr. C.V. Suresh Babu
 
System hacking
System hackingSystem hacking
System hacking
CAS
 
Unit 2
Unit 2Unit 2
Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5
AfiqEfendy Zaen
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
Education
 
System security
System securitySystem security
System security
sommerville-videos
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
Piyush Rochwani
 
Ipsec
IpsecIpsec
Software security
Software securitySoftware security
Software security
Roman Oliynykov
 
Network security - OSI Security Architecture
Network security - OSI Security ArchitectureNetwork security - OSI Security Architecture
Network security - OSI Security Architecture
BharathiKrishna6
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
ramya marichamy
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
Ravindra Raju Kolahalam
 
Cryptography
CryptographyCryptography
Cryptography
Shivanand Arur
 
Message authentication
Message authenticationMessage authentication
Message authentication
CAS
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
Sumit Kumar
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
Niyas Nazar
 

What's hot (20)

Operating System Security
Operating System SecurityOperating System Security
Operating System Security
 
Ssrf
SsrfSsrf
Ssrf
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
System hacking
System hackingSystem hacking
System hacking
 
Unit 2
Unit 2Unit 2
Unit 2
 
Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5Virus and Malicious Code Chapter 5
Virus and Malicious Code Chapter 5
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
System security
System securitySystem security
System security
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Ipsec
IpsecIpsec
Ipsec
 
Software security
Software securitySoftware security
Software security
 
Network security - OSI Security Architecture
Network security - OSI Security ArchitectureNetwork security - OSI Security Architecture
Network security - OSI Security Architecture
 
Classical encryption techniques
Classical encryption techniquesClassical encryption techniques
Classical encryption techniques
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
Cryptography
CryptographyCryptography
Cryptography
 
Message authentication
Message authenticationMessage authentication
Message authentication
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
 
Compilers
CompilersCompilers
Compilers
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 

Similar to Buffer overflow

Ids 008 buffer overflow
Ids 008 buffer overflowIds 008 buffer overflow
Ids 008 buffer overflow
jyoti_lakhani
 
Golf teamlearnerlecture
Golf teamlearnerlectureGolf teamlearnerlecture
Golf teamlearnerlecture
kairistiona
 
What
WhatWhat
What
anity
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
IRJET - Buffer Overflows Attacks & Defense
IRJET -  	  Buffer Overflows Attacks & DefenseIRJET -  	  Buffer Overflows Attacks & Defense
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
Software Reverse Engineering in a Security Context
Software Reverse Engineering in a Security ContextSoftware Reverse Engineering in a Security Context
Software Reverse Engineering in a Security Context
Lokendra Rawat
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflowCeh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
Buffer overflow explained
Buffer overflow explainedBuffer overflow explained
Buffer overflow explained
Teja Babu
 
Module 20 (buffer overflows)
Module 20 (buffer overflows)Module 20 (buffer overflows)
Module 20 (buffer overflows)
Wail Hassan
 
1Buttercup On Network-based Detection of Polymorphic B.docx
 1Buttercup On Network-based Detection of Polymorphic B.docx 1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
aryan532920
 
please answer these questions number by numberSolution1) An.pdf
please answer these questions number by numberSolution1) An.pdfplease answer these questions number by numberSolution1) An.pdf
please answer these questions number by numberSolution1) An.pdf
arishaenterprises12
 
Possibility of arbitrary code execution by Step-Oriented Programming
Possibility of arbitrary code execution by Step-Oriented ProgrammingPossibility of arbitrary code execution by Step-Oriented Programming
Possibility of arbitrary code execution by Step-Oriented Programming
kozossakai
 
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
CODE BLUE
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
sonalikharade3
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentals
Eran Goldstein
 
nullcon 2011 - Fuzzing with Complexities
nullcon 2011 - Fuzzing with Complexitiesnullcon 2011 - Fuzzing with Complexities
nullcon 2011 - Fuzzing with Complexities
n|u - The Open Security Community
 
An automated approach to fix buffer overflows
An automated approach to fix buffer overflows An automated approach to fix buffer overflows
An automated approach to fix buffer overflows
IJECEIAES
 
Rust Hack
Rust HackRust Hack
Rust Hack
Viral Parmar
 
Program security
Program securityProgram security
Program security
G Prachi
 

Similar to Buffer overflow (20)

Ids 008 buffer overflow
Ids 008 buffer overflowIds 008 buffer overflow
Ids 008 buffer overflow
 
Golf teamlearnerlecture
Golf teamlearnerlectureGolf teamlearnerlecture
Golf teamlearnerlecture
 
What
WhatWhat
What
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
IRJET - Buffer Overflows Attacks & Defense
IRJET -  	  Buffer Overflows Attacks & DefenseIRJET -  	  Buffer Overflows Attacks & Defense
IRJET - Buffer Overflows Attacks & Defense
 
Software Reverse Engineering in a Security Context
Software Reverse Engineering in a Security ContextSoftware Reverse Engineering in a Security Context
Software Reverse Engineering in a Security Context
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflowCeh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
 
Buffer overflow explained
Buffer overflow explainedBuffer overflow explained
Buffer overflow explained
 
Module 20 (buffer overflows)
Module 20 (buffer overflows)Module 20 (buffer overflows)
Module 20 (buffer overflows)
 
1Buttercup On Network-based Detection of Polymorphic B.docx
 1Buttercup On Network-based Detection of Polymorphic B.docx 1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
 
please answer these questions number by numberSolution1) An.pdf
please answer these questions number by numberSolution1) An.pdfplease answer these questions number by numberSolution1) An.pdf
please answer these questions number by numberSolution1) An.pdf
 
Possibility of arbitrary code execution by Step-Oriented Programming
Possibility of arbitrary code execution by Step-Oriented ProgrammingPossibility of arbitrary code execution by Step-Oriented Programming
Possibility of arbitrary code execution by Step-Oriented Programming
 
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
Possibility of arbitrary code execution by Step-Oriented Programming by Hiroa...
 
Introduction to system programming
Introduction to system programmingIntroduction to system programming
Introduction to system programming
 
Reverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentalsReverse engineering – debugging fundamentals
Reverse engineering – debugging fundamentals
 
nullcon 2011 - Fuzzing with Complexities
nullcon 2011 - Fuzzing with Complexitiesnullcon 2011 - Fuzzing with Complexities
nullcon 2011 - Fuzzing with Complexities
 
An automated approach to fix buffer overflows
An automated approach to fix buffer overflows An automated approach to fix buffer overflows
An automated approach to fix buffer overflows
 
Rust Hack
Rust HackRust Hack
Rust Hack
 
Program security
Program securityProgram security
Program security
 

Recently uploaded

Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
MysoreMuleSoftMeetup
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
dot55audits
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 

Recently uploaded (20)

Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47Mule event processing models | MuleSoft Mysore Meetup #47
Mule event processing models | MuleSoft Mysore Meetup #47
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
ZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptxZK on Polkadot zero knowledge proofs - sub0.pptx
ZK on Polkadot zero knowledge proofs - sub0.pptx
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 

Buffer overflow

  • 1. BUFFER OVERFLOW Course Code: MISS1201 Course Name: Intrusion Management and Ethical Hacking Abu Juha Ahmed Muid Roll: 2054911004 MISS-2020 Bangladesh University of Professionals
  • 2. content  What’s a buffer?  What is buffer overflow?  Use of the Stack  Who is vulnerable to buffer overflow attacks?  How do attackers exploit buffer overflows?  What are the different types of buffer overflow attacks?  Buffer Overflow Example
  • 3.  The size and complexity of software systems is growing, increasing the number of bugs. Many of these bugs constitute security vulnerabilities. Most common of these bugs is the buffer overflow vulnerability
  • 4. What’s a buffer?  A buffer, or data buffer, is an area of physical memory storage used to temporarily store data while it is being moved from one place to another. These buffers typically live in RAM memory. Computers frequently use buffers to help improve performance; most modern hard drives take advantage of buffering to efficiently access data, and many online services also use buffers. For example, buffers are frequently used in online video streaming to prevent interruption. When a video is streamed, the video player downloads and stores perhaps 20% of the video at a time in a buffer and then streams from that buffer. This way, minor drops in connection speed or quick service disruptions won’t affect the video stream performance.  Buffers are designed to contain specific amounts of data. Unless the program utilizing the buffer has built-in instructions to discard data when too much is sent to the buffer, the program will overwrite data in memory adjacent to the buffer.
  • 5. What is buffer overflow?  Buffer overflow is an anomaly that occurs when software writing data to a buffer overflows the buffer’s capacity, resulting in adjacent memory locations being overwritten. In other words, too much information is being passed into a container that does not have enough space, and that information ends up replacing data in adjacent containers.  Buffer overflows can be exploited by attackers with a goal of modifying a computer’s memory in order to undermine or take control of program execution. M I S S S T U D E N T
  • 6. Use of the Stack  The stack is a region in a program's memory space that is only accessible from the top. There are two operations, push and pop, to a stack. A push stores a new data item on top of the stack, a pop removes the top item. Every process has its own memory space (at least in a decent OS), among them a stack region and a heap region. The stack is used heavily to store local variables and the return address of a function.
  • 7. Use of the Stack  The stack is a region in a program's memory space that is only accessible from the top. There are two operations, push and pop, to a stack. A push stores a new data item on top of the stack, a pop removes the top item. Every process has its own memory space (at least in a decent OS), among them a stack region and a heap region. The stack is used heavily to store local variables and the return address of a function. A B C D D C B A Push Pop
  • 8. Use of the Stack
  • 9. Memory layout for a process.
  • 10. Who is vulnerable to buffer overflow attacks?  Certain coding languages are more susceptible to buffer overflow than others. C and C++ are two popular languages with high vulnerability, since they contain no built-in protections against accessing or overwriting data in their memory. Windows, Mac OSX, and Linux all contain code written in one or both of these languages.  More modern languages like Java, PERL, and C# have built-in features that help reduce the chances of buffer overflow, but cannot prevent it altogether.
  • 11. How do attackers exploit buffer overflows?  An attacker can deliberately feed a carefully crafted input into a program that will cause the program to try and store that input in a buffer that isn’t large enough, overwriting portions of memory connected to the buffer space. If the memory layout of the program is well-defined, the attacker can deliberately overwrite areas known to contain executable code. The attacker can then replace this code with his own executable code, which can drastically change how the program is intended to work.  For example if the overwritten part in memory contains a pointer (an object that points to another place in memory) the attacker’s code could replace that code with another pointer that points to an exploit payload. This can transfer control of the whole program over to the attacker’s code.
  • 12. What are the different types of buffer overflow attacks?  There are a number of different buffer overflow attacks which employ different strategies and target different pieces of code.  Stack overflow attack - This is the most common type of buffer overflow attack and involves overflowing a buffer on the call stack.  Heap overflow attack - This type of attack targets data in the open memory pool known as the heap.  Integer overflow attack - In an integer overflow, an arithmetic operation results in an integer (whole number) that is too large for the integer type meant to store it; this can result in a buffer overflow.  Unicode overflow - A unicode overflow creates a buffer overflow by inserting unicode characters into an input that expect ASCII characters.
  • 13. How to protect against buffer overflow attacks  Luckily, modern operating systems have runtime protections which help mitigate buffer overflow attacks. Let’s explore 2 common protections that help mitigate the risk of exploitation:  Address space randomization - Randomly rearranges the address space locations of key data areas of a process. Buffer overflow attacks generally rely on knowing the exact location of important executable code, randomization of address spaces makes that nearly impossible.  Data execution prevention - Marks certain areas of memory either executable or non-executable, preventing an exploit from running code found in a non-executable area.  Software developers can also take precautions against buffer overflow vulnerabilities by writing in languages that have built-in protections or using special security procedures in their code.
  • 14. Buffer Overflow Example  Function: the calling function written by the developer  Parameters: the parameters needed by the function  Return: it tells the program what to do after it has executed the function  Basepointer: marks the start of a function stack frame  Buffer: the allocated space for data  As you can see in the image above, memory is made of different parts. Between the stack and the heap, there is a buffer area, which allows both to grow during run time.  If we look at a stack in detail, we can see different sections:
  • 15. Buffer Overflow Example  In this example, we have a program that allocated 20 bits of buffer. If we inject more than that amount, say 30 bits, the data will overflow.  Because of the nature of the memory, the data will overflow upwards towards the function. Once it gets to the return section, that is where the problems start.  If an attacker injects data in the return that points to the address of malicious code, the program will run it, causing severe consequences.
  • 16.  Shellcodes are typically injected into computer memory by exploiting stack or heap-based buffer overflows vulnerabilities, or format string attacks.
  • 17.  GCC, the GNU Compiler Collection  https://gcc.gnu.org/  apt-get install gcc in linux  GDB: The GNU Project Debugger  https://www.gnu.org/software/gdb/  apt-get install gdb
  • 18.
  • 19.