Argument is from an unsecure source and might be NULL or not NULL-terminated
This defect occurs when strings from unsecure sources are used in string manipulation routines
that implicitly dereference the string buffer, for instance, strcpy or
sprintf. To consider all input from outside the current analysis
perimeter as unsecure, use -consider-analysis-perimeter-as-trust-boundary.
Tainted NULL or non-null-terminated string raises no
defect for a string returned from a call to scanf-family variadic
functions. Similarly, no defect is raised when you pass the string with a
%s specifier to printf-family variadic
functions.
If a string is from an unsecure source, it is possible that an attacker manipulated the string or pointed the string pointer to a different memory location.
If the string is NULL, the string routine cannot dereference the string, causing the program to crash. If the string is not null-terminated, the string routine might not know when the string ends. This error can cause you to write out of bounds, causing a buffer overflow.
Validate the string before you use it. Check that:
The string is not NULL.
The string is null-terminated
The size of the string matches the expected size.
| Group: Tainted Data |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax: TAINTED_STRING |
| Impact: Low |
| CWE ID: 120, 170, 476, 690, 822 |
-consider-analysis-perimeter-as-trust-boundary | Find defects
(-checkers) | Tainted string format