---
title: "CWE-1298: Hardware Logic Contains Race Conditions"
url: https://radicalnotion.ai/cwe/cwe-1298
type: cwe
description: "A race condition in the hardware logic results in undermining security guarantees of the system."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-1298: Hardware Logic Contains Race Conditions

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 3
- **Of those, in CISA KEV:** 0
- **New in 2026:** 1
- **CWE catalog version:** 4.21

## Description

A race condition in the hardware logic results in undermining security guarantees of the system.

A race condition in logic circuits typically occurs when a logic gate gets inputs from signals that have traversed different paths while originating from the same source. Such inputs to the gate can change at slightly different times in response to a change in the source signal. This results in a timing error or a glitch (temporary or permanent) that causes the output to change to an unwanted state before settling back to the desired state.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | - |

## Applicable platforms

**Languages:** Verilog (Undetermined), VHDL (Undetermined)

**Technologies:** System on Chip (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Bypass Protection Mechanism, Gain Privileges or Assume Identity, Alter Execution Logic | If timing errors occur in access control logic or finite state machines that are implemented in security sensitive flows, an attacker might exploit them to circumvent existing protections. |

## Potential mitigations

### Architecture and Design

Adopting design practices that encourage designers to recognize and eliminate race conditions, such as Karnaugh maps, could result in the decrease in occurrences of race conditions.

### Implementation

Logic redundancy can be implemented along security critical paths to prevent race conditions. To avoid metastability, it is a good practice in general to default to a secure state in which access is not given to untrusted agents.

## Demonstrative examples

### Example 1

The code below shows a 2x1 multiplexor using logic gates. Though the code shown below results in the minimum gate solution, it is disjoint and causes glitches.

Bad code:

```verilog
// 2x1 Multiplexor using logic-gates

module glitchEx(
    input wire in0, in1, sel,
    output wire z
);

wire not_sel;
wire and_out1, and_out2;

assign not_sel = ~sel;
assign and_out1 = not_sel & in0;
assign and_out2 = sel & in1;

// Buggy line of code:
assign z = and_out1 | and_out2; // glitch in signal z

endmodule
```

### Example 2

The example code is taken from the DMA (Direct Memory Access) module of the buggy OpenPiton SoC of HACK@DAC'21. The DMA contains a finite-state machine (FSM) for accessing the permissions using the physical memory protection (PMP) unit.

PMP provides secure regions of physical memory against unauthorized access. It allows an operating system or a hypervisor to define a series of physical memory regions and then set permissions for those regions, such as read, write, and execute permissions. When a user tries to access a protected memory area (e.g., through DMA), PMP checks the access of a PMP address (e.g., pmpaddr\_i) against its configuration (pmpcfg\_i). If the access violates the defined permissions (e.g., CTRL\_ABORT), the PMP can trigger a fault or an interrupt. This access check is implemented in the pmp parameterized module in the below code snippet. The below code assumes that the state of the pmpaddr\_i and pmpcfg\_i signals will not change during the different DMA states (i.e., CTRL\_IDLE to CTRL\_DONE) while processing a DMA request (via dma\_ctrl\_reg). The DMA state machine is implemented using a case statement (not shown in the code snippet).

Bad code:

```systemverilog
module dma # (...)(...);
...
    input [7:0] [16-1:0] pmpcfg_i;
    input logic [16-1:0][53:0]     pmpaddr_i;
    ...
    //// Save the input command
    always @ (posedge clk_i or negedge rst_ni)
        begin: save_inputs
        if (!rst_ni)
            begin
            ...
            end
        else
            begin
                if (dma_ctrl_reg == CTRL_IDLE || dma_ctrl_reg == CTRL_DONE)
                begin
                ...
                end
            end
        end // save_inputs
        ...
        // Load/store PMP check
        pmp #(
            .XLEN       ( 64                     ),
            .PMP_LEN    ( 54                     ),
            .NR_ENTRIES ( 16           )
        ) i_pmp_data (
            .addr_i        ( pmp_addr_reg        ),
            .priv_lvl_i    ( riscv::PRIV_LVL_U   ),
            .access_type_i ( pmp_access_type_reg ),
            // Configuration
            .conf_addr_i   ( pmpaddr_i           ),
            .conf_i        ( pmpcfg_i            ),
            .allow_o       ( pmp_data_allow      )
        );
endmodule
```

Good code:

```systemverilog
module dma # (...)(...);
...
    input [7:0] [16-1:0] pmpcfg_i;
    input logic [16-1:0][53:0]     pmpaddr_i;
    ...
    reg [7:0] [16-1:0] pmpcfg_reg;
    reg [16-1:0][53:0] pmpaddr_reg;
    ...
    //// Save the input command
    always @ (posedge clk_i or negedge rst_ni)
        begin: save_inputs
        if (!rst_ni)
            begin
            ...
            pmpaddr_reg <= 'b0 ;
            pmpcfg_reg <= 'b0 ;
            end
        else
            begin
                if (dma_ctrl_reg == CTRL_IDLE || dma_ctrl_reg == CTRL_DONE)
                begin
                ...
                pmpaddr_reg <= pmpaddr_i;
                pmpcfg_reg <= pmpcfg_i;
                end
            end
        end // save_inputs
        ...
        // Load/store PMP check
        pmp #(
            .XLEN       ( 64                     ),
            .PMP_LEN    ( 54                     ),
            .NR_ENTRIES ( 16           )
        ) i_pmp_data (
            .addr_i        ( pmp_addr_reg        ),
            .priv_lvl_i    ( riscv::PRIV_LVL_U   ), // we intend to apply filter on
            // DMA always, so choose the least privilege .access_type_i ( pmp_access_type_reg ),
            // Configuration
            .conf_addr_i   ( pmpaddr_reg           ),
            .conf_i        ( pmpcfg_reg            ),
            .allow_o       ( pmp_data_allow      )
        );
endmodule
```

However, the above code \[REF-1394\] allows the values of pmpaddr\_i and pmpcfg\_i to be changed through DMA's input ports. This causes a race condition and will enable attackers to access sensitive addresses that the configuration is not associated with.

Attackers can initialize the DMA access process (CTRL\_IDLE) using pmpcfg\_i for a non-privileged PMP address (pmpaddr\_i). Then during the loading state (CTRL\_LOAD), attackers can replace the non-privileged address in pmpaddr\_i with a privileged address without the requisite authorized access configuration.

To fix this issue (see \[REF-1395\]), the value of the pmpaddr\_i and pmpcfg\_i signals should be stored in local registers (pmpaddr\_reg and pmpcfg\_reg at the start of the DMA access process and the pmp module should reference those registers instead of the signals directly. The values of the registers can only be updated at the start (CTRL\_IDLE) or the end (CTRL\_DONE) of the DMA access process, which prevents attackers from changing the PMP address in the middle of the DMA access process.

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-20707 | - | medium | 6.8 | - | No | 2026-08-11 |
| CVE-2023-20827 | - | medium | 6.7 | - | No | 2023-09-04 |
| CVE-2023-45733 | intel-microcode: Race conditions in some Intel(R) Processors | low | 2.8 | - | No | 2024-05-16 |

## Related attack patterns (CAPEC)

- [CAPEC-26](https://radicalnotion.ai/capec/capec-26): Leveraging Race Conditions

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-362](https://radicalnotion.ai/cwe/cwe-362) | Concurrent Execution using Shared Resource with Improper Synchronization |

## Frequently asked questions

### What is CWE-1298?

A race condition in the hardware logic results in undermining security guarantees of the system.

### What CVEs are caused by CWE-1298?

3 recorded CVEs are attributed to CWE-1298, including CVE-2026-20707, CVE-2023-20827 and CVE-2023-45733.

### How do you prevent CWE-1298?

Adopting design practices that encourage designers to recognize and eliminate race conditions, such as Karnaugh maps, could result in the decrease in occurrences of race conditions.

### What are the consequences of CWE-1298?

Exploiting CWE-1298 can lead to: Bypass Protection Mechanism, Gain Privileges or Assume Identity, Alter Execution Logic.

### Is CWE-1298 actively exploited?

3 recorded CVEs are caused by CWE-1298; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/1298.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-1298). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
