CWE-755 Classe Incomplet Medium likelihood

Improper Handling of Exceptional Conditions

This vulnerability occurs when software fails to properly manage unexpected situations or errors, leaving it in an unstable or insecure state.

Définition

What is CWE-755?

This vulnerability occurs when software fails to properly manage unexpected situations or errors, leaving it in an unstable or insecure state.
When a program encounters something unexpected—like a failed network connection, corrupted data, or exhausted system resources—it must handle it gracefully. Improper exception handling means the software might crash, expose sensitive debugging information, or continue operating with incorrect assumptions, creating openings for attackers to exploit. To prevent this, developers should implement robust error handling that anticipates potential failure points. This includes using structured exception handling mechanisms, defining clear recovery procedures, validating all external inputs, and ensuring the application fails securely without leaking internal details that could aid an attacker.
Impact réel

Real-world CVEs caused by CWE-755

  • SDK for OPC Unified Architecture (OPC UA) server has uncaught exception when a socket is blocked for writing but the server tries to send an error

  • Chain: JavaScript-based cryptocurrency library can fall back to the insecure Math.random() function instead of reporting a failure (CWE-392), thus reducing the entropy (CWE-332) and leading to generation of non-unique cryptographic keys for Bitcoin wallets (CWE-1391)

  • virtual interrupt controller in a virtualization product allows crash of host by writing a certain invalid value to a register, which triggers a fatal error instead of returning an error code

  • Chain: OS kernel does not properly handle a failure of a function call (CWE-755), leading to an unlock of a resource that was not locked (CWE-832), with resultant crash.

Comment les attaquants l'exploitent

Parcours de l'attaquant étape par étape

  1. 1

    The following example attempts to resolve a hostname.

  2. 2

    A DNS lookup failure will cause the Servlet to throw an exception.

  3. 3

    The following example attempts to allocate memory for a character. After the call to malloc, an if statement is used to check whether the malloc function failed.

  4. 4

    The conditional successfully detects a NULL return value from malloc indicating a failure, however it does not do anything to handle the problem. Unhandled errors may have unexpected results and may cause the program to crash or terminate.

  5. 5

    Instead, the if block should contain statements that either attempt to fix the problem or notify the user that an error has occurred and continue processing or perform some cleanup and gracefully terminate the program. The following example notifies the user that the malloc function did not allocate the required memory resources and returns an error code.

Exemple de code vulnérable

Vulnerable Java

The following example attempts to resolve a hostname.

Vulnérable Java
protected void doPost (HttpServletRequest req, HttpServletResponse res) throws IOException {
  	String ip = req.getRemoteAddr();
  	InetAddress addr = InetAddress.getByName(ip);
  	...
  	out.println("hello " + addr.getHostName());
  }
Exemple de code sécurisé

Secure C

Instead, the if block should contain statements that either attempt to fix the problem or notify the user that an error has occurred and continue processing or perform some cleanup and gracefully terminate the program. The following example notifies the user that the malloc function did not allocate the required memory resources and returns an error code.

Sécurisé C
foo=malloc(sizeof(char)); //the next line checks to see if malloc failed
  if (foo==NULL) {
  	printf("Malloc failed to allocate memory resources");
  	return -1;
  }
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-755

  • 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-755

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

This vulnerability occurs when software fails to properly manage unexpected situations or errors, leaving it in an unstable or insecure state.

Quelle est la gravité de CWE-755 ?

MITRE évalue la probabilité d'exploitation comme Moyenne — l'exploitation est réaliste mais nécessite généralement des conditions spécifiques.

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

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

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

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

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

Faiblesses associées

Weaknesses related to CWE-755

CWE-703 Parent

Improper Check or Handling of Exceptional Conditions

This vulnerability occurs when software fails to properly plan for or manage rare but possible error scenarios, leaving it unprepared for…

CWE-1384 Frère

Improper Handling of Physical or Environmental Conditions

This weakness occurs when a hardware device fails to manage unexpected physical or environmental situations, whether they happen naturally…

CWE-228 Frère

Improper Handling of Syntactically Invalid Structure

This vulnerability occurs when software fails to properly reject or process input that doesn't follow the expected format or structure,…

CWE-248 Frère

Uncaught Exception

This vulnerability occurs when a function throws an error or exception, but the calling code does not have a proper handler to catch and…

CWE-391 Frère

Unchecked Error Condition

This vulnerability occurs when a program fails to properly check or handle error conditions, such as exceptions or return codes. By…

CWE-392 Frère

Missing Report of Error Condition

This vulnerability occurs when a system fails to properly signal that an error has happened. Instead of returning a clear error code,…

CWE-393 Frère

Return of Wrong Status Code

This vulnerability occurs when a function returns an inaccurate status code or value that misrepresents the actual outcome of an…

CWE-397 Frère

Declaration of Throws for Generic Exception

This vulnerability occurs when a method is declared to throw an overly broad exception type, such as a generic 'Exception' or 'Throwable'.…

CWE-754 Frère

Improper Check for Unusual or Exceptional Conditions

This weakness occurs when software fails to properly anticipate and handle rare or unexpected runtime situations that fall outside normal…

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.