2221
Example Language: Other (Good)
The device automatically patches itself and provides considerable more protection against being hacked.
Example 2:
A System-on-Chip (SOC) implements a Root-of-Trust (RoT) in ROM to boot secure code. However,
at times this ROM code might have security vulnerabilities and need to be patched. Since ROM is
immutable, it can be impossible to patch.
ROM does not have built-in application-programming interfaces (APIs) to patch if the code is
vulnerable. Implement mechanisms to patch the vulnerable ROM code.
Example 3:
The example code is taken from the JTAG module of the buggy OpenPiton SoC of
HACK@DAC'21. JTAG is protected with a password checker. Access to JTAG operations will be
denied unless the correct password is provided by the user. This user-provided password is first
sent to the HMAC module where it is hashed with a secret crypto key. This user password hash
(pass_hash) is then compared with the hash of the correct password (exp_hash). If they match,
JTAG will then be unlocked.
Example Language: Verilog (Bad)
module dmi_jtag(...)(...);
...
PassChkValid: begin
if(hashValid) begin
if(exp_hash == pass_hash) begin
pass_check = 1'b1;
end else begin
pass_check = 1'b0;
end
state_d = Idle;
end else begin
state_d = PassChkValid;
end
end
...
hmac hmac(
...
.key_i(256'h24e6fa2254c2ff632a41b...),
...
);
...
endmodule
However, the SoC's crypto key is hardcoded into the design and cannot be updated [REF-1387].
Therefore, if the key is leaked somehow, there is no way to reprovision the key without having the
device replaced.
To fix this issue, a local register should be used (hmac_key_reg) to store the crypto key. If
designers need to update the key, they can upload the new key through an input port (hmac_key_i)
to the local register by enabling the patching signal (hmac_patch_en) [REF-1388].
Example Language: Verilog (Good)
module dmi_jtag(...
) (
input logic [255:0] hmac_key_i,
input logic hmac_patch_en,
...
reg [255:0] hmac_key_reg;
...
CWE Version 4.14
CWE-1330: Remanent Data Readable after Memory Erase
CWE-1330: Remanent Data Readable after Memory Erase