CWE-820 Base Incomplet

Missing Synchronization

This vulnerability occurs when multiple parts of your application (like threads or processes) use the same resource—such as a variable, file, or data structure—without proper coordination to control…

Définition

What is CWE-820?

This vulnerability occurs when multiple parts of your application (like threads or processes) use the same resource—such as a variable, file, or data structure—without proper coordination to control who accesses it and when.
When different parts of your code run concurrently and touch a shared resource without synchronization, the resource's state can become unpredictable. One thread might read a value while another is halfway through modifying it, or two processes might overwrite each other's changes, leading to corrupted data, crashes, or incorrect calculations that break your application's logic. This lack of coordination creates a race condition window that attackers can potentially exploit. By carefully timing their interactions, an attacker might manipulate the shared resource into an unexpected state that bypasses security checks, leaks sensitive information, or causes the system to behave in unintended and insecure ways.
Impact réel

Real-world CVEs caused by CWE-820

Aucune référence CVE publique n'est liée à ce CWE dans le catalogue MITRE pour le moment.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

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

  2. 2

    One might expect the code to print out something like:

  3. 3

    ``` PARENT child ```

  4. 4

    However, because the parent and child are executing concurrently, and stdout is flushed each time a character is printed, the output might be mixed together, such as:

  5. 5

    ``` PcAhRiElNdT [blank line] [blank line] ```

Exemple de code vulnérable

Vulnerable C

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

Vulnérable 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);
  }
Exemple de code sécurisé

Secure pseudo

Sécurisé pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Liste de contrôle de prévention

How to prevent CWE-820

  • Architecture Use safe-by-default frameworks and APIs that prevent the unsafe pattern from being expressible.
  • Implementation Validate input at trust boundaries; use allowlists, not denylists.
  • Implementation Apply the principle of least privilege to credentials, file paths, and runtime permissions.
  • Testing Cover this weakness in CI: SAST rules + targeted unit tests for the data flow.
  • Operation Monitor logs for the runtime signals listed in the next section.
Signaux de détection

How to detect CWE-820

SAST High

Exécuter une analyse statique (SAST) sur le code source à la recherche du motif non sécurisé dans le flux de données.

DAST Moderate

Exécuter des tests de sécurité applicative dynamique (DAST) contre le point de terminaison en ligne.

Runtime Moderate

Surveiller les journaux runtime pour détecter des traces d'exception inhabituelles, des entrées malformées ou des tentatives de contournement d'autorisation.

Code review Moderate

Revue de code : signaler tout nouveau code qui traite les entrées de cette surface sans utiliser les helpers du framework validés.

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-820 et ouvre une PR de correction en moins de 60 secondes.

Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.

Questions fréquentes

Frequently asked questions

Qu'est-ce que CWE-820 ?

This vulnerability occurs when multiple parts of your application (like threads or processes) use the same resource—such as a variable, file, or data structure—without proper coordination to control who accesses it and when.

Quelle est la gravité de CWE-820 ?

MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.

Quels langages ou plateformes sont affectés par CWE-820 ?

MITRE n'a pas spécifié les plateformes affectées pour ce CWE — il peut s'appliquer à la plupart des stacks applicatives.

Comment puis-je prévenir CWE-820 ?

Use safe-by-default frameworks, validate untrusted input at trust boundaries, and apply the principle of least privilege. Cover the data-flow signature in CI with SAST.

Comment Plexicus détecte et corrige CWE-820 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-820 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.

Où puis-je en savoir plus sur CWE-820 ?

MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/820.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.

Faiblesses associées

Weaknesses related to CWE-820

CWE-662 Parent

Improper Synchronization

This vulnerability occurs when a multi-threaded or multi-process application allows shared resources to be accessed by multiple threads or…

CWE-1058 Frère

Invokable Control Element in Multi-Thread Context with non-Final Static Storable or Member Element

This happens when a method or function, designed to run in a multi-threaded environment, accesses or modifies a non-final static variable…

CWE-1096 Frère

Singleton Class Instance Creation without Proper Locking or Synchronization

This flaw occurs when a Singleton class is implemented without proper thread-safe controls, allowing multiple instances to be created in…

CWE-366 Frère

Race Condition within a Thread

This vulnerability occurs when two or more threads within the same application access and manipulate a shared resource (like a variable,…

CWE-543 Frère

Use of Singleton Pattern Without Synchronization in a Multithreaded Context

This vulnerability occurs when a singleton pattern is implemented in a multithreaded application without proper synchronization,…

CWE-567 Frère

Unsynchronized Access to Shared Data in a Multithreaded Context

This vulnerability occurs when multiple threads in an application can read and modify shared data, like static variables, without proper…

CWE-663 Frère

Use of a Non-reentrant Function in a Concurrent Context

This vulnerability occurs when a program uses a function that is not safe for reentrancy within a concurrent environment, such as…

CWE-667 Frère

Improper Locking

This vulnerability occurs when a program fails to correctly acquire or release a lock on a shared resource, such as a file, database…

CWE-764 Frère

Multiple Locks of a Critical Resource

This vulnerability occurs when a critical resource, such as a file, data structure, or connection, is locked more times than the software…

Prêt quand vous l'êtes

Arrêtez de payer par développeur.
Commencez à fermer la boucle.

Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.