CWE

Common Weakness Enumeration

A Community-Developed List of Software & Hardware Weakness Types

2021 CWE最重要的硬件弱点
CWE前25个最危险的弱点
>CWEList>CWE- Individual Dictionary Definition (4.10)
ID

CWE-762:不匹配的内存管理例程

Weakness ID: 762
抽象:Variant
结构:简单的
View customized information:
+Description
The product attempts to return a memory resource to the system, but it calls a release function that is not compatible with the function that was originally used to allocate that resource.
+Extended Description

This weakness can be generally described as mismatching memory management routines, such as:

  • 内存是在堆栈上分配的(自动),但是使用内存管理例程Free()()()()()CWE-590),旨在明确分配的堆内存。
  • The memory was allocated explicitly using one set of memory management functions, and deallocated using a different set. For example, memory might be allocated with malloc() in C++ instead of the new operator, and then deallocated with the delete operator.

When the memory management functions are mismatched, the consequences may be as severe as code execution, memory corruption, or program crash. Consequences and ease of exploit will vary depending on the implementation of the routines and the object being managed.

+关系
部分帮助该表显示了与该弱点相关的弱点和高级类别。这些关系定义为childof,parentof,ementof,并深入了解可能存在于较高和较低抽象水平的类似项目。此外,定义了诸如Peerof和Canalsobe之类的关系,以显示用户可能想要探索的类似弱点。
+Relevant to the view "Research Concepts" (CWE-1000)
自然 Type ID 姓名
Childof 根据根据- a weakness that is still mostly independent of a resource or technology, but with sufficient details to provide specific methods for detection and prevention. Base level weaknesses typically describe issues in terms of 2 or 3 of the following dimensions: behavior, property, technology, language, and resource. 763 发布无效的指针或参考
ParentOf Variant变体 - 与某种类型的产品相关的弱点,通常涉及特定的语言或技术。比基本弱点更具体。变体级别的弱点通常以以下维度的3到5来描述问题:行为,财产,技术,语言和资源。 590 没有记忆而不是堆
部分帮助该表显示了与该弱点相关的弱点和高级类别。这些关系定义为childof,parentof,ementof,并深入了解可能存在于较高和较低抽象水平的类似项目。此外,定义了诸如Peerof和Canalsobe之类的关系,以显示用户可能想要探索的类似弱点。
+与“ CISQ数据保护措施”(CWE-1340)有关
自然 Type ID 姓名
Childof 班级班级 - 以非常抽象的方式描述的弱点,通常与任何特定的语言或技术无关。比支柱弱点更具体,但比基本弱点更一般。班级弱点通常用以下维度的1或2来描述问题:行为,属性和资源。 404 Improper Resource Shutdown or Release
+介绍模式
部分帮助引言的不同模式提供了有关如何以及何时引入这种弱点的信息。该阶段识别可能发生介绍的生命周期中的一个点,而音符提供了与给定阶段中引言有关的典型情况。
Phase 笔记
Implementation
+适用的平台
部分帮助该清单显示了可能出现的弱点的可能区域。这些可能适用于特定的命名语言,操作系统,体系结构,范式,技术或一类此类平台。该平台与给定弱点出现在该实例的频率一起列出。

语言

C(不确定的患病率)

C ++(不确定的患病率)

+常见后果
部分帮助该表指定与弱点相关的不同个人后果。该范围确定了违反的应用程序安全区域,而影响描述了如果对手成功利用这一弱点,就会产生负面的技术影响。其可能性提供了有关预期相对于列表中其他后果的特定后果的可能性的信息。例如,可能会利用弱点来实现一定的影响,但很可能会利用它来实现不同的影响。
范围 Impact 可能性
正直
Availability
保密

技术影响:修改内存;DOS:撞车,退出或重新启动;执行未经授权的代码或命令

+利用的可能性
Low
+Demonstrative Examples

Example 1

此示例使用C ++中的新运算符分配Barobj对象,但是,程序员然后使用Free()对对象进行处理,这可能导致意外行为。

(不良代码)
Example Language:C ++
void foo(){
barobj *ptr = new barobj()
/* do some work with ptr here */

...

免费(ptr);
}

Instead, the programmer should have either created the object with one of the malloc family functions, or else deleted the object with the delete operator.

(good code)
Example Language:C ++
void foo(){
barobj *ptr = new barobj()
/* do some work with ptr here */

...

delete ptr;
}

Example 2

In this example, the program does not use matching functions such as malloc/free, new/delete, and new[]/delete[] to allocate/deallocate the resource.

(不良代码)
Example Language:C ++
A类{
void foo();
};
void a :: foo(){
int *ptr;
ptr =(int*)malloc(sizeof(int));
delete ptr;
}

Example 3

在此示例中,该程序在非HEAP内存上调用delete []函数。

(不良代码)
Example Language:C ++
class A{
void foo(bool);
};
void A::foo(bool heap) {
int localArray[2] = {
11,22
};
int *p = localArray;
如果(堆){
p = new int [2];
}
删除[] p;
}
+Potential Mitigations

Phase: Implementation

Only call matching memory management functions. Do not mix and match routines. For example, when you allocate a buffer with malloc(), dispose of the original pointer with free().

Phase: Implementation

Strategy: Libraries or Frameworks

Choose a language or tool that provides automatic memory management, or makes manual memory management less error-prone.

例如,Linux中的GLIBC提供了防止无效指针的保护。

当使用XCode来定位OS X或iOS时,启用自动参考计数(ARC)[REF-391].

To help correctly and consistently manage memory when programming in C++, consider using a smart pointer class such as std::auto_ptr (defined by ISO/IEC ISO/IEC 14882:2003), std::shared_ptr and std::unique_ptr (specified by an upcoming revision of the C++ standard, informally referred to as C++ 1x), or equivalent solutions such as Boost.

阶段:建筑和设计

Strategy: Libraries or Frameworks

使用审查的库或框架,该图书馆或框架不允许这种弱点发生或提供使这种弱点更容易避免的结构。

例如,Linux中的GLIBC提供了防止无效指针的保护。

阶段:建筑和设计

使用一种为内存分配和交易提供抽象的语言。

Phase: Testing

使用动态检测内存管理问题的工具,例如Valgrind。
+影响资源
  • 记忆
+Memberships
部分帮助This MemberOf Relationships table shows additional CWE Categories and Views that reference this weakness as a member. This information is often useful in understanding where a weakness fits within the context of external information sources.
自然 Type ID 姓名
MemberOf CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. 876 CERT C++ Secure Coding Section 08 - Memory Management (MEM)
MemberOf CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. 1172 SEI CERT C编码标准 - 指南51. Microsoft Windows(Win)
MemberOf CategoryCategory - a CWE entry that contains a set of other entries that share a common characteristic. 1237 SFP主集群:资源错误发布错误
+笔记

Applicable Platform

This weakness is possible in any programming language that allows manual management of memory.

+Taxonomy Mappings
映射的分类名称 节点ID 合身 映射的节点名称
CERT C Secure Coding WIN30-C 精确的 Properly pair allocation and deallocation functions
软件故障模式 SFP12 内存释放故障
+参考
[Ref-657]“ Boost C ++库智能指针”。<http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/smart_ptr.htm>.
[Ref-480]“ Valgrind”。<http://valgrind.org/>.
[REF-391] iOS Developer Library. "Transitioning to ARC Release Notes". 2013-08-08. <https://developer.apple.com/library/ios/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html>.
+内容历史记录
+Submissions
Submission Date 提交者 Organization
2009-05-08 CWE内容团队 MITER
+贡献
Contribution Date 贡献者 Organization
2010-04-30 马丁·塞伯 思科系统公司
为现有缓解提供了改进
+修改
修改日期 Modifier Organization
2009-12-28 CWE内容团队 MITER
updated Applicable_Platforms, Likelihood_of_Exploit
2010-06-21 CWE内容团队 MITER
更新的描述,势_MITIGATIONS
2011-06-01 CWE内容团队 MITER
updated Common_Consequences
2011-09-13 CWE内容团队 MITER
updated Relationships, Taxonomy_Mappings
2012-05-11 CWE内容团队 MITER
更新的示范_examples,关系
2012-10-30 CWE内容团队 MITER
updated Potential_Mitigations
2014-02-18 CWE内容团队 MITER
更新了示范示例,电位_MINEIGATIONS,参考
2014-07-30 CWE内容团队 MITER
updated Relationships, Taxonomy_Mappings
2017-11-08 CWE内容团队 MITER
updated Applicable_Platforms, References, Taxonomy_Mappings
2019-01-03 CWE内容团队 MITER
updated Relationships
2020-02-24 CWE内容团队 MITER
updated Relationships
2020-12-10 CWE内容团队 MITER
updated Relationships
2021-03-15 CWE内容团队 MITER
updated Relationships
2023-01-31 CWE内容团队 MITER
更新的描述
More information is available — Please select a different filter.
页面最后更新:2023年1月31日