Use of Inherently Dangerous Function |
Weakness ID: 242 (Weakness Base) | Status: Draft |
Description Summary
Extended Description
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.
Example 1
The excerpt below calls the gets() function in C, which is inherently unsafe.
Example 2
The excerpt below calls the gets() function in C, which is inherently unsafe.
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.
Ban the use of dangerous function. Use their safe equivalent. |
Use grep or static analysis tools to spot usage of dangerous functions. |
Ordinality | Description |
---|---|
Primary | (where the weakness exists independent of other weaknesses) |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
CanFollow | ![]() | 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Research Concepts1000 |
ChildOf | ![]() | 227 | Failure to Fulfill API Contract ('API Abuse') | Development Concepts (primary)699 Seven Pernicious Kingdoms (primary)700 |
ChildOf | ![]() | 710 | Coding Standards Violation | Research Concepts (primary)1000 |
ChildOf | ![]() | 748 | CERT C Secure Coding Section 50 - POSIX (POS) | Weaknesses Addressed by the CERT C Secure Coding Standard (primary)734 |
CanPrecede | ![]() | 120 | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | Research Concepts1000 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
7 Pernicious Kingdoms | Dangerous Functions | ||
CERT C Secure Coding | POS33-C | Do not use vfork() |
Herbert Schildt. "Herb Schildt's C++ Programming Cookbook". Chapter 5. Working with I/O. McGraw-Hill Osborne Media. 2008-04-28. |
[REF-11] M. Howard and D. LeBlanc. "Writing Secure Code". Chapter 5, "gets and fgets" Page 163. 2nd Edition. Microsoft. 2002. |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
7 Pernicious Kingdoms | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Sean Eidemiller | Cigital | External | |
added/updated demonstrative examples | ||||
2008-07-01 | Eric Dalci | Cigital | External | |
updated Potential Mitigations | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Relationships, Other Notes, Taxonomy Mappings, Type, Weakness Ordinalities | ||||
2008-11-24 | CWE Content Team | MITRE | Internal | |
updated Relationships, Taxonomy Mappings | ||||
2009-10-29 | CWE Content Team | MITRE | Internal | |
updated Description, Other Notes, References | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-01-30 | Dangerous Functions | |||
2008-04-11 | Use of Inherently Dangerous Functions | |||