---
title: "CWE-662: Improper Synchronization"
url: https://radicalnotion.ai/cwe/cwe-662
type: cwe
description: "The product utilizes multiple threads, processes, components, or systems to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-662: Improper Synchronization

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

## Description

The product utilizes multiple threads, processes, components, or systems to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes.

Synchronization mechanisms vary widely, but they may include locking, mutexes, and semaphores.

## Background

Synchronization refers to a variety of behaviors and mechanisms that allow two or more independently-operating processes or threads to ensure that they operate on shared resources in predictable ways that do not interfere with each other. Some shared resource operations cannot be executed atomically; that is, multiple steps must be guaranteed to execute sequentially, without any interference by other processes.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Confidentiality, Other | Modify Application Data, Modify Memory, Read Application Data, Alter Execution Logic | Improper synchronization could lead to data or memory corruption. |
| Availability | DoS: Crash, Exit, or Restart, DoS: Instability | Improper synchronization could lead to data or memory corruption, denial of service, etc. |

## Potential mitigations

### Implementation

Use industry standard APIs to synchronize your code.

## Detection methods

### Automated Static Analysis

Automated 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.)

## Demonstrative examples

### Example 1

The following function attempts to acquire a lock in order to perform operations on a shared resource.

Bad code:

```c
void f(pthread_mutex_t *mutex) {
    pthread_mutex_lock(mutex);

    /* access shared resource */

    pthread_mutex_unlock(mutex);
}
```

Good code:

```c
int f(pthread_mutex_t *mutex) {
    int result;

    result = pthread_mutex_lock(mutex);
    if (0 != result)
        return result;

    /* access shared resource */

    return pthread_mutex_unlock(mutex);
}
```

### Example 2

The following code intends to fork a process, then have both the parent and child processes print a single line.

Bad code:

```c
static void print (char * string) {
    char * word;
    int counter;
    for (word = string; counter = *word++; ) {
        putc(counter, stdout);
        fflush(stdout);
        /* Make timing window a little larger... */

        sleep(1);
    }
}

int main(void) {
    pid_t pid;

    pid = fork();
    if (pid == -1) {
        exit(-2);
    }
    else if (pid == 0) {
        print("child\n");
    }
    else {
        print("PARENT\n");
    }
    exit(0);
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2021-1782 | Chain: improper locking (CWE-667) leads to race condition (CWE-362), as exploited in the wild per CISA KEV. |
| CVE-2009-0935 | Attacker provides invalid address to a memory-reading function, causing a mutex to be unlocked twice |

## Real CVEs with this weakness (sample of 12 of 71)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2018-15555 | - | critical | 9.8 | - | No | 2019-06-28 |
| CVE-2024-32644 | Evmos' transaction execution not accounting for all state transition after interaction with precompiles | critical | 9.1 | - | No | 2024-04-19 |
| CVE-2026-63832 | wifi: mt76: add wcid publish check in mt76\_sta\_add | high | 8.8 | - | No | 2026-07-19 |
| CVE-2016-8368 | Unrestricted Externally Accessible Lock in Mitsubishi Electric MELSEC-Q Series Ethernet Interface Module | high | 8.6 | - | No | 2017-02-13 |
| CVE-2026-68149 | fs: preserve ACL\_DONT\_CACHE state in forget\_cached\_acl() | high | 8.4 | - | No | 2026-08-10 |
| CVE-2026-72057 | net/sched: act\_ct: preserve tc\_skb\_cb across defragmentation | high | 8.2 | - | No | 2026-08-15 |
| CVE-2026-43466 | net/mlx5e: Fix DMA FIFO desync on error CQE SQ recovery | high | 8.2 | - | No | 2026-05-08 |
| CVE-2026-43362 | smb: client: fix in-place encryption corruption in SMB2\_write() | high | 8.1 | - | No | 2026-05-08 |
| CVE-2025-40075 | tcp\_metrics: use dst\_dev\_net\_rcu() | high | 8.1 | - | No | 2025-10-28 |
| CVE-2026-68404 | wifi: cfg80211: use wiphy work for socket owner autodisconnect | high | 7.8 | - | No | 2026-08-10 |
| CVE-2026-64556 | perf/core: Detach event groups during remove\_on\_exec | high | 7.8 | - | No | 2026-07-29 |
| CVE-2026-64005 | net/smc: Do not re-initialize smc hashtables | high | 7.8 | - | No | 2026-07-19 |

## Related attack patterns (CAPEC)

- [CAPEC-25](https://radicalnotion.ai/capec/capec-25): Forced Deadlock
- [CAPEC-26](https://radicalnotion.ai/capec/capec-26): Leveraging Race Conditions
- [CAPEC-27](https://radicalnotion.ai/capec/capec-27): Leveraging Race Conditions via Symbolic Links
- [CAPEC-29](https://radicalnotion.ai/capec/capec-29): Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-664](https://radicalnotion.ai/cwe/cwe-664) | Improper Control of a Resource Through its Lifetime |
| Parent | [CWE-691](https://radicalnotion.ai/cwe/cwe-691) | Insufficient Control Flow Management |
| Child | [CWE-362](https://radicalnotion.ai/cwe/cwe-362) | Concurrent Execution using Shared Resource with Improper Synchronization |
| Child | [CWE-366](https://radicalnotion.ai/cwe/cwe-366) | Race Condition within a Thread |
| Child | [CWE-543](https://radicalnotion.ai/cwe/cwe-543) | Use of Singleton Pattern Without Synchronization in a Multithreaded Context |
| Child | [CWE-567](https://radicalnotion.ai/cwe/cwe-567) | Unsynchronized Access to Shared Data in a Multithreaded Context |
| Child | [CWE-663](https://radicalnotion.ai/cwe/cwe-663) | Use of a Non-reentrant Function in a Concurrent Context |
| Child | [CWE-667](https://radicalnotion.ai/cwe/cwe-667) | Improper Locking |
| Child | [CWE-764](https://radicalnotion.ai/cwe/cwe-764) | Multiple Locks of a Critical Resource |
| Child | [CWE-820](https://radicalnotion.ai/cwe/cwe-820) | Missing Synchronization |
| Child | [CWE-821](https://radicalnotion.ai/cwe/cwe-821) | Incorrect Synchronization |
| Child | [CWE-833](https://radicalnotion.ai/cwe/cwe-833) | Deadlock |
| Child | [CWE-1058](https://radicalnotion.ai/cwe/cwe-1058) | Invokable Control Element in Multi-Thread Context with non-Final Static Storable or Member Element |
| Child | [CWE-1096](https://radicalnotion.ai/cwe/cwe-1096) | Singleton Class Instance Creation without Proper Locking or Synchronization |
| Child | [CWE-1265](https://radicalnotion.ai/cwe/cwe-1265) | Unintended Reentrant Invocation of Non-reentrant Code Via Nested Calls |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Mask signals handled by noninterruptible signal handlers | SIG00-C | - |
| CERT C Secure Coding | Do not access shared objects in signal handlers | SIG31-C | CWE More Abstract |
| CLASP | State synchronization error | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not assume that a group of calls to independently atomic methods is atomic | VNA03-J | - |
| Software Fault Patterns | Missing Lock | SFP19 | - |

## Frequently asked questions

### What is CWE-662?

The product utilizes multiple threads, processes, components, or systems to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes.

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

71 recorded CVEs are attributed to CWE-662, including CVE-2018-15555, CVE-2024-32644 and CVE-2026-63832.

### How do you prevent CWE-662?

Use industry standard APIs to synchronize your code.

### How is CWE-662 detected?

Automated Static Analysis: Automated 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.)

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

Exploiting CWE-662 can lead to: Modify Application Data, Modify Memory, Read Application Data, Alter Execution Logic, DoS: Crash, Exit, or Restart, DoS: Instability.

### Is CWE-662 actively exploited?

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

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

---

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