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)

PPTX
C programming language tutorial
PPTX
C_Progragramming_language_Tutorial_ppt_f.pptx
PPT
Security related security analyst ppt.ppt
PPTX
dinoC_ppt.pptx
PPTX
Buffer overflow
PPTX
C Programming Language
PDF
Software Security
PPTX
Rust Hack
ODP
BufferOverflow - Offensive point of View
PPT
2. Data, Operators, IO.ppt
PDF
2010.hari_kannan.phd_thesis.slides.pdf
PPTX
20101017 program analysis_for_security_livshits_lecture03_security
PPTX
PVS-Studio, a solution for resource intensive applications development
PDF
Getting Started with C Programming: A Beginner’s Guide to Syntax, Variables, ...
PDF
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
PPT
Fundamental of C Programming Language and Basic Input/Output Function
PPTX
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
PPT
Stream Based Input Output
PDF
Secure Coding Practices for Middleware
C programming language tutorial
C_Progragramming_language_Tutorial_ppt_f.pptx
Security related security analyst ppt.ppt
dinoC_ppt.pptx
Buffer overflow
C Programming Language
Software Security
Rust Hack
BufferOverflow - Offensive point of View
2. Data, Operators, IO.ppt
2010.hari_kannan.phd_thesis.slides.pdf
20101017 program analysis_for_security_livshits_lecture03_security
PVS-Studio, a solution for resource intensive applications development
Getting Started with C Programming: A Beginner’s Guide to Syntax, Variables, ...
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Fundamental of C Programming Language and Basic Input/Output Function
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
Stream Based Input Output
Secure Coding Practices for Middleware

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
KodekX | Application Modernization Development
PDF
Machine learning based COVID-19 study performance prediction
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Approach and Philosophy of On baking technology
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Network Security Unit 5.pdf for BCA BBA.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
KodekX | Application Modernization Development
Machine learning based COVID-19 study performance prediction
Chapter 3 Spatial Domain Image Processing.pdf
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Building Integrated photovoltaic BIPV_UPV.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Digital-Transformation-Roadmap-for-Companies.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Approach and Philosophy of On baking technology

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