SlideShare a Scribd company logo
Buffer Overflows OWASP Bangalore 11 th  Jan, 2009
Agenda Introduction What, How & Why? Guidelines Are you vulnerable? What to do or not to do? Vulnerability History Demo (in next session)
Buffer overflow Pushing data more than the capacity of a buffer Manipulating execution stack to reveal/modify process specific data Few examples: strcpy(target_buffer,large_string); printf(str_ptr); /*unescaped data from str_ptr*/
…so? Arbitrary shell code can be injected as user input RET address can be changed to execute the arbitrary code Do anything afterwards… Worst if the vulnerable application was running in “root”/”superuser” mode
Types of Buffer Overflow Stack Overflow Heap Overflow Integer Overflow Format String Overflow Unicode Overflow
Function Calls and Stacks Uses stacks to evaluate functions foo(bar(delta(arg1, arg2,…))) foo1(bar1(arg1), delta1(arg1, arg2,…)) From L->R LIFO
Example int sum(int a,int b){ return a+b; } int main(){ int a[5]; a[0]=sum(15,13); } … sum: pushl  %ebp movl  %esp, %ebp movl  12(%ebp), %eax addl  8(%ebp), %eax leave ret … main: pushl  %ebp movl  %esp, %ebp subl  $40, %esp … . pushl  $13 pushl  $15 call  sum addl  $8, %esp movl  %eax, -40(%ebp) leave ret
RET address FP or BP 13 15 … sum: pushl  %ebp movl  %esp, %ebp movl  12(%ebp), %eax addl  8(%ebp), %eax leave ret … main: pushl  %ebp movl  %esp, %ebp subl  $40, %esp … . pushl  $13 pushl  $15 call  sum addl  $8, %esp movl  %eax, -40(%ebp) leave ret
#include <string.h>  void f(char* s) {  char buffer[10];  strcpy(buffer, s);  }  void main(void) {  f(&quot;01234567890123456789&quot;);  }  [root /tmp]# ./stacktest  Segmentation fault   Attempted to overwrite other sections of the executable
Heap Overflow When data is written beyond the boundaries in the heap Overflow strcpy(a,long_string); Similar to stack overflows 0xB1 0xB8 Array a[8] Array b[11] 0xC2 0xCC
Integer Overflow Arithmetic overflows Processors have fixed width word size 8-bit processor can handle 0 to 255 or -127 to +127 16-bit processor can handle 0 to 65535 or -32767 to +32767 A value beyond the range, causes overflow
#include <stdio.h>  #include <string.h>  void main(int argc, char *argv[]) {  int i = atoi(argv[1]); // input from user  unsigned short s = i; // truncate to a short  char buf[50]; // large buffer  if (s > 10) { // check we're not greater than 10  return;  }  memcpy(buf, argv[2], i); // copy i bytes to the buffer  buf[i] = '\0'; // add a null byte to the buffer  printf(&quot;%s\n&quot;, buf); // output the buffer contents  return;  }  [root /tmp]# ./inttest 65580 foobar  Segmentation fault
Format String Overflow Takes advantage of functions which mix data with control information “ %x” – Read data from stack “ %s” – Read string from process memory “ %n” – Write an integer to locations in process memory “ %p” – representation of a memory location Ex:  fprint, fprintf, sprintf, snprintf  vfprintf, vprintf, vsprintf, vsnprintf a user input can be formatted to access values from the stack, e.g.  printf(“%08x.%08x.%08x.%08x.%08x”) will print top 5 stack values
Unicode Overflow Windows APIs often convert input string into Unicode before using them Input can be convoluted to cause an overflow and manipulate exception handlers Unicode conversion may generate special interrupt instructions on the stack
Are you vulnerable? Yes likely, if your code: uses low level languages like C/C++ directly accesses memory  interacts with OS activities and process stacks However: reduces risk if you know what you are doing!! Not likely, if your code uses high level languages like Java, .NET
What to do or not to do? Know thy code!!! Use safe functions strncpy instead of strcpy, strncat instead of strcat, snprintf instead of sprintf etc. Grant processes least required privileges to run Be a paranoid  don’t trust user inputs  always validate Do comprehensive code auditing and reviews. Use static code analysis tools: RATS, findbugs, flawfinder Use compiler tools: StackShield, StackGuard and Libsafe
Compiler tools StackGuard Uses an extra canary word (4-bytes) to verify if stack is intact 0x000D0AFF (0x00 NULL, 0x0D CR, 0x0A LF, 0xFF EOF) Or a random number difficult to predict StackShield Copies the expected return address in a different stack for later verification LibSafe intercepts all calls to vulnerable library functions and substitutes a corresponding version that implements the original functionality still contains any buffer overflows within the current stack frame
Vulnerability Metrics
(Recent) History Quite many incidents RealPlayer ActiveX Import Method Buffer Overflow (July 2008) Microsoft GDI Stack Overflow Vulnerability (Aug 2008) Heap based buffer overflow in QuickTime and iTunes (Sep 2008) Adobe Reader Javascript Printf Buffer Overflow (Nov 2008)
Reporting http://www.cert.org/vuls/ http:// www.adobe.com/misc/securityform.html http://www.microsoft.com/technet/security/bulletin/alertus.aspx http://www.apple.com/support/security/
References http:// www.owasp.org/index.php/Buffer_Overflows https://www.securecoding.cert.org/confluence/display/seccode/CERT+Secure+Coding+Standards Also updated at  http ://www.owasp.org/index.php/Buffer_Overflows
Ad

Recommended

Buffer overflow attacks
Buffer overflow attacks
Kapil Nagrale
 
SSRF For Bug Bounties
SSRF For Bug Bounties
OWASP Nagpur
 
Deep dive into ssrf
Deep dive into ssrf
n|u - The Open Security Community
 
SSRF workshop
SSRF workshop
Ivan Novikov
 
SQL injection
SQL injection
Raj Parmar
 
Buffer overflow attacks
Buffer overflow attacks
Joe McCarthy
 
Sqlmap
Sqlmap
Rushikesh Kulkarni
 
6 buffer overflows
6 buffer overflows
drewz lin
 
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
Aj MaChInE
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackrose
Noaman Aziz
 
SQL Injection
SQL Injection
Adhoura Academy
 
SQL INJECTION
SQL INJECTION
Anoop T
 
Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)
Abhinav Mishra
 
Introduction to Python for Security Professionals
Introduction to Python for Security Professionals
Andrew McNicol
 
Working with Methods in Java.pptx
Working with Methods in Java.pptx
maryansagsgao
 
Sql injection in cybersecurity
Sql injection in cybersecurity
Sanad Bhowmik
 
PHP - Introduction to File Handling with PHP
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
Burp suite
Burp suite
SOURABH DESHMUKH
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Java String class
Java String class
DrRajeshreeKhande
 
Security Testing Training With Examples
Security Testing Training With Examples
Alwin Thayyil
 
Sql injections - with example
Sql injections - with example
Prateek Chauhan
 
Regular expressions in Python
Regular expressions in Python
Sujith Kumar
 
Password (in)security
Password (in)security
Enrico Zimuel
 
Bug Bounty 101
Bug Bounty 101
Shahee Mirza
 
Java Exception handling
Java Exception handling
kamal kotecha
 
C Programming Unit-5
C Programming Unit-5
Vikram Nandini
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object Reference
Narudom Roongsiriwong, CISSP
 
Buffer OverFlow
Buffer OverFlow
Rambabu Duddukuri
 
What
What
anity
 

More Related Content

What's hot (20)

[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
Aj MaChInE
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackrose
Noaman Aziz
 
SQL Injection
SQL Injection
Adhoura Academy
 
SQL INJECTION
SQL INJECTION
Anoop T
 
Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)
Abhinav Mishra
 
Introduction to Python for Security Professionals
Introduction to Python for Security Professionals
Andrew McNicol
 
Working with Methods in Java.pptx
Working with Methods in Java.pptx
maryansagsgao
 
Sql injection in cybersecurity
Sql injection in cybersecurity
Sanad Bhowmik
 
PHP - Introduction to File Handling with PHP
PHP - Introduction to File Handling with PHP
Vibrant Technologies & Computers
 
Burp suite
Burp suite
SOURABH DESHMUKH
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Java String class
Java String class
DrRajeshreeKhande
 
Security Testing Training With Examples
Security Testing Training With Examples
Alwin Thayyil
 
Sql injections - with example
Sql injections - with example
Prateek Chauhan
 
Regular expressions in Python
Regular expressions in Python
Sujith Kumar
 
Password (in)security
Password (in)security
Enrico Zimuel
 
Bug Bounty 101
Bug Bounty 101
Shahee Mirza
 
Java Exception handling
Java Exception handling
kamal kotecha
 
C Programming Unit-5
C Programming Unit-5
Vikram Nandini
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object Reference
Narudom Roongsiriwong, CISSP
 
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
Aj MaChInE
 
Sql injection bypassing hand book blackrose
Sql injection bypassing hand book blackrose
Noaman Aziz
 
SQL INJECTION
SQL INJECTION
Anoop T
 
Insecure direct object reference (null delhi meet)
Insecure direct object reference (null delhi meet)
Abhinav Mishra
 
Introduction to Python for Security Professionals
Introduction to Python for Security Professionals
Andrew McNicol
 
Working with Methods in Java.pptx
Working with Methods in Java.pptx
maryansagsgao
 
Sql injection in cybersecurity
Sql injection in cybersecurity
Sanad Bhowmik
 
Secure Code Warrior - Cross site scripting
Secure Code Warrior - Cross site scripting
Secure Code Warrior
 
Security Testing Training With Examples
Security Testing Training With Examples
Alwin Thayyil
 
Sql injections - with example
Sql injections - with example
Prateek Chauhan
 
Regular expressions in Python
Regular expressions in Python
Sujith Kumar
 
Password (in)security
Password (in)security
Enrico Zimuel
 
Java Exception handling
Java Exception handling
kamal kotecha
 
OWASP Top 10 A4 – Insecure Direct Object Reference
OWASP Top 10 A4 – Insecure Direct Object Reference
Narudom Roongsiriwong, CISSP
 

Similar to Buffer Overflows (20)

Buffer OverFlow
Buffer OverFlow
Rambabu Duddukuri
 
What
What
anity
 
Buffer overflow explained
Buffer overflow explained
Teja Babu
 
2 buffer overflows
2 buffer overflows
Karthic Rao
 
Software Security
Software Security
Roman Oliynykov
 
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
ahmed8790
 
antoanthongtin_Lesson 3- Software Security (1).pptx
antoanthongtin_Lesson 3- Software Security (1).pptx
23162024
 
Advanced Arm Exploitation
Advanced Arm Exploitation
Himanshu Khokhar Jaat
 
Buffer overflow
Buffer overflow
Evgeni Tsonev
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
Buffer Overflow Attacks
Buffer Overflow Attacks
harshal kshatriya
 
Secure Coding Practices for Middleware
Secure Coding Practices for Middleware
Manuel Brugnoli
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
tharindunew
 
Control hijacking
Control hijacking
Prachi Gulihar
 
1.Buffer Overflows
1.Buffer Overflows
phanleson
 
BufferOverflow - Offensive point of View
BufferOverflow - Offensive point of View
Toe Khaing
 
Exploiting Memory Overflows
Exploiting Memory Overflows
Ankur Tyagi
 
Buffer overflow null
Buffer overflow null
nullowaspmumbai
 
Stack-Based Buffer Overflows
Stack-Based Buffer Overflows
Daniel Tumser
 
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Dr. Ramchandra Mangrulkar
 
What
What
anity
 
Buffer overflow explained
Buffer overflow explained
Teja Babu
 
2 buffer overflows
2 buffer overflows
Karthic Rao
 
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
ahmed8790
 
antoanthongtin_Lesson 3- Software Security (1).pptx
antoanthongtin_Lesson 3- Software Security (1).pptx
23162024
 
Ceh v5 module 20 buffer overflow
Ceh v5 module 20 buffer overflow
Vi Tính Hoàng Nam
 
Secure Coding Practices for Middleware
Secure Coding Practices for Middleware
Manuel Brugnoli
 
Presentation buffer overflow attacks and theircountermeasures
Presentation buffer overflow attacks and theircountermeasures
tharindunew
 
1.Buffer Overflows
1.Buffer Overflows
phanleson
 
BufferOverflow - Offensive point of View
BufferOverflow - Offensive point of View
Toe Khaing
 
Exploiting Memory Overflows
Exploiting Memory Overflows
Ankur Tyagi
 
Stack-Based Buffer Overflows
Stack-Based Buffer Overflows
Daniel Tumser
 
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Lecture #15: Buffer Overflow Attack (Non Malicious Attack)
Dr. Ramchandra Mangrulkar
 
Ad

Recently uploaded (20)

The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
The Growing Value and Application of FME & GenAI
The Growing Value and Application of FME & GenAI
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Ad

Buffer Overflows

  • 1. Buffer Overflows OWASP Bangalore 11 th Jan, 2009
  • 2. Agenda Introduction What, How & Why? Guidelines Are you vulnerable? What to do or not to do? Vulnerability History Demo (in next session)
  • 3. Buffer overflow Pushing data more than the capacity of a buffer Manipulating execution stack to reveal/modify process specific data Few examples: strcpy(target_buffer,large_string); printf(str_ptr); /*unescaped data from str_ptr*/
  • 4. …so? Arbitrary shell code can be injected as user input RET address can be changed to execute the arbitrary code Do anything afterwards… Worst if the vulnerable application was running in “root”/”superuser” mode
  • 5. Types of Buffer Overflow Stack Overflow Heap Overflow Integer Overflow Format String Overflow Unicode Overflow
  • 6. Function Calls and Stacks Uses stacks to evaluate functions foo(bar(delta(arg1, arg2,…))) foo1(bar1(arg1), delta1(arg1, arg2,…)) From L->R LIFO
  • 7. Example int sum(int a,int b){ return a+b; } int main(){ int a[5]; a[0]=sum(15,13); } … sum: pushl %ebp movl %esp, %ebp movl 12(%ebp), %eax addl 8(%ebp), %eax leave ret … main: pushl %ebp movl %esp, %ebp subl $40, %esp … . pushl $13 pushl $15 call sum addl $8, %esp movl %eax, -40(%ebp) leave ret
  • 8. RET address FP or BP 13 15 … sum: pushl %ebp movl %esp, %ebp movl 12(%ebp), %eax addl 8(%ebp), %eax leave ret … main: pushl %ebp movl %esp, %ebp subl $40, %esp … . pushl $13 pushl $15 call sum addl $8, %esp movl %eax, -40(%ebp) leave ret
  • 9. #include <string.h> void f(char* s) { char buffer[10]; strcpy(buffer, s); } void main(void) { f(&quot;01234567890123456789&quot;); } [root /tmp]# ./stacktest Segmentation fault Attempted to overwrite other sections of the executable
  • 10. Heap Overflow When data is written beyond the boundaries in the heap Overflow strcpy(a,long_string); Similar to stack overflows 0xB1 0xB8 Array a[8] Array b[11] 0xC2 0xCC
  • 11. Integer Overflow Arithmetic overflows Processors have fixed width word size 8-bit processor can handle 0 to 255 or -127 to +127 16-bit processor can handle 0 to 65535 or -32767 to +32767 A value beyond the range, causes overflow
  • 12. #include <stdio.h> #include <string.h> void main(int argc, char *argv[]) { int i = atoi(argv[1]); // input from user unsigned short s = i; // truncate to a short char buf[50]; // large buffer if (s > 10) { // check we're not greater than 10 return; } memcpy(buf, argv[2], i); // copy i bytes to the buffer buf[i] = '\0'; // add a null byte to the buffer printf(&quot;%s\n&quot;, buf); // output the buffer contents return; } [root /tmp]# ./inttest 65580 foobar Segmentation fault
  • 13. Format String Overflow Takes advantage of functions which mix data with control information “ %x” – Read data from stack “ %s” – Read string from process memory “ %n” – Write an integer to locations in process memory “ %p” – representation of a memory location Ex: fprint, fprintf, sprintf, snprintf vfprintf, vprintf, vsprintf, vsnprintf a user input can be formatted to access values from the stack, e.g. printf(“%08x.%08x.%08x.%08x.%08x”) will print top 5 stack values
  • 14. Unicode Overflow Windows APIs often convert input string into Unicode before using them Input can be convoluted to cause an overflow and manipulate exception handlers Unicode conversion may generate special interrupt instructions on the stack
  • 15. Are you vulnerable? Yes likely, if your code: uses low level languages like C/C++ directly accesses memory interacts with OS activities and process stacks However: reduces risk if you know what you are doing!! Not likely, if your code uses high level languages like Java, .NET
  • 16. What to do or not to do? Know thy code!!! Use safe functions strncpy instead of strcpy, strncat instead of strcat, snprintf instead of sprintf etc. Grant processes least required privileges to run Be a paranoid don’t trust user inputs always validate Do comprehensive code auditing and reviews. Use static code analysis tools: RATS, findbugs, flawfinder Use compiler tools: StackShield, StackGuard and Libsafe
  • 17. Compiler tools StackGuard Uses an extra canary word (4-bytes) to verify if stack is intact 0x000D0AFF (0x00 NULL, 0x0D CR, 0x0A LF, 0xFF EOF) Or a random number difficult to predict StackShield Copies the expected return address in a different stack for later verification LibSafe intercepts all calls to vulnerable library functions and substitutes a corresponding version that implements the original functionality still contains any buffer overflows within the current stack frame
  • 19. (Recent) History Quite many incidents RealPlayer ActiveX Import Method Buffer Overflow (July 2008) Microsoft GDI Stack Overflow Vulnerability (Aug 2008) Heap based buffer overflow in QuickTime and iTunes (Sep 2008) Adobe Reader Javascript Printf Buffer Overflow (Nov 2008)
  • 20. Reporting http://www.cert.org/vuls/ http:// www.adobe.com/misc/securityform.html http://www.microsoft.com/technet/security/bulletin/alertus.aspx http://www.apple.com/support/security/
  • 21. References http:// www.owasp.org/index.php/Buffer_Overflows https://www.securecoding.cert.org/confluence/display/seccode/CERT+Secure+Coding+Standards Also updated at http ://www.owasp.org/index.php/Buffer_Overflows