CWE-61 Compound Incomplete 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…

Definition

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.
Real-world impact

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

How attackers exploit it

Step-by-step attacker path

  1. 1

    Identify a code path that handles untrusted input without validation.

  2. 2

    Craft a payload that exercises the unsafe behavior — injection, traversal, overflow, or logic abuse.

  3. 3

    Deliver the payload through a normal request and observe the application's reaction.

  4. 4

    Iterate until the response leaks data, executes attacker code, or escalates privileges.

Vulnerable code example

Vulnerable pseudo

MITRE has not published a code example for this CWE. The pattern below is illustrative — see Resources for canonical references.

Vulnerable pseudo
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
  // Untrusted input flows directly into the sensitive sink.
  return executeUnsafe(input);
}
Secure code example

Secure pseudo

Secure 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.
Prevention checklist

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.
Detection signals

How to detect CWE-61

SAST High

Run static analysis (SAST) on the codebase looking for the unsafe pattern in the data flow.

DAST Moderate

Run dynamic application security testing against the live endpoint.

Runtime Moderate

Watch runtime logs for unusual exception traces, malformed input, or authorization bypass attempts.

Code review Moderate

Code review: flag any new code that handles input from this surface without using the validated framework helpers.

Plexicus auto-fix

Plexicus auto-detects CWE-61 and opens a fix PR in under 60 seconds.

Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.

Frequently asked questions

Frequently asked questions

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.

How serious is CWE-61?

MITRE rates the likelihood of exploit as High — this weakness is actively exploited in the wild and should be prioritized for remediation.

What languages or platforms are affected by CWE-61?

MITRE has not specified affected platforms for this CWE — it can apply across most application stacks.

How can I prevent 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…

How does Plexicus detect and fix CWE-61?

Plexicus's SAST engine matches the data-flow signature for CWE-61 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.

Where can I learn more about CWE-61?

MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/61.html. You can also reference OWASP and NIST documentation for adjacent guidance.

Related weaknesses

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 Sibling

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 Sibling

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 Sibling

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 Sibling

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 Peer

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 Peer

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 Peer

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 Peer

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…

Ready when you are

Don't Let Security
Weigh You Down.

Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.