The product calls a function that can never be guaranteed to work safely.
Certain functions behave in dangerous ways regardless of how they are used. Functions in this category were often implemented without taking security concerns into account. The gets() function is unsafe because it does not perform bounds checking on the size of its input. An attacker can easily send arbitrarily-sized input to gets() and overflow the destination buffer. Similarly, the >> operator is unsafe to use when reading into a statically-allocated character array because it does not perform bounds checking on the size of its input. An attacker can easily send arbitrarily-sized input to the >> operator and overflow the destination buffer.

Primary

Implementation

High

Other
Varies by Context

Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
High

Implementation
Requirements
Ban the use of dangerous functions. Use their safe equivalent.

Testing
Use grep or static analysis tools to spot usage of dangerous functions.

The code below calls gets() to read information into a buffer.

char buf[BUFSIZE];gets(buf);

The gets() function in C is inherently unsafe.

The code below calls the gets() function to read in data from the command line.

char buf[24];printf("Please enter your name and press <Enter>\n");gets(buf);...}

However, gets() is inherently unsafe, because it copies all input from STDIN to the buffer without checking size. This allows the user to provide a string that is larger than the buffer size, resulting in an overflow condition.

CVE-2007-4004
FTP client uses inherently insecure gets() function and is setuid root on some systems, allowing buffer overflow
https://www.cve.org/CVERecord?id=CVE-2007-4004

Dangerous Functions

POS33-C
Do not use vfork()
CWE More Abstract

SFP3
Use of an improper API

Allowed
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

7 Pernicious Kingdoms
2006-07-19
Draft 3
2006-07-19

Sean Eidemiller
Cigital
2008-07-01
added/updated demonstrative examples

Eric Dalci
Cigital
2008-07-01
updated Potential_Mitigations

CWE Content Team
MITRE
2008-09-08
updated Applicable_Platforms, Relationships, Other_Notes, Taxonomy_Mappings, Type, Weakness_Ordinalities

CWE Content Team
MITRE
2008-11-24
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2009-10-29
updated Description, Other_Notes, References

CWE Content Team
MITRE
2010-02-16
updated Demonstrative_Examples, References, Relationships

CWE Content Team
MITRE
2010-04-05
updated Relationships

CWE Content Team
MITRE
2011-06-01
updated Common_Consequences

CWE Content Team
MITRE
2011-06-27
updated Common_Consequences

CWE Content Team
MITRE
2012-05-11
updated Relationships

CWE Content Team
MITRE
2012-10-30
updated Potential_Mitigations

CWE Content Team
MITRE
2014-07-30
updated Demonstrative_Examples, Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2017-11-08
updated Causal_Nature, References, Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2018-03-27
updated References

CWE Content Team
MITRE
2019-01-03
updated Relationships

CWE Content Team
MITRE
2020-02-24
updated References, Relationships

CWE Content Team
MITRE
2020-12-10
updated Demonstrative_Examples

CWE Content Team
MITRE
2021-03-15
updated Demonstrative_Examples

CWE Content Team
MITRE
2023-01-31
updated Description

CWE Content Team
MITRE
2023-04-27
updated Detection_Factors, Relationships

CWE Content Team
MITRE
2023-06-29
updated Mapping_Notes

CWE Content Team
MITRE
2024-02-29
4.14
2024-02-29
updated Observed_Examples

Dangerous Functions
Use of Inherently Dangerous Functions