CWE-61 Composé Incomplet High likelihood

UNIX Symbolic Link (Symlink) Following

This vulnerability occurs when a software application opens files or directories without properly checking if they are symbolic links (symlinks). If an attacker can create or control a symlink, they…

Définition

What is CWE-61?

This vulnerability occurs when a software application opens files or directories without properly checking if they are symbolic links (symlinks). If an attacker can create or control a symlink, they can redirect file operations to locations outside the intended directory, potentially accessing or modifying unauthorized files.
In Unix-like systems, symbolic links are shortcuts that point to other files or directories. When an application uses paths that can contain symlinks—whether from internal logic or user-supplied input—an attacker can create a malicious symlink that points anywhere in the filesystem. This bypasses the application's intended directory restrictions, allowing the attacker to traverse to sensitive locations they shouldn't access. Without proper validation, the application will follow the symlink and perform operations like reading, writing, or deleting on the target file. This means an attacker could expose confidential data, corrupt critical system files, or escalate privileges by manipulating files originally protected by normal permissions. The core issue is that the application trusts the path structure without verifying that symlinks haven't redirected it outside its allowed scope.
Impact réel

Real-world CVEs caused by CWE-61

  • Some versions of Perl follow symbolic links when running with the -e option, which allows local users to overwrite arbitrary files via a symlink attack.

  • Text editor follows symbolic links when creating a rescue copy during an abnormal exit, which allows local users to overwrite the files of other users.

  • Antivirus update allows local users to create or append to arbitrary files via a symlink attack on a logfile.

  • Symlink attack allows local users to overwrite files.

  • Possible interesting example

  • Second-order symlink vulnerabilities

  • Second-order symlink vulnerabilities

  • Symlink in Python program

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 pseudo

MITRE n'a pas publié d'exemple de code pour ce CWE. Le motif ci-dessous est illustratif — voir Ressources pour les références canoniques.

Vulnérable pseudo
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
  // Untrusted input flows directly into the sensitive sink.
  return executeUnsafe(input);
}
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-61

  • Implementation Symbolic link attacks often occur when a program creates a tmp directory that stores files/links. Access to the directory should be restricted to the program as to prevent attackers from manipulating the files.
  • Architecture and Design Follow the principle of least privilege when assigning access rights to entities in a software system. Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file. Ensure good compartmentalization in the system to provide protected areas that can be trusted.
Signaux de détection

How to detect CWE-61

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

This vulnerability occurs when a software application opens files or directories without properly checking if they are symbolic links (symlinks). If an attacker can create or control a symlink, they can redirect file operations to locations outside the intended directory, potentially accessing or modifying unauthorized files.

Quelle est la gravité de CWE-61 ?

MITRE évalue la probabilité d'exploitation comme Élevée — cette faiblesse est activement exploitée et doit être priorisée pour la remédiation.

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

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

Symbolic link attacks often occur when a program creates a tmp directory that stores files/links. Access to the directory should be restricted to the program as to prevent attackers from manipulating the files. Follow the principle of least privilege when assigning access rights to entities in a software system. Denying access to a file can prevent an attacker from replacing that file with a link to a sensitive file. Ensure good compartmentalization in the system to provide protected areas…

Comment Plexicus détecte et corrige CWE-61 ?

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

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

Faiblesses associées

Weaknesses related to CWE-61

CWE-59 Parent

Improper Link Resolution Before File Access ('Link Following')

This vulnerability occurs when an application uses a filename to access a file but fails to properly check if that name points to a…

CWE-1386 Frère

Insecure Operation on Windows Junction / Mount Point

This vulnerability occurs when a Windows application opens a file or directory without properly validating that the path is not a symbolic…

CWE-62 Frère

UNIX Hard Link

This vulnerability occurs when an application opens a file or directory without verifying if the name points to a hard link that leads…

CWE-64 Frère

Windows Shortcut Following (.LNK)

This vulnerability occurs when an application opens a file or directory without properly validating that it is a Windows shortcut (.LNK).…

CWE-65 Frère

Windows Hard Link

This vulnerability occurs when a Windows application opens a file or directory without properly verifying if the path points to a hard…

CWE-362 Pair

Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

A race condition occurs when multiple processes or threads access a shared resource simultaneously without proper coordination, creating a…

CWE-340 Pair

Generation of Predictable Numbers or Identifiers

This vulnerability occurs when a system creates numbers or identifiers that are too easy to guess, undermining security mechanisms that…

CWE-386 Pair

Symbolic Name not Mapping to Correct Object

This vulnerability occurs when a program uses a fixed symbolic name (like a constant or identifier) to refer to an object, but that name…

CWE-732 Pair

Incorrect Permission Assignment for Critical Resource

This vulnerability occurs when a system grants overly permissive access to a sensitive resource, allowing unauthorized users or processes…

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.