---
title: "CWE-134: Use of Externally-Controlled Format String"
url: https://radicalnotion.ai/cwe/cwe-134
type: cwe
description: "The product uses a function that accepts a format string as an argument, but the format string originates from an external source."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-134: Use of Externally-Controlled Format String

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 427
- **Of those, in CISA KEV:** 3
- **New in 2026:** 75
- **CWE catalog version:** 4.21

## Description

The product uses a function that accepts a format string as an argument, but the format string originates from an external source.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | The programmer rarely intends for a format string to be externally-controlled at all. This weakness is frequently introduced in code that constructs log messages, where a constant format string is omitted. |
| Implementation | In cases such as localization and internationalization, the language-specific message repositories could be an avenue for exploitation, but the format string issue would be resultant, since attacker control of those repositories would also allow modification of message length, format, and content. |

## Applicable platforms

**Languages:** C (Often), C++ (Often), Perl (Rarely), Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality | Read Memory | Format string problems allow for information disclosure which can severely simplify exploitation of the program. |
| Integrity, Confidentiality, Availability | Modify Memory, Execute Unauthorized Code or Commands | Format string problems can result in the execution of arbitrary code, buffer overflows, denial of service, or incorrect data representation. |

## Potential mitigations

### Requirements

Choose a language that is not subject to this flaw.

### Implementation

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. \[REF-116\] \[REF-117\]

### Build and Compilation

Run compilers and linkers with high warning levels, since they may detect incorrect usage.

## Detection methods

### Automated Static Analysis

This weakness can often be detected using automated static analysis tools. Many modern tools use data flow analysis or constraint-based techniques to minimize the number of false positives.

### Black Box

Since format strings often occur in rarely-occurring erroneous conditions (e.g. for error message logging), they can be difficult to detect using black box methods. It is highly likely that many latent issues exist in executables that do not have associated source code (or equivalent source.

Effectiveness: Limited

### Automated Static Analysis - Binary or Bytecode

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Highly cost effective:

Cost effective for partial coverage:

- Bytecode Weakness Analysis - including disassembler + source code weakness analysis
- Binary Weakness Analysis - including disassembler + source code weakness analysis
- Binary / Bytecode simple extractor - strings, ELF readers, etc.

Effectiveness: High

### Manual Static Analysis - Binary or Bytecode

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies

Effectiveness: SOAR Partial

### Dynamic Analysis with Automated Results Interpretation

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Web Application Scanner
- Web Services Scanner
- Database Scanners

Effectiveness: SOAR Partial

### Dynamic Analysis with Manual Results Interpretation

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Fuzz Tester
- Framework-based Fuzzer

Effectiveness: SOAR Partial

### Manual Static Analysis - Source Code

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Highly cost effective:

Cost effective for partial coverage:

- Manual Source Code Review (not inspections)
- Focused Manual Spotcheck - Focused manual analysis of source

Effectiveness: High

### Automated Static Analysis - Source Code

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Highly cost effective:

Cost effective for partial coverage:

- Source code Weakness Analyzer
- Context-configured Source Code Weakness Analyzer
- Warning Flags

Effectiveness: High

### Architecture or Design Review

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Highly cost effective:

Cost effective for partial coverage:

- Formal Methods / Correct-By-Construction
- Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

The following program prints a string provided as an argument.

Bad code:

```c
#include <stdio.h>

void printWrapper(char *string) {

    printf(string);
}

int main(int argc, char **argv) {

    char buf[5012];
    memcpy(buf, argv[1], 5012);
    printWrapper(argv[1]);
    return (0);
}
```

The example is exploitable, because of the call to printf() in the printWrapper() function. Note: The stack buffer was added to make exploitation more simple.

### Example 2

The following code copies a command line argument into a buffer using snprintf().

Bad code:

```c
int main(int argc, char **argv){
    char buf[128];
    ...
    snprintf(buf,128,argv[1]);
}
```

This code allows an attacker to view the contents of the stack and write to the stack using a command line argument containing a sequence of formatting directives. The attacker can read from the stack by providing more formatting directives, such as %x, than the function takes as arguments to be formatted. (In this example, the function takes no arguments to be formatted.) By using the %n formatting directive, the attacker can write to the stack, causing snprintf() to write the number of bytes output thus far to the specified argument (rather than reading a value from the argument, which is the intended behavior). A sophisticated version of this attack will use four staggered writes to completely control the value of a pointer on the stack.

### Example 3

Certain implementations make more advanced attacks even easier by providing format directives that control the location in memory to read from or write to. An example of these directives is shown in the following code, written for glibc:

Bad code:

```c
printf("%d %d %1$d %1$d\n", 5, 9);
```

This code produces the following output: 5 9 5 5 It is also possible to use half-writes (%hn) to accurately control arbitrary DWORDS in memory, which greatly reduces the complexity needed to execute an attack that would otherwise require four staggered writes, such as the one mentioned in a separate example.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2002-1825 | format string in Perl program |
| CVE-2001-0717 | format string in bad call to syslog function |
| CVE-2002-0573 | format string in bad call to syslog function |
| CVE-2002-1788 | format strings in NNTP server responses |
| CVE-2006-2480 | Format string vulnerability exploited by triggering errors or warnings, as demonstrated via format string specifiers in a .bmp filename. |
| CVE-2007-2027 | Chain: untrusted search path enabling resultant format string by loading malicious internationalization messages. |

## Real CVEs with this weakness (sample of 12 of 427)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-23113 | Fortinet Multiple Products Format String Vulnerability | critical | 10.0 | - | Yes | 2024-02-15 |
| CVE-2019-1579 | Palo Alto Networks PAN-OS Remote Code Execution Vulnerability | critical | 9.2 | - | Yes | 2019-07-19 |
| CVE-2020-3118 | Cisco IOS XR Software Cisco Discovery Protocol Format String Vulnerability | high | 8.7 | - | Yes | 2020-02-05 |
| CVE-2026-53998 | Phoenix: Format String Injection in applyChatTemplate | critical | 10.0 | - | No | 2026-11-16 |
| CVE-2012-1851 | Print Spooler Service Format String Vulnerability | critical | 10.0 | - | No | 2012-08-15 |
| CVE-2012-0242 | Use of Externally-Controlled Format String in Advantech WebAccess | critical | 10.0 | - | No | 2012-02-21 |
| CVE-2011-2475 | - | critical | 10.0 | - | No | 2011-06-09 |
| CVE-2011-1568 | - | critical | 10.0 | - | No | 2011-04-05 |
| CVE-2010-4235 | RealNetworks Helix Server x-wap-profile Format String Remote Code Execution Vulnerability | critical | 10.0 | - | No | 2011-04-01 |
| CVE-2011-0270 | Hewlett-Packard OpenView Network Node Manager nnmRptConfig.exe Remote Code Execution Vulnerability | critical | 10.0 | - | No | 2011-01-13 |
| CVE-2010-2451 | - | critical | 10.0 | - | No | 2010-06-29 |
| CVE-2010-1039 | - | critical | 10.0 | - | No | 2010-05-20 |

## Related attack patterns (CAPEC)

- [CAPEC-135](https://radicalnotion.ai/capec/capec-135): Format String Injection
- [CAPEC-67](https://radicalnotion.ai/capec/capec-67): String Format Overflow in syslog()

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-20](https://radicalnotion.ai/cwe/cwe-20) | Improper Input Validation |
| Parent | [CWE-668](https://radicalnotion.ai/cwe/cwe-668) | Exposure of Resource to Wrong Sphere |
| Can precede | [CWE-123](https://radicalnotion.ai/cwe/cwe-123) | Write-what-where Condition |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Format string vulnerability | - | - |
| 7 Pernicious Kingdoms | Format String | - | - |
| CLASP | Format string problem | - | - |
| CERT C Secure Coding | Exclude user input from format strings | FIO30-C | Exact |
| CERT C Secure Coding | Use valid format strings | FIO47-C | CWE More Specific |
| OWASP Top Ten 2004 | Unvalidated Input | A1 | CWE More Specific |
| WASC | Format String | 6 | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Exclude user input from format strings | IDS06-J | - |
| SEI CERT Perl Coding Standard | Exclude user input from format strings | IDS30-PL | Exact |
| Software Fault Patterns | Tainted input to command | SFP24 | - |
| OMG ASCSM | - | ASCSM-CWE-134 | - |
| OpenSSF Secure Coding Guide for Python | Prevent Format String Injection | pyscg-0008 | - |

## Frequently asked questions

### What is CWE-134?

The product uses a function that accepts a format string as an argument, but the format string originates from an external source.

### What CVEs are caused by CWE-134?

427 recorded CVEs are attributed to CWE-134, including CVE-2024-23113, CVE-2019-1579 and CVE-2020-3118. 3 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### Is CWE-134 part of the OWASP Top 10?

CWE-134 maps to OWASP Top Ten 2004: Unvalidated Input (A1) in the OWASP security taxonomy.

### How do you prevent CWE-134?

Choose a language that is not subject to this flaw.

### How is CWE-134 detected?

Automated Static Analysis: This weakness can often be detected using automated static analysis tools. Many modern tools use data flow analysis or constraint-based techniques to minimize the number of false positives.

### What are the consequences of CWE-134?

Exploiting CWE-134 can lead to: Read Memory, Modify Memory, Execute Unauthorized Code or Commands.

### Is CWE-134 actively exploited?

Yes. 3 CWE-134 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 427 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/134.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-134). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
