CWE-1461: Hardware Simulation / Synthesis Mismatch
View customized information:
Shows the description and diagram, platforms, mitigations, consequences, relationships, memberships, and content history.
For users who are interested in more notional aspects of a weakness. Example: educators, technical writers, and project/program managers.
For users who are concerned with the practical application and details about the nature of a weakness and how to prevent it from happening. Example: tool developers, security researchers, pen-testers, incident response analysts.
For users who are mapping an issue to CWE/CAPEC IDs, i.e., finding the most appropriate CWE for a specific issue (e.g., a CVE record). Example: tool developers, security researchers.
For users who wish to see all available information for the CWE/CAPEC entry.
For users who want to customize what details are displayed.
×
Edit Custom FilterMore information is available — Please edit the custom filter or select a different filter.
The hardware design contains structures that are interpreted
differently during synthesis than during simulation, which
cause inconsistencies in security-relevant behavior between
the synthesized implementation and the simulation.
Hardware-description-language (HDL) code describes functionality which can be verified as correct using simulation tools. Synthesis tools then (automatically) convert this into a physically-realizable representation. Certain HDL code structures cannot be exactly represented, or have multiple valid representations from which the synthesis tool must choose. This can result in output which behaves differently to the (functionally-correct) HDL code. These "simulation/synthesis mismatches" may have security consequences. This table specifies different individual consequences
associated with the weakness. The Scope identifies the application security area that is
violated, while the Impact describes the negative technical impact that arises if an
adversary succeeds in exploiting this weakness. The Likelihood provides information about
how likely the specific consequence is expected to be seen relative to the other
consequences in the list. For example, there may be high likelihood that a weakness will be
exploited to achieve a certain impact, but a low likelihood that it will be exploited to
achieve a different impact.
This table shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOf and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition,
relationships such as PeerOf, Overlaps, and CanAlsoBe are defined to show similar weaknesses that the user
may want to explore.
The different Modes of Introduction provide information
about how and when this
weakness may be introduced. The Phase identifies a point in the life cycle at which
introduction
may occur, while the Note provides a typical scenario related to introduction during the
given
phase.
This listing shows possible areas for which the given
weakness could appear. These
may be for specific named Languages, Operating Systems, Architectures, Paradigms,
Technologies,
or a class of such platforms. The platform is listed along with how frequently the given
weakness appears for that instance.
Example 1
A hardware designer implements an access control latch which takes in lock and unlock signals (which are only active for a single cycle) and a reset signal, and outputs an unlocked state signal. During operation, the unlocked signal is synchronously set high by the unlock input and set low by the lock input. The unlocked signal also intended to be low from startup and set low by reset. (bad code)
Example Language: Verilog
module lock_control (
input wire clk,
);input wire reset, input wire lock, input wire unlock, output reg unlocked
reg unlocked_next = 1'b0;
endmodulealways @(lock or unlock or unlocked) begin
if (reset == 1'b1) begin
end
unlocked_next = 1'b1;
end else if (lock == 1'b1) begin
unlocked_next = 1'b0;
end else if (unlock == 1'b1) begin
unlocked_next = 1'b1;
end else begin
unlocked_next = unlocked;
endalways @(posedge clk) begin
unlocked <= unlocked_next;
end
The following VHDL example is written for VHDL-93 or later. (bad code)
Example Language: VHDL
library ieee; use ieee.std_logic_1164.all; entity lock_control is
port (
end entity lock_control;
clk : in std_logic;
);reset : in std_logic; lock : in std_logic; unlock : in std_logic; unlocked : out std_logic architecture behavioral of lock_control is
signal unlocked_reg : std_logic:=’0’;
beginsignal unlocked_next : std_logic;
process(lock, unlock, unlocked_reg)
end architecture behavioral; begin
if reset = '1' then
end process;
unlocked_next <= '1';
elsif lock = '1' then
unlocked_next <= '0';
elsif unlock = '1' then
unlocked_next <= '1';
else
unlocked_next <= unlocked_reg;
end if;process(clk) begin
if rising_edge(clk) then
end process;
unlocked_reg <= unlocked_next;
end if;unlocked <= unlocked_reg;
The always block is intended to describe combinational logic for unlocked_next, which depends on four signals (lock, unlock, unlocked and reset). However, the sensitivity list is missing reset. During pre-synthesis RTL simulation, this tells the simulator not to rerun the block when reset changes (only when the other signals change). The signal unlocked_next defaults to 1’b0 so the simulation sees the expected locked state and so the tests of the state after reset will pass. Synthesis tools assume a complete sensitivity list and will therefore infer logic including the reset signal. When reset is high, the unlocked _next signal is (erroneously) set to 1’b1. This is a bug (as reset should force a non-unlocked state), which would be expected to be found in simulation. The design uses a two-process state machine style which masks this bug in the code during simulation, but allows it to propagate to the synthesized implementation.
The synthesized hardware exits reset in an insecure state (with unlocked set to 1’b1) and remains in that state until one of the lock/unlock signals changes state. An adversary can take advantage of this by exploiting whatever logic makes use of this signal to set itself to a secure state. (good code)
Example Language: Algorithm
For combinational logic, ensure that simulation is triggered by every signal read by the block. This can be done by listing both inputs explicitly, but this is not recommended. A safer and more maintainable approach is to use (in Verilog) always @*, which tells the simulator to include all signals used inside the block. In SystemVerilog, use always_comb. In VHDL use process(all). Example 2
A hardware developer is debugging logic which requires the system to be in an unprotected mode. In order to enable their work, they have (temporarily) removed some code related to the "protected_mode_enabled" flag in a way that does not cause the simulations to fail. (bad code)
Example Language: VHDL
-- The following VHDL example is written for VHDL-93 or later. signal secure : boolean; -- implicitly initialized to ‘false’ signal policy_ok : boolean; signal lock_ready : boolean; ... -- synthesis translate_off secure <= security_check(policy_ok, lock_ready); -- TODO: restore this after debugging -- synthesis translate_on protected_mode_enabled <= secure; (bad code)
Example Language: Verilog
reg secure; wire policy_ok; wire lock_ready; wire protected_mode_enabled; ... always @(*) begin
secure = 1'b0; // default value
end// synopsys translate_off secure = security_check(policy_ok, lock_ready); // TODO: restore this after debugging // synopsys translate_on assign protected_mode_enabled = secure;
The design assigns the security-relevant secure signal using logic that is hidden from synthesis by translate_off / translate_on or equivalent synthesis exclusion directives. Simulation tools treat these directives as comments and include the enclosed assignment, so simulation updates secure according to security_check(policy_ok, lock_ready) and appears to validate the intended protected-mode behavior. Synthesis tools omit the code between the exclusion directives. The synthesized implementation therefore does not contain the same assignment that was exercised during simulation. This creates a simulation/synthesis mismatch in security-relevant behavior: the HDL model used for verification enables or disables protected mode using logic that is absent from the synthesized hardware.
Because the synthesized implementation does not include the same logic that was present during simulation, the hardware defaults to an insecure state. An attacker can take advantage of this to execute activities which would normally require some form of authorization, even though simulation results suggested that protected mode would be enforced. (good code)
Example Language: Algorithm
Do not place security-relevant assignments inside synthesis-excluded regions. Any logic that affects protected-mode behavior should be represented consistently in both simulation and synthesis. Limit synthesis translate_off / translate_on regions to simulation-only code that cannot assign, modify, override, or mask security-sensitive signals. Carefully review all uses of translate_on/off directives. Ensure that developers can efficiently authorize their activities during development work, to avoid the temptation to bypass security features in this way. (good code)
Example Language: VHDL
-- The following VHDL example is written for VHDL-93 or later. signal secure : boolean; -- implicitly initialized to ‘false’ signal policy_ok : boolean; signal lock_ready : boolean; ... secure <= security_check(policy_ok, lock_ready); protected_mode_enabled <= secure; (good code)
Example Language: Verilog
reg secure; wire policy_ok; wire lock_ready; wire protected_mode_enabled; ... always @(*) begin
secure = security_check(policy_ok, lock_ready);
endassign protected_mode_enabled = secure; Example 3
A hardware developer is designing a controller that manages whether protected configuration registers can be written. The controller includes states for reset handling, user-level operation, and privileged operation. (bad code)
Example Language: VHDL
-- The following VHDL example is written for VHDL-93 or later. type t_priv_state is (RESET, USER_ONLY, PRIVILEGED); signal priv_state : t_priv_state := RESET; signal auth_passed : boolean := false; signal privilege_revoke : boolean := false; ... process(clk, reset_n) begin
if reset_n = '0' then
priv_state <= RESET;
elsif rising_edge(clk) then
case priv_state is
end process;
when RESET =>
end if;
priv_state <= USER_ONLY;
when USER_ONLY =>
if auth_passed then
when PRIVILEGED =>
priv_state <= PRIVILEGED;
end if;
if privilege_revoke then
when others =>
priv_state <= USER_ONLY;
end if;
priv_state <= USER_ONLY; -- intended recovery for unexpected encodings
end case;protected_cfg_write_en <= (priv_state = PRIVILEGED); (bad code)
Example Language: Verilog
localparam RESET = 2'b00; localparam USER_ONLY = 2'b01; localparam PRIVILEGED = 2'b10; reg [1:0] priv_state = RESET; wire auth_passed; // Implicitly 1-bit (boolean equivalent) wire privilege_revoke; // Implicitly 1-bit (boolean equivalent) wire clk; wire reset_n; wire protected_cfg_write_en; ... always @(posedge clk or negedge reset_n) begin
if (!reset_n) begin
end
priv_state <= RESET;
end else begin
case (priv_state)
end
RESET: begin
endcase
priv_state <= USER_ONLY;
endUSER_ONLY: begin
if (auth_passed) begin
end
priv_state <= PRIVILEGED;
endPRIVILEGED: begin
if (privilege_revoke) begin
end
priv_state <= USER_ONLY;
enddefault: begin
priv_state <= USER_ONLY; // intended recovery for unexpected encodings
endassign protected_cfg_write_en = (priv_state == PRIVILEGED);
The design relies on a VHDL others choice or Verilog default branch to express recovery behavior for state values not explicitly listed in the state transition logic. In RTL simulation, the intended behavior is that unexpected controller states will transition to USER_ONLY, where protected configuration writes are blocked. The error is assuming that this RTL-level recovery behavior will necessarily be preserved after synthesis. During synthesis, the state machine may be encoded, optimized, or transformed based on the states considered reachable during normal operation. As a result, logic associated with unused or faulty hardware encodings may be removed or altered, and the synthesized implementation may not preserve the same recovery behavior that appeared in RTL simulation.
If the synthesized implementation does not preserve the unexpected-state recovery behavior, the hardware may fail to return to USER_ONLY after a fault, reset anomaly, voltage glitch, clock disturbance, or other condition that places the state storage into an unintended encoding. An attacker who can induce or influence such conditions may be able to leave protected configuration writes enabled, or cause them to become enabled, even though simulation suggested that unexpected state values would be forced into a state where those writes are blocked. (good code)
Example Language: Algorithm
Do not rely on a VHDL others choice or Verilog default branch to guarantee post-synthesis recovery behavior for security-critical state machines. If recovery from unexpected state encodings affects access to protected configuration registers, the implementation should not depend on synthesis inferring and preserving that behavior from RTL alone. For this type of security-critical controller, implement the state machine using a carefully-controlled structural or hand-synthesized representation where the relevant state elements, reset behavior, transition logic, and fail-closed recovery behavior are explicit. Be careful that the synthesiser does not infer a state machine from the crafted logic, and “undo” the work. Review the resulting gate-level or structural implementation to confirm that unintended encodings are handled as required. Perform post-synthesis simulations where faults are injected into the state registers and confirm the behavior. Perform formal analysis to prove that the behavior of these critical blocks has not been altered by the synthesis process. After the implementation is verified and validated, preserve it during integration so later synthesis or whole-design optimization does not re-encode, merge, remove, or otherwise transform the security-critical recovery logic. This approach is costly and design-specific, but it is appropriate when relying on ordinary RTL synthesis would create unacceptable security risk. Note: this is a curated list of examples for users to understand the variety of ways in which this weakness can be introduced. It is not a complete list of all CVEs that are related to this CWE entry.
This MemberOf Relationships table shows additional CWE Categories and Views that
reference this weakness as a member. This information is often useful in understanding where a
weakness fits within the context of external information sources.
More information is available — Please edit the custom filter or select a different filter. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Use of the Common Weakness Enumeration (CWE™) and the associated references from this website are subject to the Terms of Use. CWE is sponsored by the U.S. Department of Homeland Security (DHS) Cybersecurity and Infrastructure Security Agency (CISA) and managed by the Homeland Security Systems Engineering and Development Institute (HSSEDI) which is operated by The MITRE Corporation (MITRE). Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. |
||

