CAPEC-135
Format String Injection
An adversary includes formatting characters in a string input field on the target application. Most applications assume that users will provide static text and may respond unpredictably to the presence of formatting character. For example, in certain functions of the C programming languages such as printf, the formatting character %s will print the contents of a memory location expecting this location to identify a string and the formatting character %n prints the number of DWORD written in the memory. An adversary can use this to read or write to memory locations or files, or simply to manipulate the value of the resulting text in unexpected ways. Reading or writing memory may result in program crashes and writing memory could result in the execution of arbitrary code if the adversary can write to the program stack.
On this page
Ask an AI about this attack pattern
Show the prompt
Explain the attack pattern CAPEC-135: Format String Injection: how it unfolds, what it needs and how to prevent and detect it in my systems. Use https://capec.mitre.org/data/definitions/135.html and https://cve.bz/cve/capec/135?via=ask-ai-copy, which lists recent CVEs with the weaknesses it exploits. Cite the sources.Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this attack pattern's id and public links.
How the attack unfolds
Explore
The attacker looks for a way in.
[Survey application] The adversary takes an inventory of the entry points of the application.
2 techniques
- Spider web sites for all available links
- List parameters, external variables, configuration files variables, etc. that are possibly used by the application.
Experiment
They probe what they found.
[Determine user-controllable input susceptible to format string injection] Determine the user-controllable input susceptible to format string injection. For each user-controllable input that the adversary suspects is vulnerable to format string injection, attempt to inject formatting characters such as %n, %s, etc.. The goal is to manipulate the string creation using these formatting characters.
1 technique
- Inject probe payload which contains formatting characters (%s, %d, %n, etc.) through input parameters.
Exploit
They carry out the attack.
[Try to exploit the Format String Injection vulnerability] After determining that a given input is vulnerable to format string injection, hypothesize what the underlying usage looks like and the associated constraints.
1 technique
- Insert various formatting characters to read or write the memory, e.g. overwrite return address, etc.
Prerequisites
The target application must accept a strings as user input, fail to sanitize string formatting characters in the user input, and process this string using functions that interpret string formatting characters.
Skills required
- High skill
In order to discover format string vulnerabilities it takes only low skill, however, converting this discovery into a working exploit requires advanced knowledge on the part of the adversary.
Resources required
None: No specialized resources are required to execute this type of attack.
Consequences
| Impact | Affects | Note |
|---|---|---|
| Modify Data | Integrity | |
| Read Data | Confidentiality | |
| Gain Privileges | Access Control | |
| Execute Unauthorized Commands | Integrity | Run Arbitrary Code |
| Bypass Protection Mechanism | Access Control |
Mitigations
Limit the usage of formatting string functions.
Strong input validation - All user-controllable input must be validated and filtered for illegal formatting characters.
Weaknesses it exploits
- CWE-20 Improper Input Validation
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component
- CWE-134 Use of Externally-Controlled Format String
Recent CVEs with these weaknesses
- 6.9CVE-2026-140128
A flaw has been found in Baison E3 Omni-Channel Retail Platform up to 2.5.1. Affected is an unknown function of the component KHATTACH Controller. Executing a manipulation of the argument retObjs can lead to sql injection. It is possible t…
- 5.5CVE-2026-139984
A weakness has been identified in walinejs Waline up to 1.43.6. The affected element is an unknown function of the component OAuth Login Callback Handler. Executing a manipulation of the argument Type can lead to improper input validation.…
- 5.5CVE-2026-139983
A vulnerability was identified in walinejs Waline up to 1.43.4. This issue affects some unknown processing. Such manipulation of the argument mail leads to sql injection. The attack can be executed remotely. The exploit is publicly availab…
- 5.5CVE-2026-139982
A vulnerability was found in PerfreeBlog up to 4.0.11. This issue affects the function buildPage of the file MyBatisUtils.java. Performing a manipulation of the argument Field results in sql injection. Remote exploitation of the attack is …
- 2.1CVE-2026-139980
A vulnerability was detected in PerfreeBlog up to 4.0.11. Affected by this issue is the function buildPage of the file MyBatisUtils.java. The manipulation of the argument Field results in sql injection. The attack can be launched remotely.…
- 7.7CVE-2026-105843
A flaw was found in OpenShift Router. The regular expression used to validate the haproxy.router.openshift.io/hsts_header route annotation matches the whitespace character class, which includes newline characters, and the matched value is …
- 2.1CVE-2026-139895
A vulnerability was determined in itsourcecode Stock Management System 1.0. The impacted element is an unknown function of the file fetchOrderData.php. Executing a manipulation of the argument orderId can lead to sql injection. It is possi…
- 3.7CVE-2026-140099
Forge, also called node-forge, is a native implementation of Transport Layer Security in JavaScript. Prior to 1.4.4, pki.privateKeyFromPem() and pki.privateKeyFromAsn1() ignore the RSAPrivateKey version and otherPrimeInfos fields and inter…
The newest records naming one of them. Each weakness's page lists them all.
Related attack patterns
- Part of
- CAPEC-137 Parameter Injection
- More specific patterns
- CAPEC-67 String Format Overflow in syslog()
Examples
Untrusted search path vulnerability in the add_filename_to_string function in intl/gettext/loadmsgcat.c for E…
Untrusted search path vulnerability in the add_filename_to_string function in intl/gettext/loadmsgcat.c for Elinks 0.11.1 allows local users to cause Elinks to use an untrusted gettext message catalog (.po file) in a "../po" directory, which can be leveraged to conduct format string attacks. See also: CVE-2007-2027
MITRE's words, unchanged: CAPEC-135 at MITRE. CAPEC is Copyright © 2007–2026, The MITRE Corporation, used under the CAPEC terms of use: “The MITRE Corporation (MITRE) hereby grants you a non-exclusive, royalty-free license to use Common Attack Pattern Enumeration and Classification (CAPEC™) for research, development, and commercial purposes. Any copy you make for such purposes is authorized provided that you reproduce MITRE’s copyright designation and this license in any such copy.” CAPEC and the CAPEC logo are trademarks of The MITRE Corporation. Credits. All attack patterns.