CWE-1276: Hardware Child Block Incorrectly Connected to Parent System

Description

Signals between a hardware IP and the parent system design are incorrectly connected causing security risks.

Submission Date :

May 22, 2020, midnight

Modification Date :

2023-10-26 00:00:00+00:00

Organization :

Tortuga Logic
Extended Description

Individual hardware IP must communicate with the parent system in order for the product to function correctly and as intended. If implemented incorrectly, while not causing any apparent functional issues, may cause security issues. For example, if the IP should only be reset by a system-wide hard reset, but instead the reset input is connected to a software-triggered debug mode reset (which is also asserted during a hard reset), integrity of data inside the IP can be violated.

Example Vulnerable Codes

Example - 1

Many SoCs use hardware to partition system resources between trusted and un-trusted entities. One example of this concept is the Arm TrustZone, in which the processor and all security-aware IP attempt to isolate resources based on the status of a privilege bit. This privilege bit is part of the input interface in all TrustZone-aware IP. If this privilege bit is accidentally grounded or left unconnected when the IP is instantiated, privilege escalation of all input data may occur.



input clk, reset;input [31:0] data_in;input data_in_security_level;...


.clk(clk),.rst(rst),.data_in(rdata),//Copy-and-paste error or typo grounds data_in_security_level (in this example 0=secure, 1=non-secure) effectively promoting all data to "secure").data_in_security_level(1'b0),
...tz_peripheral u_tz_peripheral();...
// IP definitionmodule tz_peripheral(clk, reset, data_in, data_in_security_level, ...);endmodule// Instantiation of IP in a parent systemmodule soc(...)endmodule

In the Verilog code below, the security level input to the TrustZone aware peripheral is correctly driven by an appropriate signal instead of being grounded.




.clk(clk),.rst(rst),.data_in(rdata),// This port is no longer grounded, but instead driven by the appropriate signal.data_in_security_level(rdata_security_level),
...tz_peripheral u_tz_peripheral();...
// Instantiation of IP in a parent systemmodule soc(...)endmodule

Example - 2

Here is a code snippet from the Ariane core module in the HACK@DAC'21 Openpiton SoC [REF-1362]. To ensure full functional correctness, developers connect the ports with names. However, in some cases developers forget to connect some of these ports to the desired signals in the parent module. These mistakes by developers can lead to incorrect functional behavior or, in some cases, introduce security vulnerabilities.



...

<xhtml_b>.irq_i(),</xhtml_b>
<xhtml_b>.time_irq_i(),</xhtml_b>
.flush_o             ( flush_csr_ctrl ),.halt_csr_o          ( halt_csr_ctrl ),....*
...csr_regfile #() csr_regfile_i ();...

In the above example from HACK@DAC'21, since interrupt signals are not properly connected, the CSR module will fail to send notifications in the event of interrupts. Consequently, critical information in CSR registers that should be flushed or modified in response to an interrupt won't be updated. These vulnerabilities can potentially result in information leakage across various privilege levels.

To address the aforementioned vulnerability, developers must follow a two-step approach. First, they should ensure that all module signals are properly connected. This can often be facilitated using automated tools, and many simulators and sanitizer tools issue warnings when a signal remains unconnected or floats. Second, it is imperative to validate that the signals connected to a module align with the specifications. In the provided example, the developer should establish the correct connection of interrupt signals from the parent module (Ariane core) to the child module (csr_regfile) [REF-1363].



...

<xhtml_b>.irq_i			(irq_i),</xhtml_b>
<xhtml_b>.time_irq_i	(time_irq_i),</xhtml_b>
.flush_o             ( flush_csr_ctrl ),.halt_csr_o          ( halt_csr_ctrl ),....*
...csr_regfile #() csr_regfile_i ();...

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.

Visit http://cwe.mitre.org/ for more details.