CWE-134 – Use of Externally-Controlled Format String

Read Time:1 Minute, 16 Second

Description

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

Modes of Introduction:

– Implementation

 

Likelihood of Exploit: High

 

Related Weaknesses

CWE-668
CWE-668
CWE-123
CWE-20

 

Consequences

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.

 

Potential Mitigations

Phase: Requirements

Description: 

Choose a language that is not subject to this flaw.

Phase: Implementation

Description: 

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]

Phase: Build and Compilation

Description: 

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

CVE References

  • 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