encyclopegia.org

Uncontrolled format string

Uncontrolled format string is a type of code injection vulnerability discovered around 1989 that can be used in security exploits. Originally thought harmless, format string exploits can be used to crash a program or to execute harmful code. The problem stems from the use of unchecked user input as the format string parameter in certain C functions that perform formatting, such as printf() . A malicious user may use the %s and %x format tokens, among others, to print data from the call stack or possibly other locations in memory. One may also write arbitrary data to arbitrary locations using the %n format token, which commands printf() and similar functions to write the number of bytes formatted to an address stored on the stack.

Uncontrolled format string is a type of code injection vulnerability discovered around 1989 that can be used in security exploits. Originally thought harmless, format string exploits can be used to crash a program or to execute harmful code. The problem stems from the use of unchecked user input as the format string parameter in certain C functions that perform formatting, such as printf() . A malicious user may use the %s and %x format tokens, among others, to print data from the call stack or possibly other locations in memory. One may also write arbitrary data to arbitrary locations using the %n format token, which commands printf() and similar functions to write the number of bytes formatted to an address stored on the stack. ==Details== A typical exploit uses a combination of these techniques to take control of the instruction pointer (IP) of a process, for example by forcing a program to overwrite the address of a library function or the return address on the stack with a pointer to some malicious shellcode. The padding parameters to format specifiers are used to control the number of bytes output and the %x token is used to pop bytes from the stack until the beginning of the format string itself is reached. The start of the format string is crafted to contain the address that the %n format token can then overwrite with the address of the malicious code to execute. This is a common vulnerability because format bugs were previously thought harmless and resulted in vulnerabilities in many common tools. MITRE's CVE project lists roughly 500 vulnerable programs as of June 2007, and a trend analysis ranks it the 9th most-reported vulnerability type between 2001 and 2006. Format string bugs most commonly appear when a programmer wishes to output a string containing user supplied data (either to a file, to a buffer, or to the user). The programmer may mistakenly write printf(buffer) instead of printf("%s", buffer) . The first version interprets buffer as a format string, and parses any formatting instructions it may contain. The second version simply prints a string to the screen, as the programmer intended. Both versions behave identically in the absence of format specifiers in the string, which makes it easy for the mistake to go unnoticed by the developer. Format bugs arise because C's argument passing conventions are not type-safe. In particular, the varargs mechanism allows functions to accept any number of arguments (e.g. printf ) by "popping" as many arguments off the call stack as they wish, trusting the early arguments to indicate how many additional arguments are to be popped, and of what types. Format string bugs can occur in other programming languages besides C, such as Perl, although they appear with less frequency and usually cannot be exploited to execute code of the attacker's choice. Many compilers can statically check format strings and produce warnings for dangerous or suspect formats. In the GNU Compiler Collection, the relevant compiler flags are, -Wall , -Wformat , -Wno-format-extra-args , -Wformat-security , -Wformat-nonliteral , and -Wformat=2 . Most of these are only useful for detecting bad format strings that are known at compile-time. If the format string may come from the user or from a source external to the application, the application must validate the format string before using it. Care must also be taken if the application generates or selects format strings on the fly. If the GNU C library is used, the -D_FORTIFY_SOURCE=2 parameter can be used to detect certain types of attacks occurring at run-time. The -Wformat-nonliteral check is more stringent. ==See also== Cross-application scripting exploits a similar kind of programming error Cross-site scripting printf scanf syslog Improper input validation SQL injection is a similar attack that succeeds when input is not filtered ==References== ==Further reading== (vii+663 pages) ==External links== Introduction to format string exploits 2013-05-02, by Alex Reece scut / team-TESO Exploiting Format String Vulnerabilities v1.2 2001-09-09 WASC Threat Classification - Format String Attacks CERT Secure Coding Standards CERT Secure Coding Initiative Known vulnerabilities at MITRE's CVE project. Secure Programming with GCC and GLibc (2008), by Marcel Holtmann

References

  1. Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmful code. The problem stems from the use of unchecked user input as the [ . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmful code. The problem stems from the use of unchecked user input as the [ ." Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmf. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmful code. The problem stems from the use of unchecked user input as the [ ." Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmf. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmf. (2026). Originally thought harmless, format string exploits can be used to Crash (computing)|crash a program or to execute harmful code. The problem stems from the use of unchecked user input as the [ . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  2. [https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Warning-Options.html#Warning-Options Warning Options - Using the GNU Compiler Collection (GCC)] . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Warning-Options.html#Warning-Options Warning Options - Using the GNU Compiler Collection (GCC)] ." https://gcc. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Warning-Options.html#Warning-Options Warning Options - Using the GNU Compiler Collection (GCC)] ." https://gcc. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA https://gcc. (2026). [https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Warning-Options.html#Warning-Options Warning Options - Using the GNU Compiler Collection (GCC)] . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  3. [https://seclists.org/bugtraq/2000/Jul/241 Bugtraq: Format Bugs] [https://www.lysator.liu.se/~kjell-e/tekla/linux/security/bugtraq/2000/format-bugs-2000-07.html Format bugs] July 2000 by Pascal Boucha . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[https://seclists.org/bugtraq/2000/Jul/241 Bugtraq: Format Bugs] [https://www.lysator.liu.se/~kjell-e/tekla/linux/security/bugtraq/2000/format-bugs-2000-07.html Format bugs] July 2000 by Pascal Boucha ." https://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[https://seclists.org/bugtraq/2000/Jul/241 Bugtraq: Format Bugs] [https://www.lysator.liu.se/~kjell-e/tekla/linux/security/bugtraq/2000/format-bugs-2000-07.html Format bugs] July 2000 by Pascal Boucha ." https://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA https://seclists. (2026). [https://seclists.org/bugtraq/2000/Jul/241 Bugtraq: Format Bugs] [https://www.lysator.liu.se/~kjell-e/tekla/linux/security/bugtraq/2000/format-bugs-2000-07.html Format bugs] July 2000 by Pascal Boucha . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  4. [https://seclists.org/bugtraq/2000/Jun/339 Bugtraq: format bugs, in addition to the wuftpd bug] June 2000, by Lamagra Argamal . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[https://seclists.org/bugtraq/2000/Jun/339 Bugtraq: format bugs, in addition to the wuftpd bug] June 2000, by Lamagra Argamal ." https://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[https://seclists.org/bugtraq/2000/Jun/339 Bugtraq: format bugs, in addition to the wuftpd bug] June 2000, by Lamagra Argamal ." https://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA https://seclists. (2026). [https://seclists.org/bugtraq/2000/Jun/339 Bugtraq: format bugs, in addition to the wuftpd bug] June 2000, by Lamagra Argamal . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  5. Exploiting Format String Vulnerabilities . julianor.tripod.com . September 1, 2001. · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "Exploiting Format String Vulnerabilities . julianor.tripod.com . September 1, 2001." Exploiting Format String Vulnerabilities. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "Exploiting Format String Vulnerabilities . julianor.tripod.com . September 1, 2001." Exploiting Format String Vulnerabilities. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA Exploiting Format String Vulnerabilities. (2026). Exploiting Format String Vulnerabilities . julianor.tripod.com . September 1, 2001. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  6. Vulnerability Type Distributions in CVE . 2007-05-22. · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "Vulnerability Type Distributions in CVE . 2007-05-22." Vulnerability Type Distributions in CVE. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "Vulnerability Type Distributions in CVE . 2007-05-22." Vulnerability Type Distributions in CVE. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA Vulnerability Type Distributions in CVE. (2026). Vulnerability Type Distributions in CVE . 2007-05-22. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  7. [http://seclists.org/bugtraq/2005/Dec/0030.html Bugtraq: Format String Vulnerabilities in Perl Programs] . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[http://seclists.org/bugtraq/2005/Dec/0030.html Bugtraq: Format String Vulnerabilities in Perl Programs] ." http://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[http://seclists.org/bugtraq/2005/Dec/0030.html Bugtraq: Format String Vulnerabilities in Perl Programs] ." http://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA http://seclists. (2026). [http://seclists.org/bugtraq/2005/Dec/0030.html Bugtraq: Format String Vulnerabilities in Perl Programs] . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  8. An Empirical Study of the Reliability of UNIX Utilities . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "An Empirical Study of the Reliability of UNIX Utilities ." 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "An Empirical Study of the Reliability of UNIX Utilities ." 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA encyclopegia.org. (2026). An Empirical Study of the Reliability of UNIX Utilities . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  9. [http://seclists.org/bugtraq/1999/Sep/0328.html Bugtraq: Exploit for proftpd 1.2.0pre6] . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[http://seclists.org/bugtraq/1999/Sep/0328.html Bugtraq: Exploit for proftpd 1.2.0pre6] ." http://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[http://seclists.org/bugtraq/1999/Sep/0328.html Bugtraq: Exploit for proftpd 1.2.0pre6] ." http://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA http://seclists. (2026). [http://seclists.org/bugtraq/1999/Sep/0328.html Bugtraq: Exploit for proftpd 1.2.0pre6] . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  10. [https://marc.info/?l=bugtraq&m=96179429114160&w=2 'WUFTPD 2.6.0 remote root exploit' - MARC], June 2000 by Przemysław Frasunek . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[https://marc.info/?l=bugtraq&m=96179429114160&w=2 'WUFTPD 2.6.0 remote root exploit' - MARC], June 2000 by Przemysław Frasunek ." https://marc. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[https://marc.info/?l=bugtraq&m=96179429114160&w=2 'WUFTPD 2.6.0 remote root exploit' - MARC], June 2000 by Przemysław Frasunek ." https://marc. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA https://marc. (2026). [https://marc.info/?l=bugtraq&m=96179429114160&w=2 'WUFTPD 2.6.0 remote root exploit' - MARC], June 2000 by Przemysław Frasunek . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  11. [https://marc.info/?l=bugtraq&m=96171893218000&w=2 'WuFTPD: Providing *remote* root since at least 1994' - MARC] by tf8 . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[https://marc.info/?l=bugtraq&m=96171893218000&w=2 'WuFTPD: Providing *remote* root since at least 1994' - MARC] by tf8 ." https://marc. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[https://marc.info/?l=bugtraq&m=96171893218000&w=2 'WuFTPD: Providing *remote* root since at least 1994' - MARC] by tf8 ." https://marc. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA https://marc. (2026). [https://marc.info/?l=bugtraq&m=96171893218000&w=2 'WuFTPD: Providing *remote* root since at least 1994' - MARC] by tf8 . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

  12. [http://seclists.org/bugtraq/2000/Sep/0214.html Bugtraq: Format String Attacks]Tim Newsham September 2000 . · retrieved 2026-06-21 · rev 1360564976
    Cite this reference

    MLA "[http://seclists.org/bugtraq/2000/Sep/0214.html Bugtraq: Format String Attacks]Tim Newsham September 2000 ." http://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976. Accessed 24 November 2026.

    Chicago "[http://seclists.org/bugtraq/2000/Sep/0214.html Bugtraq: Format String Attacks]Tim Newsham September 2000 ." http://seclists. 2026-06-21. https://en.wikipedia.org/w/index.php?oldid=1360564976.

    APA http://seclists. (2026). [http://seclists.org/bugtraq/2000/Sep/0214.html Bugtraq: Format String Attacks]Tim Newsham September 2000 . Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1360564976

Cite this article

MLA

"Uncontrolled format string." encyclopegia.org, 2026, https://encyclopegia.org/wiki/uncontrolled-format-string. Accessed 24 November 2026.

Chicago

"Uncontrolled format string." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/uncontrolled-format-string.

APA

encyclopegia.org. (2026). Uncontrolled format string. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/uncontrolled-format-string

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1360564976 · 0.5 · snapshot enwiki-001360564976

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.