/

CVE-2025-61686

Severity:

CRITICAL RISK

(9.1)

Path Traversal in File-Based Session Storage for React

CVE-2025-61686

Modified

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read/Write via Session Storage Path Traversal (constrained by format and filesystem permissions)

Severity:

CRITICAL RISK

(9.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

A path traversal flaw in file-based session storage for @react-router/node and @remix-run/node/@remix-run/deno allows attacker-controlled session identifiers to influence where session files are read from and written to on disk.

When createFileSessionStorage() is used with unsigned cookies, a malicious client can steer session access outside the intended session directory, potentially interacting with arbitrary files depending on server filesystem permissions and application behavior.

Affected context

This vulnerability appears in environments where:

  • React Router's @react-router/node or Remix's @remix-run/node/@remix-run/deno is used
  • File-based session storage is configured via createFileSessionStorage()
  • Session identifiers are stored in unsigned cookies or otherwise not cryptographically protected
  • The server process has filesystem access beyond the dedicated session directory

In these circumstances, the session mechanism may construct file paths using untrusted cookie data without fully constraining them to the configured session storage directory.

Exploit preconditions

  • Attack surface: HTTP endpoints backed by React Router or Remix that rely on createFileSessionStorage() with unsigned cookies.
  • Required access: Ability to send crafted HTTP requests to the application and control or manipulate the session cookie value (no local shell or file system access required).
  • Trigger point: Any request that causes the session middleware to read or write a session (e.g., login flows, stateful endpoints, or any route that calls session functions).
  • Why exploitation is possible: The session implementation trusts cookie-derived identifiers when constructing filesystem paths and does not sufficiently normalize or constrain them to the configured session directory, enabling path traversal outside the intended storage location.

Why this happens

The underlying issue maps to CWE-22: Path Traversal, where user-controlled input influences filesystem paths in an unsafe manner.

In this case, createFileSessionStorage() uses untrusted cookie data as part of the session file naming/lookup logic. Without strong path normalization and directory confinement checks — and without a cryptographic signature to prevent tampering — an attacker can craft cookie values that traverse directories (e.g., via ../-style patterns or equivalent) so that the session layer attempts to read or write files outside the designated session directory. This is a design-level trust boundary violation in how file-based sessions are implemented and how identifiers are derived from client-controlled data.

Potential impact

  • Session subsystem may read arbitrary files accessible to the web server process if they can be referenced via traversed paths and match the expected session file structure.
  • Sensitive data from non-session files that coincidentally conform to the session format could be loaded into server-side session state and may be exposed indirectly if application logic echoes session contents.
  • Session subsystem may create or overwrite files outside the session directory, potentially leading to data corruption or influencing application behavior if critical files are located in reachable paths.
  • Elevation of impact when combined with other vulnerabilities or misconfigurations (e.g., writable directories used for configuration, state, or code artifacts).

General mitigation guidance

Effective mitigation focuses on constraining file paths and reducing trust in client-controlled session identifiers:

  • Prefer signed or encrypted cookies for session identifiers so clients cannot tamper with the underlying ID or path-related components.
  • Ensure the session file implementation normalizes and validates paths, explicitly restricting them to a dedicated session directory and rejecting any traversal sequences or absolute paths.
  • Use indirect, opaque session identifiers (e.g., random tokens) that are mapped to filenames by server-side logic, instead of using cookie values directly as or within filesystem paths.
  • Run the application under a least-privilege service account with filesystem permissions restricted strictly to the directories required for operation, especially the session directory.
  • Consider using non-filesystem-backed session storage (e.g., in-memory stores, databases, or managed session services) to avoid direct exposure of the underlying filesystem to client-influenced identifiers.

How teams detect issues like this

Detection typically combines code-level review with behavioral monitoring:

  • Static analysis / SAST:
  • Flag uses of createFileSessionStorage() where:
  • Cookies are configured as unsigned, or
  • User-controlled values are concatenated into file paths without normalization and directory constraints.
  • Detect filesystem calls where request- or cookie-derived values influence path construction.
  • Code review signals:
  • File-based session stores that derive file names directly or indirectly from cookie/session IDs without a mapping layer.
  • Lack of explicit checks ensuring generated paths resolve under the configured session directory.
  • Runtime and logging:
  • Log session file paths being accessed and alert on attempts to access locations outside the configured session directory.
  • Monitor for unusual session errors or file access patterns (e.g., attempts referencing ../ or unexpected directories).
  • Automated tooling:
  • Integrate security-focused linters or SAST tools into CI pipelines to enforce policies against unsanitized path construction and unsigned cookies for file-backed sessions.

Sources

SourceLink
github.comgithub.com/remix-run/react-router/security/advisories/GHSA-9583-h5hc-x8cw
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-61686
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2428423
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-61686.json

Frequently asked

questions

Yes. An attacker only needs network access to the vulnerable HTTP endpoints and the ability to control or modify the session cookie value; no local access to the server filesystem is required.

Not necessarily. If anonymous users receive session cookies (a common pattern), an unauthenticated attacker can manipulate those cookies. If sessions are only issued post-login, then access to a valid session cookie is required, but the attack still occurs over standard HTTP requests.

Use signed (or encrypted) cookies for session identifiers and ensure the session file implementation strictly confines all file operations to a dedicated session directory. Paths derived from identifiers should be normalized and validated so that traversal outside this directory is impossible, and identifiers themselves should be opaque tokens rather than user-controlled path fragments.

Treat all client-controlled data, including session IDs, as untrusted; avoid feeding such data directly into filesystem paths. Adopt a defense-in-depth strategy: use cryptographically protected cookies, enforce strict directory confinement for any file-backed storage, run services with minimal filesystem privileges, and include automated checks in your development workflow to catch path traversal patterns early.

Find out what's already
exploitable in your codebase.