CWE-226: Sensitive Information in Resource Not Removed Before Reuse
Description
The product releases a resource such as memory or a file so that it can be made available for reuse, but it does not clear or "zeroize" the information contained in the resource before the product performs a critical state transition or makes the resource available for reuse by other entities.
Submission Date :
July 19, 2006, midnight
Modification Date :
2023-06-29 00:00:00+00:00
Organization :
MITRE
Extended Description
When resources are released, they can be made available for reuse. For example, after memory is de-allocated, an operating system may make the memory available to another process, or disk space may be reallocated when a file is deleted. As removing information requires time and additional resources, operating systems do not usually clear the previously written information.
Even when the resource is reused by the same process, this weakness can arise when new data is not as large as the old data, which leaves portions of the old data still available. Equivalent errors can occur in other situations where the length of data is variable but the associated data structure is not. If memory is not cleared after use, the information may be read by less trustworthy parties when the memory is reallocated.
This weakness can apply in hardware, such as when a device or system switches between power, sleep, or debug states during normal operation, or when execution changes to different users or privilege levels.
Example - 1
This example shows how an attacker can take advantage of an incorrect state transition.<xhtml_p>During the transition from A to B, the device does not scrub the memory.</xhtml_p>
For transition from state A to state B, remove information which should not be available once the transition is complete.
Example - 2
The following code calls realloc() on a buffer containing sensitive data: There is an attempt to scrub the sensitive data from memory, but realloc() is used, so it could return a pointer to a different part of memory. The memory that was originally allocated for cleartext_buffer could still contain an uncleared copy of the data.
cleartext_buffer = get_secret();...cleartext_buffer = realloc(cleartext_buffer, 1024);...scrub_memory(cleartext_buffer, 1024);
Related Weaknesses
This table shows the weaknesses and high level categories that are related to this weakness. These relationships are defined to give an overview of the different insight to similar items that may exist at higher and lower levels of abstraction.
CWE-201: Insertion of Sensitive Information Into Sent Data
CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer
CWE-244: Improper Clearing of Heap Memory Before Release ('Heap Inspection')
CWE-459: Incomplete Cleanup
CWE-1239: Improper Zeroization of Hardware Register
CWE-1272: Sensitive Information Uncleared Before Debug/Power State Transition
CWE-1301: Insufficient or Incomplete Data Removal within Hardware Component
CWE-1342: Information Exposure through Microarchitectural State after Transient Execution
Visit http://cwe.mitre.org/ for more details.