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.
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.
Potential Impact
Confidentiality
Read Application Data
Demonstrative Examples
During the transition from A to B, the device does not scrub the memory.For transition from state A to state B, remove information which should not be available once the transition is complete.cleartext_buffer = get_secret();...cleartext_buffer = realloc(cleartext_buffer, 1024);...scrub_memory(cleartext_buffer, 1024);module aes0_wrapper #(...)(...);
...
always @(posedge clk_i)
begin
if(~(rst_ni && ~rst_1)) //clear p_c[i] at reset
begin
start <= 0;
p_c[0] <= 0;
p_c[1] <= 0;
p_c[2] <= 0;
p_c[3] <= 0;
...
end
else if(en && we)
case(address[8:3])
0:
start <= reglk_ctrl_i[1] ? start : wdata[0];
1:
p_c[3] <= reglk_ctrl_i[3] ? p_c[3] : wdata[31:0];
2:
p_c[2] <= reglk_ctrl_i[3] ? p_c[2] : wdata[31:0];
3:
p_c[1] <= reglk_ctrl_i[3] ? p_c[1] : wdata[31:0];
4:
p_c[0] <= reglk_ctrl_i[3] ? p_c[0] : wdata[31:0];
...
endcase
end // always @ (posedge wb_clk_i)
endmodulemodule aes0_wrapper #(...)(...);
...
always @(posedge clk_i)
begin
if(~(rst_ni && ~rst_1)) //clear p_c[i] at reset
...
else if(ct_valid) //encryption process complete, clear p_c[i]
begin
p_c[0] <= 0;
p_c[1] <= 0;
p_c[2] <= 0;
p_c[3] <= 0;
end
else if(en && we)
case(address[8:3])
...
endcase
end // always @ (posedge wb_clk_i)
endmoduleMitigations & Prevention
During critical state transitions, information not needed in the next state should be removed or overwritten with fixed patterns (such as all 0's) or random data, before the transition to the next state.
When releasing, de-allocating, or deleting a resource, overwrite its data and relevant metadata with fixed patterns or random data. Be cautious about complex resource types whose underlying representation might be non-contiguous or change at a low level, such as how a file might be split into different chunks on a file system, even though "logical" file positions are contiguous at the application layer. Such resource types might require invocation of special modes or APIs to tell the underlying
Detection Methods
- Manual Analysis High — Write a known pattern into each sensitive location. Trigger the release of the resource or cause the desired state transition to occur. Read data back from the sensitive locations. If the reads are successful, and the data is the same as the pattern that was originally written, the test fails and th
- Automated Static Analysis High — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2019-3733 | Cryptography library does not clear heap memory before release |
| CVE-2003-0001 | Ethernet NIC drivers do not pad frames with null bytes, leading to infoleak from malformed packets. |
| CVE-2003-0291 | router does not clear information from DHCP packets that have been previously used |
| CVE-2005-1406 | Products do not fully clear memory buffers when less data is stored into the buffer than previous. |
| CVE-2005-1858 | Products do not fully clear memory buffers when less data is stored into the buffer than previous. |
| CVE-2005-3180 | Products do not fully clear memory buffers when less data is stored into the buffer than previous. |
| CVE-2005-3276 | Product does not clear a data structure before writing to part of it, yielding information leak of previously used memory. |
| CVE-2002-2077 | Memory not properly cleared before reuse. |
Related Weaknesses
Taxonomy Mappings
- PLOVER: — Sensitive Information Uncleared Before Use
- CERT C Secure Coding: MEM03-C — Clear sensitive information stored in reusable resources returned for reuse
- Software Fault Patterns: SFP23 — Exposed Data
Frequently Asked Questions
What is CWE-226?
CWE-226 (Sensitive Information in Resource Not Removed Before Reuse) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. 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 per...
How can CWE-226 be exploited?
Attackers can exploit CWE-226 (Sensitive Information in Resource Not Removed Before Reuse) to read application data. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-226?
Key mitigations include: During critical state transitions, information not needed in the next state should be removed or overwritten with fixed patterns (such as all 0's) or random data, before the transition to the next sta
What is the severity of CWE-226?
CWE-226 is classified as a Base-level weakness (Medium abstraction). It has been observed in 8 real-world CVEs.