/

CVE-2026-41180

Severity:

HIGH RISK

(7.5)

Path Traversal in PsiTransfer File Upload Handler

CVE-2026-41180

Deferred

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write leading to Remote Code Execution on restart

Severity:

HIGH RISK

(7.5)

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

PsiTransfer's upload PATCH endpoint mishandles encoded versus decoded path values, allowing an attacker to write files outside the intended upload directory in certain custom deployments.

In environments where the upload directory name prefixes a JavaScript configuration path, an unauthenticated attacker can create a config.<NODE_ENV>.js file in the application root that will be executed on the next process restart.

Affected context

This vulnerability appears in PsiTransfer deployments that:

  • Expose the /files/:uploadId tus upload PATCH endpoint to unauthenticated clients
  • Use a custom PSITRANSFER_UPLOAD_DIR whose basename prefixes a startup-loaded JavaScript configuration path (for example, conf leading to config.<NODE_ENV>.js)
  • Run in an environment where application configuration files (like config.<NODE_ENV>.js) are loaded and executed from the application root on process start

Under these conditions, mismatched validation and write paths between encoded req.path and decoded req.params.uploadId can let uploads escape the intended directory layout.

Exploit preconditions

  • Attack surface: HTTP PATCH requests to the /files/:uploadId endpoint using the tus upload protocol
  • Required access: No authentication required; the endpoint is typically public for file uploads
  • Trigger point: Sending a crafted uploadId that, once decoded, resolves to a path that overlaps with or escapes toward a JavaScript configuration filename in the application root
  • Why exploitation is possible:
  • The framework validates the mounted path using the still-encoded req.path, assuming it constrains the upload to the configured directory
  • The downstream tus handler later interprets and writes using the decoded req.params.uploadId
  • When PSITRANSFER_UPLOAD_DIR is chosen such that its basename prefixes a config filename path, the decoded upload ID can be manipulated so the resulting write lands at config.<NODE_ENV>.js in the application root

Why this happens

The bug stems from inconsistent use of encoded versus decoded request path values when validating and using filesystem paths.

The application checks mount constraints against the encoded req.path, implicitly assuming that this validation guarantees that subsequent operations will stay within the upload directory.

However, the tus handler later uses the decoded req.params.uploadId to derive the actual file system path, effectively bypassing the earlier validation.

This pattern maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled path segments are insufficiently normalized and constrained before being used for file writes, enabling directory traversal or arbitrary file write into sensitive locations.

Potential impact

  • Attacker-controlled creation of config.<NODE_ENV>.js in the application root
  • Execution of attacker-supplied JavaScript code on the next application restart
  • Full compromise of the server-side application runtime (remote code execution on restart)
  • Tampering with application behavior, including authentication, logging, or routing logic defined in configuration
  • Potential pivot to broader system compromise depending on runtime privileges

General mitigation guidance

Effective mitigation focuses on strict, normalized path handling and isolation of upload data:

  • Normalize and validate all path components after decoding, ensuring the final resolved path is within an expected upload root directory
  • Treat uploadId and similar identifiers as opaque tokens, not as file paths; map them through a safe lookup (e.g., an ID-to-filename mapping) rather than using them directly in filesystem operations
  • Use filesystem APIs that operate on precomputed, canonical paths and compare them against an expected base directory before writing
  • Avoid choosing upload directories whose names overlap or prefix sensitive configuration or code paths in the application root
  • Separate writable upload locations from executable or configuration directories, and configure runtimes so that user-writable locations are never interpreted as code

How teams detect issues like this

Organizations can look for this class of issue using:

  • Static analysis patterns:
  • Identification of request path parameters (e.g., req.params.uploadId, req.path) being concatenated or interpolated into filesystem paths
  • Checks that path validation occurs after URL decoding and that canonicalization (e.g., resolving .., symlinks) is performed before use
  • Rules that flag code writing to executable or configuration directories using user-controlled data
  • Code review signals:
  • Inconsistent usage of encoded versus decoded path variables
  • Use of URL or path segments from HTTP requests as direct filenames without normalization and boundary checks
  • Writable directories located in or adjacent to code/config folders
  • Policy enforcement and tooling:
  • CI checks to prevent new code paths that mix HTTP parameters and filesystem operations without canonicalization
  • Optional use of dependency and configuration scanners to flag applications where upload directories and configuration directories overlap or share naming patterns

Sources

SourceLink
github.comgithub.com/psi-4ward/psitransfer/commit/8b547bf3e09757122efa00aab90281e3915aa0c6
github.comgithub.com/psi-4ward/psitransfer/releases/tag/v2.4.3
github.comgithub.com/psi-4ward/psitransfer/security/advisories/GHSA-533q-w4g6-5586

Frequently asked

questions

Yes. The vulnerable endpoint is an HTTP upload interface, and an unauthenticated remote attacker can send crafted PATCH requests using a malicious uploadId to attempt exploitation.

No explicit credentials are required if the /files/:uploadId tus upload endpoint is exposed publicly, as is common for file sharing services. The attacker only needs network access to the service.

Ensure that any path derived from HTTP input is fully decoded, normalized, and then validated against a fixed, non-executable base directory before use. Treat upload identifiers as opaque tokens and resolve them to server-side filenames instead of trusting client-supplied paths.

Adopt a consistent pattern for path handling that includes URL decoding, canonicalization, and base-directory checks as a standard utility function. Keep user-writable directories physically and logically separated from code and configuration, and enforce these constraints via code review checklists and static analysis rules.

Find out what's already
exploitable in your codebase.