SlideShare a Scribd company logo
COUNTERMEASURES AGAINST
BUFFER OVERFLOW ATTACKS
DATA EXECUTION PREVENTION
(DEP)
SECURITY ASSESSMENT
BY AMAR MYANA
TOPICS OF DISCUSSION
• Buffer Overflow Attacks
• Stack Smashing
• Heap Overflows
• Off-By-One ( a classic programmers error )
• Countermeasures against buffer overflow attacks
• Language Level
• Source Code Level
• Compiler Level
• Operating System Level
• DEP || Executable Space Protection || ( NX || XD ) bit
• Security Audits, Vulnerability Assessments and Penetration Testing
BUFFER OVERFLOW ATTACKS
• The term buffe r refers to an allocated chunk of memory, such as a pointer,
array or string.
• Ex:
void f() {
int a[10] ;
a[20] = 3;
}
• Two conditions must be fulfilled:
•The attacker must be able to control the data written into the buffer.
•There must be security sensitive variables stored after the buffer in memory.
VARIABLE ATTACKS
int main(int argc, char *argv[]) {
char passwd_ok = 0;
char passwd[8];
strcpy(passwd, argv[1]);
if (strcmp(passwd, “amar”) == 0)
passwd_ok = 1;
if (passwd_ok) {
…
}
•The strcpy function makes no check that argv[1] contains at most 8 chars, so an
attacker that passes a longer string can overflow the passwd buffer.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
STACK & HEAP OVERFLOW
• When a function is called in C, the caller begins by pushing the
function parameters to the stack. Thereafter, the caller pushes the
address of its next instruction --- the address where execution should
continue when the function returns --- to the stack and jumps to the
function. The callee, in turn, makes room on the stack for its local
variables.
• The attacker can in fact call any function in the program or in the
libraries used by it.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
COUNTERMEASURES
• Prevent use of dangerous functions: gets, strcpy, etc.
• Stack Based
• Adding redundant information/routines to protect the stack or parts of stack.
• Ex: StackGuard
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
STACK GUARD
• A simple approach to protect programs against stack smashing and
with little modification against EBP overflows.
• This is achieved by a compiler extension that adds so called canary
values before the EIP saved at the function.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
LIBSAFE & LIBVERIFY
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
• LIBSAFE
• A transparent approach set up in a DLL that replaces standard(vulnerable)
functions by standard bounds checked functions
• Ex: strcpy could be replaced by strncpy
• The upper limit of the bounds is calculated based on the EBP, so the maximm
amount written to a buffer is the size of the stackframe.
• LIBVERIFY
• Similar to Stackguard
• It implements a wrapper function that saves the copy of the canaries to a canary
stack.
OTHER PROTECTION MECHANISM
• Use static or dynamic source code analyzers at the source code level
to check the code for buffer overflow problems
• Change the compiler at the compiler level that does bounds checking
or protect addresses from overwriting
• Change the rules at that operating system level for which the memory
pages are allowed to hold executable data.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
DATA EXECUTION PREVENTION
• Data Execution Prevention (DEP) is a set of hardware and software
technologies that perform additional checks on memory to help
prevent malicious code from running on a system.
• The primary benefit of DEP is to help prevent code execution from
data pages.
• HARDWARE ENFORCED DEP
• Hardware-enforced DEP marks all memory locations in a process as non-
executable unless the location explicitly contains executable code.
• Hardware-enforced DEP relies on processor hardware to mark memory with an
attribute that indicates that code should not be executed from that memory.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
DEP
• Beginning with Windows XP SP2, the 32-bit version of Windows uses one of the
following:
• The no-execute page-protection (NX) processor feature as defined by AMD.
• The Execute Disable Bit (XD) feature as defined by Intel.
• SOFTWARE ENFORCED DEP
• Software-enforced DEP runs on any processor.
• By default, software-enforced DEP helps protect only limited system binaries,
regardless of the hardware-enforced DEP capabilities of the processor.
• BENEFITS
• DEP can help block a class of security intrusions. Specifically, DEP can help
block a malicious program in which a virus or other type of attack has injected a
process with additional code and then tries to run the injected code. 
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
SECURITY ASSESSMENT
• Every organization uses different types of security assessments to
validate the level of security on its network resources.
• Security assessment is broadly divided into three categories:
• SECURITY AUDITs
• Focus on the people and processes used to design, implement, and manage
security on a network.
• You can perform a manual assessment by using the following techniques:
• Interviewing the staff
• Reviewing application and operating systems access controls
• Analyzing physical access to the systems.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
SECURITY ASSESSMENT
• You can perform an automatic assessment by using the following techniques:
• Generating audit reports
• Monitoring and reporting the changes in the files
• VULNERABILITY ASSESSMENTs
• Helps in identifying known security vulnerabilities by scanning a network
• Vulnerability scanners can test systems and network devices for exposure to
common attacks.
• Attacks on security related information and denial of service attacks.
• Host-based scanners look for features such as weak file access permissions,
poor passwords, and logging faults.
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
SECURITY ASSESSMENT
• PENETRATION TESTING
• A penetration test will not only point out vulnerabilities, it will also document how
the weaknesses can be exploited and how several minor vulnerabilities can be
escalated by an attacker to compromise a computer or network.
• Penetration tests can reveal whether employees routinely allow people without
identification to enter company facilities and where they would have physical
access to computers.
• Reveal process problems ( Not applying security updates )
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
THANK YOU!
The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 

More Related Content

PPTX
[CB16] COFI break – Breaking exploits with Processor trace and Practical cont...
PPTX
Anatomy of a Buffer Overflow Attack
PPTX
Exploitation techniques and fuzzing
PDF
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
PDF
Practical Malware Analysis: Ch 8: Debugging
PPTX
Buffer overflow attacks
PPTX
Ethical hacking Chapter 6 - Port Scanning - Eric Vanderburg
PDF
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
[CB16] COFI break – Breaking exploits with Processor trace and Practical cont...
Anatomy of a Buffer Overflow Attack
Exploitation techniques and fuzzing
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
Practical Malware Analysis: Ch 8: Debugging
Buffer overflow attacks
Ethical hacking Chapter 6 - Port Scanning - Eric Vanderburg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg

What's hot (20)

PPTX
Hacking Blind
PPTX
Buffer overflow
PPTX
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
PDF
Practical Malware Analysis Ch 14: Malware-Focused Network Signatures
PPTX
Two-For-One Talk: Malware Analysis for Everyone
PDF
CNIT 126 11. Malware Behavior
PPTX
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
PDF
Automatic tool for static analysis
PPTX
Introduction to Malware Analysis
PPTX
Buffer overflow attacks
PPTX
Stack-Based Buffer Overflows
PDF
Practical Malware Analysis Ch13
PPT
BSidesJXN 2017 - Improving Vulnerability Management
PPTX
Buffer overflow explained
PPTX
Operating system enhancements to prevent misuse of systems
PDF
Practical Malware Analysis Ch12
PDF
9: OllyDbg
PDF
Применение виртуализации для динамического анализа
PDF
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
PPTX
Threat Modeling: Applied on a Publish-Subscribe Architectural Style
Hacking Blind
Buffer overflow
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis Ch 14: Malware-Focused Network Signatures
Two-For-One Talk: Malware Analysis for Everyone
CNIT 126 11. Malware Behavior
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Automatic tool for static analysis
Introduction to Malware Analysis
Buffer overflow attacks
Stack-Based Buffer Overflows
Practical Malware Analysis Ch13
BSidesJXN 2017 - Improving Vulnerability Management
Buffer overflow explained
Operating system enhancements to prevent misuse of systems
Practical Malware Analysis Ch12
9: OllyDbg
Применение виртуализации для динамического анализа
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Threat Modeling: Applied on a Publish-Subscribe Architectural Style
Ad

Viewers also liked (20)

PPTX
Como ser um Hacker Ético Profissional
PPT
Oracle UCM Security: Challenges and Best Practices
PDF
Patent Risk and Countermeasures Related to Open Management in Interaction Design
PPTX
Improving web application security, part i
PPSX
PPTX
A3 problem solving
PPTX
Antivirus Evasion Techniques and Countermeasures
PDF
Apresenta cyber (2)
PDF
Brigadeiro Engº VenâNcio Alvarenga Gomes
PDF
PDF
Brigadeiro Engº VenâNcio Alvarenga Gomes
PPT
Apresentação Cyberpunk
PPT
Skyjacking A Cisco Wlan Attack Analysis And Countermeasures
PDF
Unpack your troubles*: .NET packer tricks and countermeasures
PPTX
Email phishing and countermeasures
PDF
PPTX
Dstl Medical Countermeasures for Dangerous Pathogens
PPT
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
PDF
Table 4: Unit 4 Reactor: Fukushima Daiichi Nuclear Power Plant - 18 May 2011
PDF
Cehv8 module 01 introduction to ethical hacking
Como ser um Hacker Ético Profissional
Oracle UCM Security: Challenges and Best Practices
Patent Risk and Countermeasures Related to Open Management in Interaction Design
Improving web application security, part i
A3 problem solving
Antivirus Evasion Techniques and Countermeasures
Apresenta cyber (2)
Brigadeiro Engº VenâNcio Alvarenga Gomes
Brigadeiro Engº VenâNcio Alvarenga Gomes
Apresentação Cyberpunk
Skyjacking A Cisco Wlan Attack Analysis And Countermeasures
Unpack your troubles*: .NET packer tricks and countermeasures
Email phishing and countermeasures
Dstl Medical Countermeasures for Dangerous Pathogens
Identifying Web Servers: A First-look Into the Future of Web Server Fingerpri...
Table 4: Unit 4 Reactor: Fukushima Daiichi Nuclear Power Plant - 18 May 2011
Cehv8 module 01 introduction to ethical hacking
Ad

Similar to Buffer Overflow Countermeasures, DEP, Security Assessment (20)

PPTX
Hacking blind
PPTX
Control hijacking
PDF
RIoT (Raiding Internet of Things) by Jacob Holcomb
PPTX
antoanthongtin_Lesson 3- Software Security (1).pptx
PDF
Chapter 1: Introduction to Command Line
PPTX
Chapter 1: Introduction to Command Line
PPTX
Ethical hacking basics
PPTX
Safe Wrappers and Sane Policies for Self Protecting JavaScript
PPTX
CodeChecker Overview Nov 2019
PPTX
Thick client pentesting_the-hackers_meetup_version1.0pptx
ODP
Native client (Евгений Эльцин)
PDF
Ceh v5 module 20 buffer overflow
PDF
z/OS Authorized Code Scanner
PPT
Code Quality - Security
PPTX
Design Like a Pro: Scripting Best Practices
PDF
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
PDF
2010.hari_kannan.phd_thesis.slides.pdf
PPT
ICS PPT Unit 4.ppt
PPTX
PPTX
Design Like a Pro: Scripting Best Practices
Hacking blind
Control hijacking
RIoT (Raiding Internet of Things) by Jacob Holcomb
antoanthongtin_Lesson 3- Software Security (1).pptx
Chapter 1: Introduction to Command Line
Chapter 1: Introduction to Command Line
Ethical hacking basics
Safe Wrappers and Sane Policies for Self Protecting JavaScript
CodeChecker Overview Nov 2019
Thick client pentesting_the-hackers_meetup_version1.0pptx
Native client (Евгений Эльцин)
Ceh v5 module 20 buffer overflow
z/OS Authorized Code Scanner
Code Quality - Security
Design Like a Pro: Scripting Best Practices
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
2010.hari_kannan.phd_thesis.slides.pdf
ICS PPT Unit 4.ppt
Design Like a Pro: Scripting Best Practices

Recently uploaded (20)

PDF
System and Network Administraation Chapter 3
PPTX
L1 - Introduction to python Backend.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Nekopoi APK 2025 free lastest update
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
System and Network Administration Chapter 2
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
top salesforce developer skills in 2025.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
System and Network Administraation Chapter 3
L1 - Introduction to python Backend.pptx
ai tools demonstartion for schools and inter college
Which alternative to Crystal Reports is best for small or large businesses.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Nekopoi APK 2025 free lastest update
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PTS Company Brochure 2025 (1).pdf.......
Digital Systems & Binary Numbers (comprehensive )
CHAPTER 2 - PM Management and IT Context
How to Migrate SBCGlobal Email to Yahoo Easily
System and Network Administration Chapter 2
Wondershare Filmora 15 Crack With Activation Key [2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
top salesforce developer skills in 2025.pdf
Design an Analysis of Algorithms I-SECS-1021-03

Buffer Overflow Countermeasures, DEP, Security Assessment

  • 1. COUNTERMEASURES AGAINST BUFFER OVERFLOW ATTACKS DATA EXECUTION PREVENTION (DEP) SECURITY ASSESSMENT BY AMAR MYANA
  • 2. TOPICS OF DISCUSSION • Buffer Overflow Attacks • Stack Smashing • Heap Overflows • Off-By-One ( a classic programmers error ) • Countermeasures against buffer overflow attacks • Language Level • Source Code Level • Compiler Level • Operating System Level • DEP || Executable Space Protection || ( NX || XD ) bit • Security Audits, Vulnerability Assessments and Penetration Testing
  • 3. BUFFER OVERFLOW ATTACKS • The term buffe r refers to an allocated chunk of memory, such as a pointer, array or string. • Ex: void f() { int a[10] ; a[20] = 3; } • Two conditions must be fulfilled: •The attacker must be able to control the data written into the buffer. •There must be security sensitive variables stored after the buffer in memory.
  • 4. VARIABLE ATTACKS int main(int argc, char *argv[]) { char passwd_ok = 0; char passwd[8]; strcpy(passwd, argv[1]); if (strcmp(passwd, “amar”) == 0) passwd_ok = 1; if (passwd_ok) { … } •The strcpy function makes no check that argv[1] contains at most 8 chars, so an attacker that passes a longer string can overflow the passwd buffer. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 5. STACK & HEAP OVERFLOW • When a function is called in C, the caller begins by pushing the function parameters to the stack. Thereafter, the caller pushes the address of its next instruction --- the address where execution should continue when the function returns --- to the stack and jumps to the function. The callee, in turn, makes room on the stack for its local variables. • The attacker can in fact call any function in the program or in the libraries used by it. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 6. COUNTERMEASURES • Prevent use of dangerous functions: gets, strcpy, etc. • Stack Based • Adding redundant information/routines to protect the stack or parts of stack. • Ex: StackGuard The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 7. STACK GUARD • A simple approach to protect programs against stack smashing and with little modification against EBP overflows. • This is achieved by a compiler extension that adds so called canary values before the EIP saved at the function. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 8. LIBSAFE & LIBVERIFY The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer.  • LIBSAFE • A transparent approach set up in a DLL that replaces standard(vulnerable) functions by standard bounds checked functions • Ex: strcpy could be replaced by strncpy • The upper limit of the bounds is calculated based on the EBP, so the maximm amount written to a buffer is the size of the stackframe. • LIBVERIFY • Similar to Stackguard • It implements a wrapper function that saves the copy of the canaries to a canary stack.
  • 9. OTHER PROTECTION MECHANISM • Use static or dynamic source code analyzers at the source code level to check the code for buffer overflow problems • Change the compiler at the compiler level that does bounds checking or protect addresses from overwriting • Change the rules at that operating system level for which the memory pages are allowed to hold executable data. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 10. DATA EXECUTION PREVENTION • Data Execution Prevention (DEP) is a set of hardware and software technologies that perform additional checks on memory to help prevent malicious code from running on a system. • The primary benefit of DEP is to help prevent code execution from data pages. • HARDWARE ENFORCED DEP • Hardware-enforced DEP marks all memory locations in a process as non- executable unless the location explicitly contains executable code. • Hardware-enforced DEP relies on processor hardware to mark memory with an attribute that indicates that code should not be executed from that memory. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 11. DEP • Beginning with Windows XP SP2, the 32-bit version of Windows uses one of the following: • The no-execute page-protection (NX) processor feature as defined by AMD. • The Execute Disable Bit (XD) feature as defined by Intel. • SOFTWARE ENFORCED DEP • Software-enforced DEP runs on any processor. • By default, software-enforced DEP helps protect only limited system binaries, regardless of the hardware-enforced DEP capabilities of the processor. • BENEFITS • DEP can help block a class of security intrusions. Specifically, DEP can help block a malicious program in which a virus or other type of attack has injected a process with additional code and then tries to run the injected code.  The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 12. SECURITY ASSESSMENT • Every organization uses different types of security assessments to validate the level of security on its network resources. • Security assessment is broadly divided into three categories: • SECURITY AUDITs • Focus on the people and processes used to design, implement, and manage security on a network. • You can perform a manual assessment by using the following techniques: • Interviewing the staff • Reviewing application and operating systems access controls • Analyzing physical access to the systems. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 13. SECURITY ASSESSMENT • You can perform an automatic assessment by using the following techniques: • Generating audit reports • Monitoring and reporting the changes in the files • VULNERABILITY ASSESSMENTs • Helps in identifying known security vulnerabilities by scanning a network • Vulnerability scanners can test systems and network devices for exposure to common attacks. • Attacks on security related information and denial of service attacks. • Host-based scanners look for features such as weak file access permissions, poor passwords, and logging faults. The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer. 
  • 14. SECURITY ASSESSMENT • PENETRATION TESTING • A penetration test will not only point out vulnerabilities, it will also document how the weaknesses can be exploited and how several minor vulnerabilities can be escalated by an attacker to compromise a computer or network. • Penetration tests can reveal whether employees routinely allow people without identification to enter company facilities and where they would have physical access to computers. • Reveal process problems ( Not applying security updates ) The strcpy function makes no check that argv[1] contains at most 8 characters, so an attacker that passes a longer string can overflow the passwd buffer.