SlideShare a Scribd company logo
Buffer Overflow Attack
(Software security)
Krishantha Dinesh
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
What is it
• Buffers are areas of memory set aside to hold data, often while moving it from one section of a program
to another, or between programs. Buffer overflows can often be triggered by malformed inputs.
• if one assumes all inputs will be smaller than a certain size and the buffer is created to be that size, if an
anomalous transaction produces more data it could cause it to write past the end of the buffer. If this
overwrites adjacent data or executable code, this may result in erratic program behavior, including
memory access errors, incorrect results, and crashes.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
Buffer overflow types
• Stack overflow
• Heap overflow
• Off By One overflow
• Function pointers
• Integer overflow
• Format string overflow
• Unicode overflow
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
Example (Format String attack)
If the user passes %X as value, then printf() will receive
a pointer to a string with “%X” in it on the stack
Printf() will see the %X and assume there is another
parameter above it on the stack
Whatever is above it on the stack will be printed in
hexadecimal
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
Who are vulnerable
• Applications written in Java, PHP, C#, ASP.NET, Ruby-on-rails, server-side javascript and JSP are
managed applications, and are not lead to memory corruption vulnerabilities such as stack buffer
overflows or heap buffer overflows caused by bad web-application code
• Buffer overflows tend to be the preserve of C/C++ applications.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
How it comes
• Pushing data more than the capacity of a buffer
• buffer overflow, or buffer overrun, is an anomaly where a program, while writing data to a buffer,
overruns the buffer's boundary and overwrites adjacent memory.
• For example:
• - strcpy(target_buffer, large_string)
• - printf(str_ptr)
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
example
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
./sample.out hello
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
./sample.out AAAAAAAAAAAAAAAAA
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
Unsafe C functions
• strcpy (char *dest, const char *src)
• strcat (char *dest, const char *src)
• gets (char *s)
• scanf ( const char *format, … )
• printf (conts char *format, … )
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
How to prevent
• never use printf(buffer) for any function in the printf family
• Review loop bounds for off-by-one errors
• Avoid unsafe C functions (e.g. strcpy(), strcat(), sprintf(), gets(), scanf()) and learn how to use
alternatives (e.g. strncpy(), strncat(), snprintf())
• Insert bounds checking code
• Avoid unsafe programming languages (C, C++) and use type safe languages like java
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
records
• The earliest documented hostile exploitation of a buffer overflow was in 1988. It was one of several
exploits used by the Morris worm to propagate itself over the Internet. The program exploited was a
service on Unix called finger.The Ping of death
• The Morris (Internet worm of November 2, 1988) worm spread in part by exploiting a stack buffer
overflow in the Unix finger server.
• The Witty worm (2004) spread by exploiting a stack buffer overflow in the Internet Security Systems
BlackICE Desktop Agent. The Witty worm is a computer worm that attacks the firewall and other
computer security products written by a particular company, Internet Security Systems (ISS) now IBM
Internet Security Systems.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
• The Slammer worm (January 25, 2003) spread by exploiting a stack buffer overflow in Microsoft's SQL
server.
• The Blaster worm spread by exploiting a stack buffer overflow in Microsoft DCOM service. The Blaster
Worm (also known as Lovsan, Lovesan or MSBlast) was a computer worm that spread on computers
running the Microsoft operating systems Windows XP and Windows 2000, during August 2003.The
earliest documented hostile exploitation of a buffer overflow was in 1988. It was one of several exploits
used by the Morris worm to propagate itself over the Internet. The program exploited was a service on
Unix called finger.
•
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
• 1995, Thomas Lopatic independently rediscovered the buffer overflow and published his findings on the
Bugtraq security mailing list. A year later, in 1996, Elias Levy (also known as Aleph One) published in
Phrack magazine the paper "Smashing the Stack for Fun and Profit”, a step-by-step introduction to
exploiting stack-based buffer overflow vulnerabilities. Since then, at least two major internet worms
have exploited buffer overflows to compromise a large number of systems. In 2001, the Code Red worm
exploited a buffer overflow in Microsoft's Internet Information Services (IIS) 5.0 and in 2003 the SQL
Slammer worm compromised machines running Microsoft SQL Server 2000.
* http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/
• In 2003, buffer overflows present in licensed Xbox games have been exploited to allow unlicensed
software, including homebrew games, to run on the console without the need for hardware
modifications, known as modchips. The PS2 Independence Exploit also used a buffer overflow to
achieve the same for the PlayStation 2. The Twilight hack accomplished the same with the Wii, using a
buffer overflow in The Legend of Zelda: Twilight Princess.

More Related Content

PPTX
Anatomy of a Buffer Overflow Attack
PPT
Buffer Overflow Attacks
PPTX
Buffer overflow attacks
PPTX
How Safe is your Link ?
PPTX
Buffer overflow
PDF
Buffer overflow null
PPTX
Buffer Overflow Demo by Saurabh Sharma
PPTX
Power of linked list
Anatomy of a Buffer Overflow Attack
Buffer Overflow Attacks
Buffer overflow attacks
How Safe is your Link ?
Buffer overflow
Buffer overflow null
Buffer Overflow Demo by Saurabh Sharma
Power of linked list

What's hot (20)

PPT
Beyond Automated Testing - RVAsec 2016
PDF
Metasploit for Penetration Testing: Beginner Class
PDF
Introduction to red team operations
PPT
6 buffer overflows
PDF
Internal Pentest: from z3r0 to h3r0
PPTX
Vulnerability, exploit to metasploit
PDF
Writing malware while the blue team is staring at you
PPT
BSides Philly Finding a Company's BreakPoint
PPT
RIT 2009 Intellectual Pwnership
PDF
Buffer overflow attacks
DOCX
Web-servers & Application Hacking
PPTX
Control hijacking
PDF
'Malware Analysis' by PP Singh
PPT
Buffer Overflows
PPTX
Pwnstaller
PPT
BSidesJXN 2016: Finding a Company's BreakPoint
PDF
Hacking in shadows By - Raghav Bisht
PPTX
Stack-Based Buffer Overflows
PDF
Art of Web Backdoor - Pichaya Morimoto
PDF
Attack Chaining: Advanced Maneuvers for Hack Fu
Beyond Automated Testing - RVAsec 2016
Metasploit for Penetration Testing: Beginner Class
Introduction to red team operations
6 buffer overflows
Internal Pentest: from z3r0 to h3r0
Vulnerability, exploit to metasploit
Writing malware while the blue team is staring at you
BSides Philly Finding a Company's BreakPoint
RIT 2009 Intellectual Pwnership
Buffer overflow attacks
Web-servers & Application Hacking
Control hijacking
'Malware Analysis' by PP Singh
Buffer Overflows
Pwnstaller
BSidesJXN 2016: Finding a Company's BreakPoint
Hacking in shadows By - Raghav Bisht
Stack-Based Buffer Overflows
Art of Web Backdoor - Pichaya Morimoto
Attack Chaining: Advanced Maneuvers for Hack Fu
Ad

Similar to Buffer overflow attack (20)

PPSX
Ids 008 buffer overflow
PPTX
Owasp web application security trends
PPTX
[2.1] Web application Security Trends - Omar Ganiev
PPTX
Methods Hackers Use
PDF
WannaCry (WannaCrypt) Ransomware - Advisory from CERT-IN
PPTX
Hacking WebApps for fun and profit : how to approach a target?
PDF
Threats, Threat Modeling and Analysis
PPTX
Rust Hack
PDF
Computer security
PDF
Metasploitation part-1 (murtuja)
PPTX
Owasp Mobile Risk Series : M4 : Unintended Data Leakage
DOCX
Continuing in your role as a human service provider for your local.docx
PPTX
Web & Cloud Security in the real world
PDF
Living with the threat of Determined Attackers - RANT0214
PPTX
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
PPTX
Defending Enterprise IT - beating assymetricality
PDF
VULNERABILITY ( CYBER SECURITY )
PDF
A short visit to the bot zoo
PPT
Hacking and its Defence
PPTX
MALWARE UNIT 1 PPT.pptx...This covers about Malware Nomenclature and its types
Ids 008 buffer overflow
Owasp web application security trends
[2.1] Web application Security Trends - Omar Ganiev
Methods Hackers Use
WannaCry (WannaCrypt) Ransomware - Advisory from CERT-IN
Hacking WebApps for fun and profit : how to approach a target?
Threats, Threat Modeling and Analysis
Rust Hack
Computer security
Metasploitation part-1 (murtuja)
Owasp Mobile Risk Series : M4 : Unintended Data Leakage
Continuing in your role as a human service provider for your local.docx
Web & Cloud Security in the real world
Living with the threat of Determined Attackers - RANT0214
An Introduction of SQL Injection, Buffer Overflow & Wireless Attack
Defending Enterprise IT - beating assymetricality
VULNERABILITY ( CYBER SECURITY )
A short visit to the bot zoo
Hacking and its Defence
MALWARE UNIT 1 PPT.pptx...This covers about Malware Nomenclature and its types
Ad

More from Krish (7)

PDF
Introduction to docker
PDF
Web Services
PDF
Introduction to jenkins
PDF
Introduction to ansible
PPTX
Introduction to apache maven
PPTX
Java Fundamentals to Advance
PPTX
Introduction to-ict
Introduction to docker
Web Services
Introduction to jenkins
Introduction to ansible
Introduction to apache maven
Java Fundamentals to Advance
Introduction to-ict

Recently uploaded (20)

PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Transform Your Business with a Software ERP System
PDF
System and Network Administraation Chapter 3
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
history of c programming in notes for students .pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Designing Intelligence for the Shop Floor.pdf
Softaken Excel to vCard Converter Software.pdf
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
L1 - Introduction to python Backend.pptx
Odoo POS Development Services by CandidRoot Solutions
Upgrade and Innovation Strategies for SAP ERP Customers
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Transform Your Business with a Software ERP System
System and Network Administraation Chapter 3
How to Choose the Right IT Partner for Your Business in Malaysia
Why Generative AI is the Future of Content, Code & Creativity?
history of c programming in notes for students .pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Designing Intelligence for the Shop Floor.pdf

Buffer overflow attack

  • 1. Buffer Overflow Attack (Software security) Krishantha Dinesh
  • 2. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ What is it • Buffers are areas of memory set aside to hold data, often while moving it from one section of a program to another, or between programs. Buffer overflows can often be triggered by malformed inputs. • if one assumes all inputs will be smaller than a certain size and the buffer is created to be that size, if an anomalous transaction produces more data it could cause it to write past the end of the buffer. If this overwrites adjacent data or executable code, this may result in erratic program behavior, including memory access errors, incorrect results, and crashes.
  • 3. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ Buffer overflow types • Stack overflow • Heap overflow • Off By One overflow • Function pointers • Integer overflow • Format string overflow • Unicode overflow
  • 4. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ Example (Format String attack) If the user passes %X as value, then printf() will receive a pointer to a string with “%X” in it on the stack Printf() will see the %X and assume there is another parameter above it on the stack Whatever is above it on the stack will be printed in hexadecimal
  • 5. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ Who are vulnerable • Applications written in Java, PHP, C#, ASP.NET, Ruby-on-rails, server-side javascript and JSP are managed applications, and are not lead to memory corruption vulnerabilities such as stack buffer overflows or heap buffer overflows caused by bad web-application code • Buffer overflows tend to be the preserve of C/C++ applications.
  • 6. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ How it comes • Pushing data more than the capacity of a buffer • buffer overflow, or buffer overrun, is an anomaly where a program, while writing data to a buffer, overruns the buffer's boundary and overwrites adjacent memory. • For example: • - strcpy(target_buffer, large_string) • - printf(str_ptr)
  • 7. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ example
  • 8. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ ./sample.out hello
  • 9. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ ./sample.out AAAAAAAAAAAAAAAAA
  • 10. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ Unsafe C functions • strcpy (char *dest, const char *src) • strcat (char *dest, const char *src) • gets (char *s) • scanf ( const char *format, … ) • printf (conts char *format, … )
  • 11. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ How to prevent • never use printf(buffer) for any function in the printf family • Review loop bounds for off-by-one errors • Avoid unsafe C functions (e.g. strcpy(), strcat(), sprintf(), gets(), scanf()) and learn how to use alternatives (e.g. strncpy(), strncat(), snprintf()) • Insert bounds checking code • Avoid unsafe programming languages (C, C++) and use type safe languages like java
  • 12. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ records • The earliest documented hostile exploitation of a buffer overflow was in 1988. It was one of several exploits used by the Morris worm to propagate itself over the Internet. The program exploited was a service on Unix called finger.The Ping of death • The Morris (Internet worm of November 2, 1988) worm spread in part by exploiting a stack buffer overflow in the Unix finger server. • The Witty worm (2004) spread by exploiting a stack buffer overflow in the Internet Security Systems BlackICE Desktop Agent. The Witty worm is a computer worm that attacks the firewall and other computer security products written by a particular company, Internet Security Systems (ISS) now IBM Internet Security Systems.
  • 13. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ • The Slammer worm (January 25, 2003) spread by exploiting a stack buffer overflow in Microsoft's SQL server. • The Blaster worm spread by exploiting a stack buffer overflow in Microsoft DCOM service. The Blaster Worm (also known as Lovsan, Lovesan or MSBlast) was a computer worm that spread on computers running the Microsoft operating systems Windows XP and Windows 2000, during August 2003.The earliest documented hostile exploitation of a buffer overflow was in 1988. It was one of several exploits used by the Morris worm to propagate itself over the Internet. The program exploited was a service on Unix called finger. •
  • 14. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ • 1995, Thomas Lopatic independently rediscovered the buffer overflow and published his findings on the Bugtraq security mailing list. A year later, in 1996, Elias Levy (also known as Aleph One) published in Phrack magazine the paper "Smashing the Stack for Fun and Profit”, a step-by-step introduction to exploiting stack-based buffer overflow vulnerabilities. Since then, at least two major internet worms have exploited buffer overflows to compromise a large number of systems. In 2001, the Code Red worm exploited a buffer overflow in Microsoft's Internet Information Services (IIS) 5.0 and in 2003 the SQL Slammer worm compromised machines running Microsoft SQL Server 2000.
  • 15. * http://www.krishantha.com * https://www.youtube.com/krish * https://www.linkedin.com/in/krish-/ • In 2003, buffer overflows present in licensed Xbox games have been exploited to allow unlicensed software, including homebrew games, to run on the console without the need for hardware modifications, known as modchips. The PS2 Independence Exploit also used a buffer overflow to achieve the same for the PlayStation 2. The Twilight hack accomplished the same with the Wii, using a buffer overflow in The Legend of Zelda: Twilight Princess.