SlideShare a Scribd company logo
Format String
Vulnerability
By Rakesh P
Amrita University
→ Rakesh Paruchuri (nuc13us)
Security Enthusiast→
Love playing CTFs (team bi0s)→
Intern with Amrita Center→
for Cyber Security
Outline:
→ Background
→ Introduction
→ Format string functions
→ Format specifiers
→ How printf works?
→ Exploiting format string
→ Format string vulnerability (vs)
Buffer overflow
Background
What is a vulnerability ?
Binary Exploitation ?
●
Buffer Overflow
●
Heap Overflow
●
Format string and many more..
Lets go a little deep into Format String
Program in execution
Executable section: TEXT
– The actual code that will be
executed
●
Initialized data: DATA
– Global variables
●
Uninitialized data: BSS
●
Local variables: Stack
Stack view during function calls
Stack
…....
10. push j
11. push i
12. call add
13. add esp, 0x8
……
20. add:
21. mov eax, [esp+0x4]
22. mov ebx, [esp+0x8]
23. add eax, ebx
24. ret
Stack
0XDEADCAFE
Higher address
Lower address
How printf works
●
Printf can take variable number of arguments.
– printf(<format string>,......);
●
Arguments must be stored in the stack.
●
Those arguments are accused through format specifiers that
are given the format string.
●
Format string = “%d” → assumes that there is one argument
●
(“%s %d”) → two arguments
Format String Functions
int printf(const char *format, ...);
int fprintf(FILE *stream, const char *format, ...);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, size_t size, const char *format, …);
Format Specifiers
Format Specifier Description Passed as
%d decimal value
%u Unsigned decimal value
%s String reference
%x hexadecimal value
%n Write number of bytes
written so far
reference
Exploiting Format String
What format string vulnerability can lead to?
●
View the process memory
●
Crash a program
●
Overwrite instruction pointer or process memory location with
malicious data
Format String Vulnerability (vs) Buffer
overflow
Buffer Overflow Format string
Discovered in 1980’s Discovered in 1999
Number of exploits are in
thousands
Number of exploits are very less
Security threat Programmers mistake
Difficult to find out Easy to find
Attacks on Format String:
Sudo - (privilege escalation)
Peanch - instant messaging program
CUPS- Printing system for unix
CVE-2016-4448:
Format string vulnerability in libxml2 before 2.9.4
allows attackers to have unspecified impact via
format string specifiers
Format string vunerability

More Related Content

PPTX
C format string vulnerability
PDF
2.Format Strings
PPTX
miniLesson on the printf() function
PPTX
Error correction-and-type-of-error-in-c
PPTX
Control hijacking
PPT
Buffer Overflows
PDF
Buffer overflow null
PDF
C programming day#1
C format string vulnerability
2.Format Strings
miniLesson on the printf() function
Error correction-and-type-of-error-in-c
Control hijacking
Buffer Overflows
Buffer overflow null
C programming day#1

What's hot (20)

PDF
Presentation buffer overflow attacks and theircountermeasures
PDF
File Handling in C Programming
PDF
Common mistakes in C programming
PDF
Format string vunerability
PPT
C introduction
PPT
Advanced+pointers
PDF
TDD in C - Recently Used List Kata
PPT
Mesics lecture 5 input – output in ‘c’
DOCX
PDF
Introduction to Python Programming | InsideAIML
PDF
2 data and c
PPT
C tutorial
PPTX
Loops in Python
DOC
C operators
PPTX
Buffer Overflow Demo by Saurabh Sharma
PPT
Lecture 8- Data Input and Output
PDF
Types of pointer in C
PPT
Unit1 C
PPT
CPU INPUT OUTPUT
Presentation buffer overflow attacks and theircountermeasures
File Handling in C Programming
Common mistakes in C programming
Format string vunerability
C introduction
Advanced+pointers
TDD in C - Recently Used List Kata
Mesics lecture 5 input – output in ‘c’
Introduction to Python Programming | InsideAIML
2 data and c
C tutorial
Loops in Python
C operators
Buffer Overflow Demo by Saurabh Sharma
Lecture 8- Data Input and Output
Types of pointer in C
Unit1 C
CPU INPUT OUTPUT
Ad

Viewers also liked (7)

ODP
Format string Attack
PPTX
CTFを楽しむやで
PDF
シェル芸初心者によるシェル芸入門 (修正版)
PDF
Summary of "Hacking", 0x351-0x354
PDF
Trend Micro CTF Asia Pacific & Japan -defensive100-
PDF
CTF初心者🔰
PDF
CTF for ビギナーズ バイナリ講習資料
Format string Attack
CTFを楽しむやで
シェル芸初心者によるシェル芸入門 (修正版)
Summary of "Hacking", 0x351-0x354
Trend Micro CTF Asia Pacific & Japan -defensive100-
CTF初心者🔰
CTF for ビギナーズ バイナリ講習資料
Ad

Similar to Format string vunerability (20)

PDF
Format string
PPTX
Format String Attack
PPTX
[MOSUT] Format String Attacks
PDF
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
PDF
CNIT 127: 4: Format string bugs
PDF
CNIT 127 Ch 4: Introduction to format string bugs
PDF
CNIT 127 Ch 4: Introduction to format string bugs
PDF
CNIT 127: Ch 4: Introduction to format string bugs
PDF
Exploitation Crash Course
PDF
CNIT 127 Ch 4: Introduction to format string bugs
PPT
Buffer OverFlow
DOCX
C tutoria input outputl
PPTX
Format String
PDF
4 text file
PDF
Advanced Arm Exploitation
PDF
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
PDF
Introduction to Input/Output Functions in C
PPTX
Introduction about Low Level Programming using C
PDF
Chapter 13.1.10
PPTX
ARRAY's in C Programming Language PPTX.
Format string
Format String Attack
[MOSUT] Format String Attacks
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127: 4: Format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127: Ch 4: Introduction to format string bugs
Exploitation Crash Course
CNIT 127 Ch 4: Introduction to format string bugs
Buffer OverFlow
C tutoria input outputl
Format String
4 text file
Advanced Arm Exploitation
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
Introduction to Input/Output Functions in C
Introduction about Low Level Programming using C
Chapter 13.1.10
ARRAY's in C Programming Language PPTX.

Recently uploaded (20)

PDF
Getting Started with Data Integration: FME Form 101
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Empathic Computing: Creating Shared Understanding
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Getting Started with Data Integration: FME Form 101
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx
TLE Review Electricity (Electricity).pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
cloud_computing_Infrastucture_as_cloud_p
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Heart disease approach using modified random forest and particle swarm optimi...
Group 1 Presentation -Planning and Decision Making .pptx
Tartificialntelligence_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm

Format string vunerability

  • 2. → Rakesh Paruchuri (nuc13us) Security Enthusiast→ Love playing CTFs (team bi0s)→ Intern with Amrita Center→ for Cyber Security
  • 3. Outline: → Background → Introduction → Format string functions → Format specifiers → How printf works? → Exploiting format string → Format string vulnerability (vs) Buffer overflow
  • 4. Background What is a vulnerability ? Binary Exploitation ? ● Buffer Overflow ● Heap Overflow ● Format string and many more.. Lets go a little deep into Format String
  • 5. Program in execution Executable section: TEXT – The actual code that will be executed ● Initialized data: DATA – Global variables ● Uninitialized data: BSS ● Local variables: Stack
  • 6. Stack view during function calls
  • 7. Stack ….... 10. push j 11. push i 12. call add 13. add esp, 0x8 …… 20. add: 21. mov eax, [esp+0x4] 22. mov ebx, [esp+0x8] 23. add eax, ebx 24. ret Stack 0XDEADCAFE Higher address Lower address
  • 8. How printf works ● Printf can take variable number of arguments. – printf(<format string>,......); ● Arguments must be stored in the stack. ● Those arguments are accused through format specifiers that are given the format string. ● Format string = “%d” → assumes that there is one argument ● (“%s %d”) → two arguments
  • 9. Format String Functions int printf(const char *format, ...); int fprintf(FILE *stream, const char *format, ...); int sprintf(char *str, const char *format, ...); int snprintf(char *str, size_t size, const char *format, …);
  • 10. Format Specifiers Format Specifier Description Passed as %d decimal value %u Unsigned decimal value %s String reference %x hexadecimal value %n Write number of bytes written so far reference
  • 12. What format string vulnerability can lead to? ● View the process memory ● Crash a program ● Overwrite instruction pointer or process memory location with malicious data
  • 13. Format String Vulnerability (vs) Buffer overflow Buffer Overflow Format string Discovered in 1980’s Discovered in 1999 Number of exploits are in thousands Number of exploits are very less Security threat Programmers mistake Difficult to find out Easy to find
  • 14. Attacks on Format String: Sudo - (privilege escalation) Peanch - instant messaging program CUPS- Printing system for unix CVE-2016-4448: Format string vulnerability in libxml2 before 2.9.4 allows attackers to have unspecified impact via format string specifiers