Common Attack Pattern Enumeration and Classification
A Community Resource for Identifying and Understanding Attacks
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.
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.
Skill or Knowledge Level: High
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.
Limit the usage of formatting string functions.
Strong input validation - All user-controllable input must be validated and filtered for illegal formatting characters.
Formatting characters associated with malicious string content intended to reveal information or modify the memory.
User-controllable input shall not be used directly inside a formatting string function e.g., fprintf(user_controllable). Special formatting characters in user-controllable input must be escaped before use by the application in a formatting string function.
Ensure that all format string functions are passed a static string which cannot be controlled by the user and that the proper number of arguments are always sent to that function as well. If at all possible, use functions that do not support the %n operator in format strings.
[R.135.1] Hal Burch and Brendan Saulsbury. "FIO30-C. Exclude user input from format strings". CERT. May 2011. <https://www.securecoding.cert.org/confluence/display/seccode/FIO30-C.+Exclude+user+input+from+format+strings>.
[R.135.2] [REF-1] Robert Auger. "WASC Threat Classification 2.0". WASC-06 - Format String. The Web Application Security Consortium (WASC). Feb 2009. <http://projects.webappsec.org/Format-String>.
More information is available — Please select a different filter.