WSTG-v42-INPV-13-document-13-Testing_for_Format_String_Injection / GUIDANCE
Testing for Format String Injection (WSTG-INPV-13)
A format string is a null-terminated character sequence that also contains conversion specifiers interpreted or converted at runtime. If server-side code concatenates a user's input with a format string, an attacker can append additional conversion specifiers to cause a runtime error, information disclosure, or buffer overflow. The worst case for format strings vulnerabilities occur in languages that don't check arguments and also include a %n specifier that writes to memory. These functions, if exploited by an attacker modifying a format string, could cause information disclosure and code execution: - C and C++ printf and similar methods fprintf, sprintf, snprintf - Perl printf and sprintf These format string functions cannot write to memory, but attackers can still cause information disclosure by changing format strings to output values the developers did not intend to send: - Python 2.6 and 2.7 str.format and Python 3 unicode str.format can be modified by injecting strings that can point to other variables in memory The following format string functions can cause runtime errors if the attacker adds conversion specifiers: - Java String.format and PrintStream.format - PHP printf The code pattern that causes a format string vulnerability is a call to a string format function that contains unsanitized user input. The following example shows how a debug printf could make a program vulnerable: The example in C: The example in Java: In this particular example, if the attacker set their userName to have one or more conversion specifiers, there would be unwanted behaviour. The C […]
- Category
- OWASP assurance
- Version / scope
- OWASP WSTG pinned commit dd33419
- Affected / relevant technologies
- Web applications
- Evidence
- Documentation: pinned-source excerpt checked. Execution: not tested. Editorial: curated reference.
Defensive analysis and explicitly authorized assessment only. This website performs no scans, exploitation, model calls or infrastructure changes. Indicators below are investigation opportunities, not proof of compromise or guaranteed detectors.
Mechanism and prerequisites
Apply only to authorized systems and select the relevant scope and verification level. This publisher reference is not evidence of a completed assessment.
Potential impact
The publisher describes a verification objective; applicability does not establish a local defect or a compliance result.
Versioned source scope
This record contains normalized, sometimes shortened source excerpts with editorial safety context. Markup and executable example blocks are omitted. Source-field verification does not establish device testing, a working detector or local applicability.
Publisher: OWASP. Release: OWASP WSTG pinned commit dd33419. Source checked: 2026-11-26.
Source object: document/4-Web_Application_Security_Testing/07-Input_Validation_Testing/13-Testing_for_Format_String_Injection.md.
Attribution and source terms (OWASP contributors · CC BY-SA 4.0)Detection and investigation
- - Assess whether injecting format string conversion specifiers into user-controlled fields causes undesired behaviour from the application.
Preserve source timestamps, asset identity and collection context. Correlate independent evidence before attributing malicious intent. In OT, review passive evidence with the process owner; do not induce failures, replay commands or write to controllers to test a hypothesis.
Mitigation and response
- Review the complete publisher reference and relevant platform documentation; the source excerpt is not a tested mitigation.
Apply changes through the asset owner's approved change and recovery process. Documentation review is separate from successful testing or verified production protection.
Related technical context
No protocol-specific mapping is asserted for this entry.
Authoritative sources and attribution
Identifiers and source titles belong to OWASP, MITRE, the CVE Program, CISA, NIST or the cited vendor. Source excerpts are attributed and adapted under the linked publisher license; editorial context is separate. This is not an official framework mirror. Review baseline: 2026-11-18. Live documents can change; check exact current applicability.
- https://github.com/OWASP/wstg/blob/dd33419e10edb22b78d89325a6c2aad9f184e3a2/document/4-Web_Application_Security_Testing/07-Input_Validation_Testing/13-Testing_for_Format_String_Injection.md — Publisher link; not separately HTTP-checked
- Testing for Format String Injection (WSTG-INPV-13) — source accessed 2026-11-26
Source review supports bounded reference text. It is not execution evidence, a completeness claim, a CVSS assessment, a compliance certification or verification of production security.
