/

CVE-2026-33195

Severity:

CRITICAL RISK

(9.8)

Path Traversal in Rails Active Storage DiskService#path_for

CVE-2026-33195

Modified

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read/Write/Delete on Server Filesystem

Severity:

CRITICAL RISK

(9.8)

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 vulnerability in Rails Active Storage's DiskService#path_for allows filesystem paths derived from blob keys to escape the configured storage root directory.

If untrusted input is ever used as a blob key, an attacker could read, write, or delete arbitrary files on the server by crafting keys containing traversal sequences like ../.

Affected context

This issue affects Rails applications using Active Storage's Disk service where blob keys influence on-disk storage paths.

While blob keys are usually treated as trusted, any application code that derives keys from user-controlled input, external identifiers, or unvalidated parameters may unintentionally expose this vulnerability.

The risk is highest in environments where the web process has read or write access to sensitive files outside the Active Storage root, such as configuration files, credentials, logs, or source code.

Exploit preconditions

  • Attack surface: HTTP endpoints or background jobs that create, fetch, or manage Active Storage blobs using keys.
  • Required access: Ability to cause the application to use an attacker-controlled blob key (directly or indirectly) when resolving a disk path.
  • Trigger point: Invocation of DiskService#path_for with a blob key containing directory traversal sequences (e.g., ../, nested traversals, or absolute path tricks).
  • Why exploitation is possible: The path joining logic does not enforce that the final resolved path remains within the configured storage root, so crafted keys can escape the intended directory sandbox.

Why this happens

The underlying bug is a classic directory traversal flaw, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.

Active Storage's DiskService#path_for constructs filesystem paths by combining the storage root with the blob key but fails to normalize and validate the resulting path.

Without checks that the resolved path still resides under the storage root, an attacker-controlled key containing ../ or similar sequences can traverse up the directory tree and point to arbitrary locations.

Conceptually, this reflects an insecure pattern where trusted assumptions about identifier format (blob keys) are not enforced at the boundary where those identifiers are converted into filesystem paths.

Potential impact

  • Reading arbitrary files that the application process can access, potentially exposing secrets, configuration, or source code.
  • Overwriting or truncating existing files, including logs, configuration files, or application code.
  • Deleting arbitrary files, leading to data loss or denial of service.
  • Modifying files in ways that enable further compromise, such as altering scripts or configuration to gain code execution in some deployments.
  • Bypassing logical access controls by directly accessing stored files that should not be exposed through normal application paths.

General mitigation guidance

Mitigation centers on constraining how paths are derived and ensuring all filesystem access remains within a controlled root.

Helpful defensive patterns include:

  • Normalizing and resolving any constructed path, then verifying it is still inside the expected storage root before use (e.g., by comparing canonical paths).
  • Treating blob keys and similar identifiers as untrusted unless they are generated exclusively by the server and never influenced by user input.
  • Introducing a strict format or whitelist for blob keys (e.g., constrained character sets and fixed-length tokens) and rejecting values that do not conform.
  • Encapsulating all file operations behind a storage abstraction that enforces directory boundaries and performs validation centrally.
  • Applying least-privilege file permissions to the application process so that even if traversal is attempted, the impact on sensitive system files is limited.

How teams detect issues like this

Effective detection usually combines code-level review with automated checks:

  • Static analysis: Search for filesystem operations that combine a base directory with externally influenced values (such as blob keys) without normalization and boundary checks; tools can flag uses of File.join, Pathname#join, or similar APIs where inputs are not constrained.
  • Code review: Examine Active Storage customization points, factories, and any code that sets or manipulates blob keys, looking for direct use of user parameters or request data.
  • Runtime monitoring: Log and monitor unexpected access patterns, such as requests that result in paths containing ../, or attempts to access files outside known storage directories.
  • Security testing: Include directory traversal test cases in application security tests, fuzzing blob key handling and upload/download endpoints to ensure traversal sequences are rejected.

Sources

SourceLink
github.comgithub.com/rails/rails/commit/4933c1e3b8c1bb04925d60347be9f69270392f2c
github.comgithub.com/rails/rails/commit/9b06fbc0f504b8afe333f33d19548f3b85fbe655
github.comgithub.com/rails/rails/commit/a290c8a1ec189d793aa6d7f2570b6a763f675348
github.comgithub.com/rails/rails/releases/tag/v7.2.3.1
github.comgithub.com/rails/rails/releases/tag/v8.0.4.1
github.comgithub.com/rails/rails/releases/tag/v8.1.2.1
github.comgithub.com/rails/rails/security/advisories/GHSA-9xrj-h377-fr87
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-33195
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2450546
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-33195.json

Frequently asked

questions

Exploitability depends on whether an attacker can influence blob keys or related identifiers; in applications where keys are strictly server-generated and never derived from user input, practical risk is reduced, but any deviation from that pattern increases exposure.

An attacker typically needs the ability to submit or control values that the application uses as blob keys, which may be possible through file upload flows, API parameters, or custom integrations that map user data to keys.

The safest approach is to normalize the constructed path and enforce that it stays within the intended storage root, combined with strict constraints on blob key formats so that directory traversal sequences and absolute paths are never accepted.

Treat all path components derived from outside the storage layer as untrusted, centralize file access through a hardened abstraction that validates paths, and integrate static analysis and security review practices that specifically look for directory traversal patterns wherever filesystem APIs are used.

Find out what's already
exploitable in your codebase.