结构: Simple
Abstraction: Variant
状态: Draft
被利用可能性: unkown
Using realloc() to resize buffers that store sensitive information can leave the sensitive information exposed to attack, because it is not removed from memory.
When sensitive data such as a password or an encryption key is not removed from memory, it could be exposed to an attacker using a "heap inspection" attack that reads the sensitive data using memory dumps or other methods. The realloc() function is commonly used to increase the size of a block of allocated memory. This operation often requires copying the contents of the old memory block into a new and larger block. This operation leaves the contents of the original block intact but inaccessible to the program, preventing the program from being able to scrub sensitive data from memory. If an attacker can later examine the contents of a memory dump, the sensitive data could be exposed.
cwe_Nature: ChildOf cwe_CWE_ID: 226 cwe_View_ID: 1000 cwe_Ordinal: Primary
cwe_Nature: ChildOf cwe_CWE_ID: 226 cwe_View_ID: 699 cwe_Ordinal: Primary
cwe_Nature: CanPrecede cwe_CWE_ID: 669 cwe_View_ID: 1000
Language: [{'cwe_Name': 'C', 'cwe_Prevalence': 'Undetermined'}, {'cwe_Name': 'C++', 'cwe_Prevalence': 'Undetermined'}]
范围 | 影响 | 注释 |
---|---|---|
['Confidentiality', 'Other'] | ['Read Memory', 'Other'] | Be careful using vfork() and fork() in security sensitive code. The process state will not be cleaned up and will contain traces of data from past use. |
The following code calls realloc() on a buffer containing sensitive data:
bad C
There is an attempt to scrub the sensitive data from memory, but realloc() is used, so a copy of the data can still be exposed in the memory originally allocated for cleartext_buffer.
映射的分类名 | ImNode ID | Fit | Mapped Node Name |
---|---|---|---|
7 Pernicious Kingdoms | Heap Inspection | ||
CERT C Secure Coding | MEM03-C | Clear sensitive information stored in reusable resources returned for reuse | |
Software Fault Patterns | SFP23 | Exposed Data |