SlideShare a Scribd company logo
Buffer Overflow Attacks



                          1
What are buffer overflows?
•   Suppose a web server contains a function:
        void func(char *str) {
        char buf[128];
        strcpy(buf, str);
        do-something(buf);
}
• } When the function is invoked the stack looks like:




•   What if *str is 136 bytes long? After strcpy



                                                         2
Basic stack exploit

o Main problem: no range checking in strcpy().
o Suppose *str is such that after strcpy stack looks like:




o When func() exits, the user will be given a shell !!
o Note: attack code runs in stack.
o To determine ret guess position of stack when func() is
  called.



                                                             3
Some unsafe C lib functions

o strcpy (char *dest, const char *src)

o strcat (char *dest, const char *src)

o gets (char *s)

o scanf ( const char *format, … )

o printf (conts char *format, … )


                                         4
Exploiting buffer overflows

Suppose web server calls func() with given URL.
 Attacker can create a 200 byte URL to obtain shell
 on web server.

Some complications:
o Program P should not contain the ‘0’ character.
o Overflow should not crash program before func()
  exits.

  Sample buffer overflow of this type:
o Overflow in MIME type field in MS Outlook.
                                                      5
Causing program to exec attack
               code
o Stack smashing attack:
o   Override return address in stack activation
                 record by overflowing a local
  buffer variable.
o Function pointers: (used in attack on Linux)




o   Overflowing buf will override function
  pointer.
o    Longjmp buffers: longjmp(pos) (used in
  attack on Perl 5.003)                           6
Finding buffer overflows

Hackers find buffer overflows as follows:
o Run web server on local machine.
o Issue requests with long tags.
o All long tags end with “$$$$$”.
o     If web server crashes,
o      search core dump for “$$$$$” to find
o      overflow location.
o Some automated tools exist. (eEye Retina,
  ISIC).

                                              7
Preventing buf overflow attacks

o Main problem:
o strcpy(), strcat(), sprintf() have no range checking.
o “Safe” versions strncpy(), strncat() are misleading
o    – strncpy() may leave buffer unterminated.
o    – strncpy(), strncat() encourage off by 1 bugs.

o Defenses:
o  Type safe languages (Java, ML). Legacy code?
o  Mark stack as non-execute. Random stack location.
o  Static source code analysis.
o  Run time checking: StackGuard, Libsafe, SafeC,
  (Purify).
o Black box testing (e.g. eEye Retina, ISIC ).
                                                          8
Marking stack as non-execute

o Basic stack exploit can be prevented by marking
o     stack segment as non-executable or
o     randomizing stack location.
o Code patches exist for Linux and Solaris.
o      Problems:
o Does not block more general overflow exploits:
o     – Overflow on heap: overflow buffer next to func
  pointer.
o Some apps need executable stack (e.g. LISP
  interpreters).



                                                     9
Static source code analysis

Statically check source to detect buffer overflows.
Several consulting companies.

 Several tools exist:
o @stake (l0pht.com): SLINT (designed for UNIX)
o its4. Scans function calls.
o Wagner. Test constraint violations.
o Engler. Test trust inconsistency.

 Find lots of bugs.


                                                      10
Recent Attacks


o RealPlayer, Helix Player, KM Player vulnerable to
  attack.

o Exploit code released for Adobe Photoshop flaw.
                         News - Security - ZDNet
                         Australia_files




                                                      11
Ad

Recommended

Buffer overflow
Buffer overflow
Evgeni Tsonev
 
6 buffer overflows
6 buffer overflows
drewz lin
 
Buffer overflow attacks
Buffer overflow attacks
Kapil Nagrale
 
Introduction To EMU
Introduction To EMU
Education Front
 
Shell and its types in LINUX
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
Confidentiality policies UNIT 2 (CSS)
Confidentiality policies UNIT 2 (CSS)
Dr. SURBHI SAROHA
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applications
Niyas Nazar
 
Apache ppt
Apache ppt
poornima sugumaran
 
Metasploit framework in Network Security
Metasploit framework in Network Security
Ashok Reddy Medikonda
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Buffer overflow
Buffer overflow
قصي نسور
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
Passes of compilers
Passes of compilers
Vairavel C
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
Omar Bashir
 
Web Application Penetration Testing Introduction
Web Application Penetration Testing Introduction
gbud7
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Applets in java
Applets in java
Wani Zahoor
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Computer Virus.
Computer Virus.
QuratNaeem
 
Introduction of c programming
Introduction of c programming
Tarun Sharma
 
Interface java
Interface java
atiafyrose
 
Assembly language
Assembly language
shashank puthran
 
Deep dive into ssrf
Deep dive into ssrf
n|u - The Open Security Community
 
Sqlmap
Sqlmap
Institute of Information Security (IIS)
 
Open Source Software
Open Source Software
Ali Yavari
 
Basics of Denial of Service Attacks
Basics of Denial of Service Attacks
Hansa Nidushan
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
Java Tokens
Java Tokens
Madishetty Prathibha
 
Control hijacking
Control hijacking
Prachi Gulihar
 
Ch 18: Source Code Auditing
Ch 18: Source Code Auditing
Sam Bowne
 

More Related Content

What's hot (20)

Metasploit framework in Network Security
Metasploit framework in Network Security
Ashok Reddy Medikonda
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Buffer overflow
Buffer overflow
قصي نسور
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
Passes of compilers
Passes of compilers
Vairavel C
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
Omar Bashir
 
Web Application Penetration Testing Introduction
Web Application Penetration Testing Introduction
gbud7
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Applets in java
Applets in java
Wani Zahoor
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Computer Virus.
Computer Virus.
QuratNaeem
 
Introduction of c programming
Introduction of c programming
Tarun Sharma
 
Interface java
Interface java
atiafyrose
 
Assembly language
Assembly language
shashank puthran
 
Deep dive into ssrf
Deep dive into ssrf
n|u - The Open Security Community
 
Sqlmap
Sqlmap
Institute of Information Security (IIS)
 
Open Source Software
Open Source Software
Ali Yavari
 
Basics of Denial of Service Attacks
Basics of Denial of Service Attacks
Hansa Nidushan
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
Java Tokens
Java Tokens
Madishetty Prathibha
 
Metasploit framework in Network Security
Metasploit framework in Network Security
Ashok Reddy Medikonda
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
Passes of compilers
Passes of compilers
Vairavel C
 
An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
Omar Bashir
 
Web Application Penetration Testing Introduction
Web Application Penetration Testing Introduction
gbud7
 
Lesson 2 Understanding Linux File System
Lesson 2 Understanding Linux File System
Sadia Bashir
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Computer Virus.
Computer Virus.
QuratNaeem
 
Introduction of c programming
Introduction of c programming
Tarun Sharma
 
Interface java
Interface java
atiafyrose
 
Open Source Software
Open Source Software
Ali Yavari
 
Basics of Denial of Service Attacks
Basics of Denial of Service Attacks
Hansa Nidushan
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 

Similar to Buffer Overflow Attacks (20)

Control hijacking
Control hijacking
Prachi Gulihar
 
Ch 18: Source Code Auditing
Ch 18: Source Code Auditing
Sam Bowne
 
Secure Coding Practices for Middleware
Secure Coding Practices for Middleware
Manuel Brugnoli
 
Buffer Overflows
Buffer Overflows
Sumit Kumar
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
ahmed8790
 
Stack-Based Buffer Overflows
Stack-Based Buffer Overflows
Daniel Tumser
 
An automated approach to fix buffer overflows
An automated approach to fix buffer overflows
IJECEIAES
 
1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
aryan532920
 
What
What
anity
 
2 buffer overflows
2 buffer overflows
Karthic Rao
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
AllBits BVBA (freelancer)
 
IRJET - Buffer Overflows Attacks & Defense
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
test
test
aaro11
 
Buffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
Buffer overflow tutorial
Buffer overflow tutorial
hughpearse
 
Cruiser pldi2011
Cruiser pldi2011
nytshade15
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
tharindunew
 
1.Buffer Overflows
1.Buffer Overflows
phanleson
 
Ids 008 buffer overflow
Ids 008 buffer overflow
jyoti_lakhani
 
Ch 18: Source Code Auditing
Ch 18: Source Code Auditing
Sam Bowne
 
Secure Coding Practices for Middleware
Secure Coding Practices for Middleware
Manuel Brugnoli
 
Buffer Overflows
Buffer Overflows
Sumit Kumar
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
ahmed8790
 
Stack-Based Buffer Overflows
Stack-Based Buffer Overflows
Daniel Tumser
 
An automated approach to fix buffer overflows
An automated approach to fix buffer overflows
IJECEIAES
 
1Buttercup On Network-based Detection of Polymorphic B.docx
1Buttercup On Network-based Detection of Polymorphic B.docx
aryan532920
 
What
What
anity
 
2 buffer overflows
2 buffer overflows
Karthic Rao
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
AllBits BVBA (freelancer)
 
IRJET - Buffer Overflows Attacks & Defense
IRJET - Buffer Overflows Attacks & Defense
IRJET Journal
 
Buffer overflow attacks
Buffer overflow attacks
Sandun Perera
 
Buffer overflow tutorial
Buffer overflow tutorial
hughpearse
 
Cruiser pldi2011
Cruiser pldi2011
nytshade15
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
tharindunew
 
1.Buffer Overflows
1.Buffer Overflows
phanleson
 
Ids 008 buffer overflow
Ids 008 buffer overflow
jyoti_lakhani
 
Ad

Recently uploaded (20)

National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
The State of Web3 Industry- Industry Report
The State of Web3 Industry- Industry Report
Liveplex
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Ad

Buffer Overflow Attacks

  • 2. What are buffer overflows? • Suppose a web server contains a function: void func(char *str) { char buf[128]; strcpy(buf, str); do-something(buf); } • } When the function is invoked the stack looks like: • What if *str is 136 bytes long? After strcpy 2
  • 3. Basic stack exploit o Main problem: no range checking in strcpy(). o Suppose *str is such that after strcpy stack looks like: o When func() exits, the user will be given a shell !! o Note: attack code runs in stack. o To determine ret guess position of stack when func() is called. 3
  • 4. Some unsafe C lib functions o strcpy (char *dest, const char *src) o strcat (char *dest, const char *src) o gets (char *s) o scanf ( const char *format, … ) o printf (conts char *format, … ) 4
  • 5. Exploiting buffer overflows Suppose web server calls func() with given URL. Attacker can create a 200 byte URL to obtain shell on web server. Some complications: o Program P should not contain the ‘0’ character. o Overflow should not crash program before func() exits. Sample buffer overflow of this type: o Overflow in MIME type field in MS Outlook. 5
  • 6. Causing program to exec attack code o Stack smashing attack: o Override return address in stack activation record by overflowing a local buffer variable. o Function pointers: (used in attack on Linux) o Overflowing buf will override function pointer. o Longjmp buffers: longjmp(pos) (used in attack on Perl 5.003) 6
  • 7. Finding buffer overflows Hackers find buffer overflows as follows: o Run web server on local machine. o Issue requests with long tags. o All long tags end with “$$$$$”. o If web server crashes, o search core dump for “$$$$$” to find o overflow location. o Some automated tools exist. (eEye Retina, ISIC). 7
  • 8. Preventing buf overflow attacks o Main problem: o strcpy(), strcat(), sprintf() have no range checking. o “Safe” versions strncpy(), strncat() are misleading o – strncpy() may leave buffer unterminated. o – strncpy(), strncat() encourage off by 1 bugs. o Defenses: o Type safe languages (Java, ML). Legacy code? o Mark stack as non-execute. Random stack location. o Static source code analysis. o Run time checking: StackGuard, Libsafe, SafeC, (Purify). o Black box testing (e.g. eEye Retina, ISIC ). 8
  • 9. Marking stack as non-execute o Basic stack exploit can be prevented by marking o stack segment as non-executable or o randomizing stack location. o Code patches exist for Linux and Solaris. o Problems: o Does not block more general overflow exploits: o – Overflow on heap: overflow buffer next to func pointer. o Some apps need executable stack (e.g. LISP interpreters). 9
  • 10. Static source code analysis Statically check source to detect buffer overflows. Several consulting companies. Several tools exist: o @stake (l0pht.com): SLINT (designed for UNIX) o its4. Scans function calls. o Wagner. Test constraint violations. o Engler. Test trust inconsistency. Find lots of bugs. 10
  • 11. Recent Attacks o RealPlayer, Helix Player, KM Player vulnerable to attack. o Exploit code released for Adobe Photoshop flaw. News - Security - ZDNet Australia_files 11