CWE-242 使用内在危险函数

admin 2021年12月16日16:01:38评论99 views字数 1835阅读6分7秒阅读模式

CWE-242 使用内在危险函数

Use of Inherently Dangerous Function

结构: 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.

相关缺陷

  • cwe_Nature: ChildOf cwe_CWE_ID: 1177 cwe_View_ID: 1000 cwe_Ordinal: Primary

适用平台

Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}]

常见的影响

范围 影响 注释
Other Varies by Context

可能的缓解方案

['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.

bad C

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.

bad C

char buf[24];
printf("Please enter your name and press n");
gets(buf);
...

}

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

引用

文章来源于互联网:scap中文网

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年12月16日16:01:38
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-242 使用内在危险函数https://cn-sec.com/archives/613138.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息