Format String Vulnerability
Passing attacker-controlled text as a format string to printf-style calls.
What it is
A flaw where untrusted input is used directly as the format argument of a formatting function. Conversion specifiers in the input let an attacker read from or write to memory through the formatting machinery.
Why it matters
Format string bugs can leak memory and even perform writes, providing both an info leak and a corruption primitive in one. They are easy to introduce and easy to spot in code review once the pattern is known.
In practice
Logging user input with printf(user_input) instead of printf("%s", user_input), letting %x leak stack values and %n write to memory.
What to look for
- printf style calls with input as the format.
- %n or %x sequences in logs or input fields.
- Compiler warnings about non literal format strings.
Common mistake
Ignoring the compiler warning. It points straight at the bug.
Practice it nearby
CyberKit has no tool for this term itself. These are the closest places to practice it.
- Risk Scoring
Score a vulnerability with CVSS v3.1, or an incident across five dimensions, and see the reasoning behind each number.
- Map and Score
Map real procedures to ATT&CK techniques, then pick the CVSS v3.1 metrics for real vulnerabilities.
In the field
Well-known tools where this shows up on the job. They are listed to show the landscape, not as a recommendation.
-
Nessus Commercial
A vulnerability scanner that checks hosts for known flaws and missing patches.
-
Qualys VMDR Commercial
A cloud platform that scans assets and ranks vulnerabilities for patching.
-
OpenVAS Open source
An open source vulnerability scanner with a large set of checks.
-
Nuclei Open source
Runs community templates that test for specific, newly published flaws.
Read next
- Information Leak: Disclosing memory contents to defeat randomization or steal secrets.
- Write-What-Where Condition: Controlling both the value written and the address it lands at.
- Arbitrary Read/Write Primitive: The ability to read or write any chosen memory address at will.