CWE-459 Base Brouillon

Incomplete Cleanup

This vulnerability occurs when an application fails to properly remove temporary files, data structures, or system resources after they are no longer needed.

Définition

What is CWE-459?

This vulnerability occurs when an application fails to properly remove temporary files, data structures, or system resources after they are no longer needed.
Incomplete cleanup happens when developers focus on the primary function of their code but neglect the final 'housekeeping' steps. This often involves forgetting to close file handles, database connections, or network sockets, or leaving temporary files in shared directories. These leftover resources can accumulate over time, leading to performance degradation, data leaks, or denial of service as system limits are reached. From a security perspective, uncleaned temporary files can expose sensitive data to other users or processes on the system. In multi-user environments, this can allow unauthorized access to session tokens, configuration secrets, or user data. The risk is particularly high when predictable filenames are used, as attackers can easily locate and exploit these residual artifacts.
Impact réel

Real-world CVEs caused by CWE-459

  • World-readable temporary file not deleted after use.

  • Temporary file not deleted after use, leaking database usernames and passwords.

  • Interaction error creates a temporary file that can not be deleted due to strong permissions.

  • Alternate data streams for NTFS files are not cleared when files are wiped (alternate channel / infoleak).

  • Alternate data streams for NTFS files are not cleared when files are wiped (alternate channel / infoleak).

  • Alternate data streams for NTFS files are not cleared when files are wiped (alternate channel / infoleak).

  • Alternate data streams for NTFS files are not cleared when files are wiped (alternate channel / infoleak).

  • Alternate data streams for NTFS files are not cleared when files are wiped (alternate channel / infoleak).

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

Stream resources in a Java application should be released in a finally block, otherwise an exception thrown before the call to close() would result in an unreleased I/O resource. In the example below, the close() method is called in the try block (incorrect).

Vulnérable Java
try {
  	InputStream is = new FileInputStream(path);
  	byte b[] = new byte[is.available()];
  	is.read(b);
  	is.close();
  } catch (Throwable t) {
  	log.error("Something bad happened: " + t.getMessage());
  }
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-459

  • Architecture and Design / Implementation Temporary files and other supporting resources should be deleted/released immediately after they are no longer needed.
Signaux de détection

How to detect CWE-459

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

This vulnerability occurs when an application fails to properly remove temporary files, data structures, or system resources after they are no longer needed.

Quelle est la gravité de CWE-459 ?

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

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

Temporary files and other supporting resources should be deleted/released immediately after they are no longer needed.

Comment Plexicus détecte et corrige CWE-459 ?

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

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

Faiblesses associées

Weaknesses related to CWE-459

CWE-404 Parent

Improper Resource Shutdown or Release

This vulnerability occurs when a program fails to properly close or release a system resource—like a file handle, database connection, or…

CWE-1266 Frère

Improper Scrubbing of Sensitive Data from Decommissioned Device

This vulnerability occurs when a system lacks a reliable method for administrators to permanently erase sensitive information before…

CWE-299 Frère

Improper Check for Certificate Revocation

This vulnerability occurs when an application fails to properly verify whether a security certificate has been revoked, potentially…

CWE-401 Frère

Missing Release of Memory after Effective Lifetime

This vulnerability occurs when a program allocates memory but fails to properly release it after it's no longer needed, causing a gradual…

CWE-761 Frère

Free of Pointer not at Start of Buffer

This vulnerability occurs when a program incorrectly frees a memory pointer that no longer points to the beginning of the allocated heap…

CWE-762 Frère

Mismatched Memory Management Routines

This vulnerability occurs when a program uses incompatible functions to allocate and free memory. For example, freeing memory with a…

CWE-763 Frère

Release of Invalid Pointer or Reference

This vulnerability occurs when a program tries to free a memory resource back to the system but uses an incorrect deallocation method or…

CWE-772 Frère

Missing Release of Resource after Effective Lifetime

This vulnerability occurs when a program fails to properly release a system resource—like memory, file handles, or network sockets—after…

CWE-775 Frère

Missing Release of File Descriptor or Handle after Effective Lifetime

This vulnerability occurs when a program fails to properly close file descriptors or handles after they are no longer needed, leaving…

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.