CWE-585 Variante Brouillon

Empty Synchronized Block

An empty synchronized block is a Java code construct where a synchronized block exists but contains no executable statements inside it.

Définition

What is CWE-585?

An empty synchronized block is a Java code construct where a synchronized block exists but contains no executable statements inside it.
An empty synchronized block is a logic flaw that fails to provide any actual thread safety or mutual exclusion. While the synchronized keyword is present, the block does nothing to protect shared data or coordinate threads, leaving critical sections of your code vulnerable to race conditions and concurrency bugs. This issue often arises during code maintenance, such as when a developer comments out or removes the internal logic for debugging but forgets to remove the now-useless synchronization wrapper. It serves as a clear red flag for developers to review that section of code, as it either indicates missing functionality or unnecessary overhead that can harm performance without benefit.
Impact réel

Real-world CVEs caused by CWE-585

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

    Identifier un chemin de code qui traite des entrées non fiables sans validation.

  2. 2

    Élaborer une charge utile qui exploite le comportement non sécurisé — injection, traversal, débordement ou abus de logique.

  3. 3

    Délivrer la charge utile via une requête normale et observer la réaction de l'application.

  4. 4

    Itérer jusqu'à ce que la réponse divulgue des données, exécute le code de l'attaquant ou élève les privilèges.

Exemple de code vulnérable

Vulnerable Java

The following code attempts to synchronize on an object, but does not execute anything in the synchronized block. This does not actually accomplish anything and may be a sign that a programmer is wrestling with synchronization but has not yet achieved the result they intend.

Vulnérable Java
synchronized(this) { }
Exemple de code sécurisé

Secure Java

Instead, in a correct usage, the synchronized statement should contain procedures that access or modify data that is exposed to multiple threads. For example, consider a scenario in which several threads are accessing student records at the same time. The method which sets the student ID to a new value will need to make sure that nobody else is accessing this data at the same time and will require synchronization.

Sécurisé Java
public void setID(int ID){
  	synchronized(this){
  		this.ID = ID;
  	}
  }
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-585

  • Implementation When you come across an empty synchronized statement, or a synchronized statement in which the code has been commented out, try to determine what the original intentions were and whether or not the synchronized block is still necessary.
Signaux de détection

How to detect CWE-585

Automated Static Analysis High

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

Correction automatique Plexicus

Plexicus détecte automatiquement CWE-585 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-585 ?

An empty synchronized block is a Java code construct where a synchronized block exists but contains no executable statements inside it.

Quelle est la gravité de CWE-585 ?

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-585 ?

MITRE lists the following affected platforms: Java.

Comment puis-je prévenir CWE-585 ?

When you come across an empty synchronized statement, or a synchronized statement in which the code has been commented out, try to determine what the original intentions were and whether or not the synchronized block is still necessary.

Comment Plexicus détecte et corrige CWE-585 ?

Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-585 à 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-585 ?

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

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.