CWE-366: Race Condition within a Thread

What is CWE-366?

CWE-366 is Race Condition within a Thread. The flaw arises when if two threads of execution use a resource simultaneously, there exists the possibility that resources may be used while invalid, in turn making the state of execution undefined. The database currently holds 4 vulnerabilities mapped to CWE-366 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

Analyzing data...

OWASP Top 10 Rank-
Related CVES (365 days)4
AbstractionBase
Likelihood of exploitMedium

Vulnerabilities mapped to CWE-366

4 vulnerabilities

No data

No vulnerability data in CISA KEV for CWE-366

Official definition

ByMitre CWE

If two threads of execution use a resource simultaneously, there exists the possibility that resources may be used while invalid, in turn making the state of execution undefined.

Characteristics

Modes of introduction

  • Implementation

Common consequences

ImpactScopeExplanation
Alter Execution Logic, Unexpected StateIntegrity, OtherThe main problem is that -- if a lock is overcome -- data could be altered in a bad state.

Risk mitigations

  1. Architecture and DesignUse locking functionality. This is the recommended solution. Implement some form of locking mechanism around code which alters or reads persistent data in a multithreaded environment.
  2. Architecture and DesignCreate resource-locking validation checks. If no inherent locking mechanisms exist, use flags and signals to enforce your own blocking scheme when resources are being used by other threads of execution.

Detection methods

MethodApproachEffectiveness
Automated Static AnalysisAutomated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)High

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.