/

CVE-2026-32116

Severity:

HIGH RISK

(8.1)

Path Traversal in Magic Wormhole File Receiving Flow

CVE-2026-32116

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Local File Overwrite and Potential System Compromise

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Magic Wormhole versions 0.21.0 to before 0.23.0 contain a path traversal vulnerability in the wormhole receive operation that can allow a malicious sender to overwrite critical files on the receiver's system.

By crafting file paths that target locations like ~/.ssh/authorized_keys or .bashrc, an attacker who controls the sending side may be able to compromise the receiver's machine when they accept the transfer.

Affected context

The vulnerability occurs in Magic Wormhole's file receiving logic when a user runs wormhole receive and accepts content from a peer.

It is relevant in scenarios where the receiver implicitly trusts the sender or does not inspect the file paths being transferred.

The risk materializes when the application allows received files or directories to be written without sufficient validation of their destination paths, enabling writes outside the intended download directory and into sensitive locations in the user's home directory.

Exploit preconditions

  • Attack surface: The wormhole receive command on a user's machine.
  • Required access: The attacker must be the sender in an established Magic Wormhole session; they need the ability to initiate wormhole send and get the receiver to complete the transfer.
  • User interaction: The receiver must accept the transfer, typically trusting the sender or the code phrase/connection setup.
  • Trigger point: The vulnerability is triggered when the receiving side writes the incoming file or directory structure to disk using attacker-controlled path information.
  • Why exploitation is possible: The file handling logic fails to adequately sanitize or constrain incoming paths, allowing traversal out of the intended receive directory and enabling overwrites of existing files in sensitive locations.

Why this happens

This vulnerability stems from inadequate validation of file and directory paths supplied by the remote sender before writing them to the local filesystem.

When the receiving code trusts inbound metadata (such as filenames or relative paths) and combines them with the local filesystem without enforcing strict constraints, an attacker can craft paths that escape the intended destination directory.

This is a typical CWE-22: Path Traversal pattern, where untrusted input is used in file system operations (creation or overwrite) without normalization and boundary checks, permitting writes to arbitrary locations under the user's permissions.

Potential impact

  • Overwrite of critical shell configuration files (e.g., .bashrc) which could be used to execute attacker-controlled commands when the shell starts.
  • Overwrite of SSH authorization files (e.g., ~/.ssh/authorized_keys), allowing the attacker to gain persistent remote access using their own SSH key.
  • Modification or corruption of other application or configuration files in the user's home directory.
  • Loss of integrity and potential loss of availability for user data stored in overwritten files.
  • Broader system compromise if overwritten files are used in privileged or security-sensitive workflows.

General mitigation guidance

Mitigation focuses on constraining where received files can be written and eliminating the influence of untrusted path components on filesystem operations.

Useful defensive patterns include:

  • Normalizing and validating filenames and directory paths before writing them, rejecting or sanitizing any input that attempts to traverse outside the intended receive directory.
  • Enforcing a dedicated, application-controlled download directory and preventing writes above this root (e.g., via path canonicalization and prefix checks).
  • Stripping or rejecting path separators, parent directory references (..), absolute paths, or leading home-directory indicators from filenames provided by the sender.
  • Applying a "safe list" approach for allowed path patterns and explicitly blocking unusual or control-character-laden names.
  • Running the application with least-privilege filesystem permissions, avoiding execution in contexts where overwriting configuration files would have severe consequences.

How teams detect issues like this

Organizations can detect similar issues through a combination of code-centric and behavior-centric approaches:

  • Static analysis: Configure rules to flag uses of attacker-controlled or network-derived path components that feed into file open, write, or extraction operations without normalization and boundary checks.
  • Code review: Look for file handling logic in receive or sync features where filenames originate from peers, archives, or external metadata; verify that paths are canonicalized and constrained to a safe root directory.
  • Security testing: Perform dynamic tests where crafted filenames (including ../, absolute paths, home-directory references, and nested directory structures) are sent to the receiver to observe whether files are created outside the expected directory.
  • Policy enforcement: Integrate automated checks in CI pipelines that scan for dangerous file handling patterns and require security review for any feature that writes files based on remote input.

Sources

SourceLink
github.comgithub.com/magic-wormhole/magic-wormhole/security/advisories/GHSA-4g4c-mfqg-pj8r

Frequently asked

questions

Yes, but only by the party acting as the sender in a Magic Wormhole session. They can exploit the issue over the network once the receiver accepts the transfer; intermediary servers cannot directly leverage this flaw.

The attacker must be able to initiate wormhole send and convince or trick the victim into running wormhole receive with the matching code and accepting the transfer. No prior access to the victim's system is required beyond this interaction.

Implement strict path validation and confinement: normalize all incoming filenames, reject unsafe constructs (such as .., absolute paths, and home-directory references), and ensure all writes remain within a designated, controlled directory. Treat remote filenames as untrusted metadata.

Design file-receiving and synchronization features under a "principle of least privilege for paths," where remote input cannot influence where on disk data is stored beyond a constrained sandbox. Combine this with automated tests, static analysis rules for file I/O, and security-focused code review practices for any logic that touches the filesystem based on external input.

Find out what's already
exploitable in your codebase.