CWE-366 · Słabość
Race Condition within a Thread
- Abstrakcja
- Bazowa
- Status
- Szkic
- Ryzyko wykorzystania
- średnie
- Dodano
- 19 lipca 2006
- Ostatnia zmiana
- 11 grudnia 2025
Opis
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.
Skutki
Integrity, Other
Alter Execution Logic; Unexpected State
The main problem is that -- if a lock is overcome -- data could be altered in a bad state.
Zapobieganie
Architecture and Design
Use 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.
Architecture and Design
Create 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.
Przykłady podatności
- CVE-2022-2621 Chain: two threads in a web browser use the same resource (CWE-366), but one of those threads can destroy the resource before the other has completed (CWE-416).
Słabość nadrzędna
Kiedy powstaje
- Implementation
Dotyczy
C, C++, Java, C#, Not Technology-Specific
Źródła
- The CLASP Application Security Process — Secure Software, Inc., 2005
- 24 Deadly Sins of Software Security — Michael Howard, David LeBlanc, John Viega, "Sin 13: Race Conditions." Page 205, McGraw-Hill, 2010
- The Art of Software Security Assessment — Mark Dowd, John McDonald, Justin Schuh, Chapter 13, "Race Conditions", Page 759, Addison Wesley, 2006
Wpis z katalogu CWE 4.20.