Tainted string format
Input format argument is from an unsecure source
Description
This defect occurs when printf
-style functions use a format specifier
constructed from unsecure sources.
Risk
If you use externally controlled elements to format a string,
you can cause buffer overflow or data-representation problems. An
attacker can use these string formatting elements to view the contents
of a stack using %x
or write to a stack using %n
.
Fix
Pass a static string to format string functions. This fix ensures that an external actor cannot control the string.
Another possible fix is to allow only the expected number of
arguments. If possible, use functions that do not support the vulnerable %n
operator
in format strings.
Extend Checker
By default, Polyspace® assumes that data from external sources are tainted. See Sources of Tainting in a Polyspace Analysis. To consider
any data that does not originate in the current scope of Polyspace analysis as
tainted, use the command line option -consider-analysis-perimeter-as-trust-boundary
.
Examples
Result Information
Group: Tainted Data |
Language: C | C++ |
Default: Off |
Command-Line Syntax: TAINTED_STRING_FORMAT |
Impact: Low |
Version History
Introduced in R2015b
See Also
Tainted NULL or non-null-terminated string
| Find
defects (-checkers)
| -consider-analysis-perimeter-as-trust-boundary
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)
- Sources of Tainting in a Polyspace Analysis
- Modify Default Behavior of Bug Finder Checkers