566
The above code snippet [REF-1402] illustrates an instance of a vulnerable implementation of the
AES wrapper module, where p_c[i] registers are cleared at reset. Otherwise, p_c[i]registers either
maintain their old values (if reglk_ctrl_i[3]is true) or get filled through the AXI signal wdata. Note
that p_c[i]registers can be read through the AXI Lite interface (not shown in snippet). However,
p_c[i] registers are never cleared after their usage once the AES engine has completed the
encryption process of the message. In a multi-user or multi-process environment, not clearing
registers may result in the attacker process accessing data left by the victim, leading to data
leakage or unintentional information disclosure.
To fix this issue, it is essential to ensure that these internal registers are cleared in a timely manner
after their usage, i.e., the encryption process is complete. This is illustrated below by monitoring the
assertion of the cipher text valid signal, ct_valid [REF-1403].
Example Language: Verilog (Good)
module 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)
endmodule
Observed Examples
Reference Description
CVE-2019-3733 Cryptography library does not clear heap memory before release
https://www.cve.org/CVERecord?id=CVE-2019-3733
CVE-2003-0001 Ethernet NIC drivers do not pad frames with null bytes, leading to infoleak from
malformed packets.
https://www.cve.org/CVERecord?id=CVE-2003-0001
CVE-2003-0291 router does not clear information from DHCP packets that have been
previously used
https://www.cve.org/CVERecord?id=CVE-2003-0291
CVE-2005-1406 Products do not fully clear memory buffers when less data is stored into the
buffer than previous.
https://www.cve.org/CVERecord?id=CVE-2005-1406
CVE-2005-1858 Products do not fully clear memory buffers when less data is stored into the
buffer than previous.
https://www.cve.org/CVERecord?id=CVE-2005-1858
CVE-2005-3180 Products do not fully clear memory buffers when less data is stored into the
buffer than previous.
https://www.cve.org/CVERecord?id=CVE-2005-3180
CVE-2005-3276 Product does not clear a data structure before writing to part of it, yielding
information leak of previously used memory.
https://www.cve.org/CVERecord?id=CVE-2005-3276
CVE-2002-2077 Memory not properly cleared before reuse.
https://www.cve.org/CVERecord?id=CVE-2002-2077
CWE Version 4.14
CWE-226: Sensitive Information in Resource Not Removed Before Reuse
CWE-226: Sensitive Information in Resource Not Removed Before Reuse