结构: Simple
Abstraction: Base
状态: Draft
被利用可能性: High
The program 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.
Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}]
范围 | 影响 | 注释 |
---|---|---|
Other | Varies by Context |
策略:
Ban the use of dangerous functions. Use their safe equivalent.
策略:
Use grep or static analysis tools to spot usage of dangerous functions.
The code below calls gets() to read information into a buffer.
bad C
The gets() function in C is inherently unsafe.
The code below calls the gets() function to read in data from the command line.
bad C
However, the programmer uses the function gets() which is inherently unsafe because it blindly 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.
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
7 Pernicious Kingdoms | Dangerous Functions | ||
CERT C Secure Coding | POS33-C | CWE More Abstract | Do not use vfork() |
Software Fault Patterns | SFP3 | Use of an improper API |