SlideShare a Scribd company logo
1 of 11
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

More Related Content

What's hot

6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
drewz lin
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Christian Schneider
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
Ross Wolf
 

What's hot (20)

Web application security part 01
Web application security part 01Web application security part 01
Web application security part 01
 
Buffer overflow attacks
Buffer overflow attacksBuffer overflow attacks
Buffer overflow attacks
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Hash cat
Hash catHash cat
Hash cat
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
 
Secure code
Secure codeSecure code
Secure code
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
 
Reverse engineering malware
Reverse engineering malwareReverse engineering malware
Reverse engineering malware
 
Abusing & Securing XPC in macOS apps
Abusing & Securing XPC in macOS appsAbusing & Securing XPC in macOS apps
Abusing & Securing XPC in macOS apps
 
SQL Injection
SQL InjectionSQL Injection
SQL Injection
 
Secure code practices
Secure code practicesSecure code practices
Secure code practices
 
OWASP Mobile Security: Top 10 Risks for 2017
OWASP Mobile Security: Top 10 Risks for 2017OWASP Mobile Security: Top 10 Risks for 2017
OWASP Mobile Security: Top 10 Risks for 2017
 
Basics of Server Side Template Injection
Basics of Server Side Template InjectionBasics of Server Side Template Injection
Basics of Server Side Template Injection
 
Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)Top 10 Web Security Vulnerabilities (OWASP Top 10)
Top 10 Web Security Vulnerabilities (OWASP Top 10)
 
Ethical Hacking - sniffing
Ethical Hacking - sniffingEthical Hacking - sniffing
Ethical Hacking - sniffing
 
SITCON2021 Web Security 領航之路
SITCON2021  Web Security 領航之路SITCON2021  Web Security 領航之路
SITCON2021 Web Security 領航之路
 
Owasp top 10 vulnerabilities
Owasp top 10 vulnerabilitiesOwasp top 10 vulnerabilities
Owasp top 10 vulnerabilities
 

Similar to Buffer Overflow Attacks

Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
hughpearse
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
Yandex
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
Yandex
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
Sumit Kumar
 

Similar to Buffer Overflow Attacks (20)

Control hijacking
Control hijackingControl hijacking
Control hijacking
 
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
 
Linux binary analysis and exploitation
Linux binary analysis and exploitationLinux binary analysis and exploitation
Linux binary analysis and exploitation
 
Fuzzing: Finding Your Own Bugs and 0days! 2.0
Fuzzing: Finding Your Own Bugs and 0days! 2.0Fuzzing: Finding Your Own Bugs and 0days! 2.0
Fuzzing: Finding Your Own Bugs and 0days! 2.0
 
Buffer overflow – Smashing The Stack
Buffer overflow – Smashing The StackBuffer overflow – Smashing The Stack
Buffer overflow – Smashing The Stack
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
Finding 0days at Arab Security Conference
Finding 0days at Arab Security ConferenceFinding 0days at Arab Security Conference
Finding 0days at Arab Security Conference
 
Buffer Overflow - Smashing the Stack
Buffer Overflow - Smashing the StackBuffer Overflow - Smashing the Stack
Buffer Overflow - Smashing the Stack
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow AttackAnatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW SecurityAllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
 
Report on hacking blind
Report on hacking blindReport on hacking blind
Report on hacking blind
 
Buffer Overflows
Buffer OverflowsBuffer Overflows
Buffer Overflows
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code AuditingCNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
 
Hacking Blind
Hacking BlindHacking Blind
Hacking Blind
 
Hacking blind
Hacking blindHacking blind
Hacking blind
 
fg.workshop: Software vulnerability
fg.workshop: Software vulnerabilityfg.workshop: Software vulnerability
fg.workshop: Software vulnerability
 

Recently uploaded

Recently uploaded (20)

10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 

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