The program invokes a potentially dangerous function that could
introduce a vulnerability if it is used incorrectly, but the function can also
be used safely.
Time of Introduction
Architecture and Design
Implementation
Applicable Platforms
Languages
C
C++
Likelihood of Exploit
High
Demonstrative Examples
Example 1
The strcpy() function in C is an excellent example of a potentially
dangerous function because of the danger of introducing a buffer overflow
vulnerability.
(Bad Code)
C
void manipulate(char *buffer) {
char newbuffer[80];
strcpy(newbuffer, buffer);
}
Potential Mitigations
Phase
Description
Use static analysis tools to spot use/misuse of the dangerous
function.
Other Notes
This weakness is different than CWE-242 (Use of Inherently Dangerous
Function). CWE-242 covers functions with such significant security problems
that they can never be guaranteed to be safe. Some functions, if used
properly, do not directly pose a security risk, but can introduce a weakness
if not called correctly. These are regarded as potentially dangerous. A
well-known example is the strcpy() function. When provided with a
destination buffer that is larger than its source, strcpy() will not
overflow. However, it is so often misused that some developers prohibit
strcpy() entirely.
Weakness Ordinalities
Ordinality
Description
Primary
(where the
weakness exists independent of other weaknesses)