Katalog CWE

CWE-242 · Słabość

Use of Inherently Dangerous Function

Abstrakcja
Bazowa
Status
Szkic
Ryzyko wykorzystania
wysokie
Dodano
19 lipca 2006
Ostatnia zmiana
30 kwietnia 2026

Podatności CVE z tą słabościąPełny wpis na cwe.mitre.org ↗

Opis

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.

Skutki

  • Other

    Varies by Context

Zapobieganie

  • Build and Compilation, Implementation

    Identify a list of prohibited API functions and prohibit developers from using these functions, providing safer alternatives. In some cases, automatic code analysis tools or the compiler can be instructed to spot use of prohibited functions, such as the "banned.h" include file from Microsoft's SDL. [REF-554] [REF-1009] [REF-7]

  • Testing

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

Przykłady podatności

Słabość nadrzędna

Kiedy powstaje

Dotyczy

C, C++

Źródła

  1. Seven Pernicious Kingdoms: A Taxonomy of Software Security Errors — Katrina Tsipenyuk, Brian Chess, Gary McGraw, NIST, 2005
  2. Herb Schildt's C++ Programming Cookbook — Herbert Schildt, Chapter 5. Working with I/O, McGraw-Hill Osborne Media, 2008
  3. Writing Secure Code — Michael Howard, David LeBlanc, Chapter 5, "gets and fgets" Page 163, Microsoft Press, 2002
  4. Security Development Lifecycle (SDL) Banned Function Calls — Michael Howard, 2011
  5. Microsoft's Free Security Tools - banned.h — Tim Rains, 2012

Wpis z katalogu CWE 4.20.