CWE-61 Compuesto Incompleto 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…

Definición

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.
Impacto en el mundo real

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

Cómo lo explotan los atacantes

Ruta del atacante paso a paso

  1. 1

    Identifica una ruta de código que maneje entrada no confiable sin validación.

  2. 2

    Crea un payload que ejercite el comportamiento inseguro — inyección, traversal, overflow o abuso de lógica.

  3. 3

    Envía el payload a través de una solicitud normal y observa la reacción de la aplicación.

  4. 4

    Itera hasta que la respuesta filtre datos, ejecute código del atacante o escale privilegios.

Ejemplo de código vulnerable

Vulnerable pseudo

MITRE no ha publicado un ejemplo de código para esta CWE. El patrón siguiente es ilustrativo — consulta Recursos para referencias canónicas.

Vulnerable pseudo
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
  // Untrusted input flows directly into the sensitive sink.
  return executeUnsafe(input);
}
Ejemplo de código seguro

Secure pseudo

Seguro 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.
Lista de prevención

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.
Señales de detección

How to detect CWE-61

SAST High

Ejecuta análisis estático (SAST) sobre el código buscando el patrón inseguro en el flujo de datos.

DAST Moderate

Ejecuta pruebas dinámicas de seguridad de aplicaciones (DAST) contra el endpoint en vivo.

Runtime Moderate

Vigila los logs en tiempo de ejecución para detectar trazas de excepción inusuales, entradas malformadas o intentos de bypass de autorización.

Code review Moderate

Revisión de código: marca cualquier código nuevo que maneje entrada desde esta superficie sin usar los helpers validados del framework.

Auto-corrección de Plexicus

Plexicus detecta automáticamente CWE-61 y abre un PR de corrección en menos de 60 segundos.

Codex Remedium escanea cada commit, identifica esta debilidad concreta y entrega un pull request listo para revisión con el parche. Sin tickets. Sin traspasos.

Preguntas frecuentes

Frequently asked questions

¿Qué es 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.

¿Qué gravedad tiene CWE-61?

MITRE califica la probabilidad de explotación como Alta — esta debilidad se explota activamente en la práctica y debe priorizarse para su remediación.

¿Qué lenguajes o plataformas se ven afectados por CWE-61?

MITRE no ha especificado plataformas afectadas para esta CWE — puede aplicar a la mayoría de los stacks de aplicaciones.

¿Cómo puedo prevenir 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…

¿Cómo detecta y corrige Plexicus CWE-61?

El motor SAST de Plexicus detecta la firma de flujo de datos para CWE-61 en cada commit. Cuando hay coincidencia, nuestro agente Codex Remedium abre un PR de corrección con el código corregido, las pruebas y un resumen de una línea para el revisor.

¿Dónde puedo aprender más sobre CWE-61?

MITRE publica la definición canónica en https://cwe.mitre.org/data/definitions/61.html. También puedes consultar la documentación de OWASP y NIST para guías relacionadas.

Debilidades relacionadas

Weaknesses related to CWE-61

CWE-59 Padre

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 Hermano

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 Hermano

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 Hermano

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 Hermano

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 Par

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 Par

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 Par

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 Par

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…

Listo cuando tú lo estés

Deja de pagar por desarrollador.
Empieza a cerrar el bucle.

Plexicus es el ASPM nativo de IA que escanea, filtra, corrige, pentestea y explica — de forma autónoma. Desarrolladores ilimitados, repos ilimitados, acciones de IA de uso justo. Nivel gratuito real, €269/mo anual cuando estés listo.