/

CVE-2026-22860

Severity:

HIGH RISK

(7.5)

Directory Traversal / Path Traversal in Rack::Directory

CVE-2026-22860

Modified

Vulnerability type

Category:

Directory Traversal / Path Traversal

CWE:

CWE-22, CWE-548

Impact:

Unauthorized Directory Listing and Potential Information Exposure

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

Rack's Rack::Directory component contains a directory traversal flaw where path checks rely on simple string prefix matching of expanded paths.

Under certain crafted requests, such as those using .. segments, an attacker can cause directory listings outside the intended root directory, exposing files that should not be browsable.

Affected context

This vulnerability occurs in Ruby web applications that use Rack's Rack::Directory middleware or components for serving directory listings from a configured root.

It manifests when the code trusts a prefix-based string comparison on expanded paths to enforce the directory root, rather than performing robust canonicalization and containment checks.

The risk is present where web-exposed directory listings exist, and the filesystem contains sensitive or internal directories adjacent to or above the configured root path.

Exploit preconditions

  • Attack surface: HTTP endpoints that use Rack::Directory or similar directory listing functionality.
  • Required access: Ability to send crafted HTTP requests to the vulnerable endpoint (no prior authentication strictly required, depending on app configuration).
  • Trigger point: Requests containing traversal-like segments (e.g., /../root_example/) that cause the expanded filesystem path to start with the configured root string while logically escaping it.
  • Why exploitation is possible: The path validation logic relies on a string prefix check of the expanded path, which can be bypassed when the expanded path still starts with the root string but resolves to a location outside the intended root directory.

Why this happens

The underlying bug stems from insufficient path validation and canonicalization when determining whether a requested path is contained within a configured root directory.

Instead of performing a strict containment check on canonicalized paths (e.g., comparing normalized absolute paths and ensuring the requested path is a true descendant of the root), the implementation uses a simple string prefix match.

This pattern is characteristic of CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled path elements like .. enable traversal beyond an intended directory boundary.

Because directory listings are then rendered for the resolved path, the bug indirectly aligns with CWE-548: Exposure of Information Through Directory Listing, as it can reveal file and directory names outside the intended scope.

Potential impact

  • Attackers may browse and list directories that reside outside the configured root.
  • Sensitive files and directory names (logs, configuration fragments, temporary files, or internal scripts) could be exposed.
  • Information about server structure and deployment layout can be revealed, aiding further attacks.
  • In environments where additional misconfigurations exist, exposed paths may link to files that are accessible for download, increasing data leakage risk.

General mitigation guidance

Effective mitigation focuses on enforcing robust path containment and reducing exposure of directory listings:

  • Implement canonicalization of all filesystem paths derived from user input before access checks, ensuring normalization of . and .. segments and symbolic links where applicable.
  • Use a strict directory containment check that verifies the requested path is a true descendant of the configured root (e.g., by comparing normalized absolute paths, not just string prefixes).
  • Minimize or disable directory listing features in production environments, especially for paths that may neighbor sensitive directories or files.
  • Apply the principle of least privilege to filesystem permissions so that even if path checks fail, the web process has limited read access.
  • Treat any user-derived path components as untrusted and subject them to whitelisting, path component filtering, or mapping to known-safe directories rather than direct filesystem traversal.

How teams detect issues like this

Detection can be approached through code analysis, configuration review, and runtime testing:

  • Static analysis and code review:
  • Search for usages of Rack::Directory or similar directory listing middleware within the application stack.
  • Look for path validation logic that relies on simple string prefix checks or starts_with? comparisons instead of canonical path containment checks.
  • Flag any code that joins user-controlled path segments directly with filesystem paths without normalization or explicit validation.
  • Configuration and deployment review:
  • Identify endpoints that expose directory listings and examine which directories they map to and what sits adjacent or above these roots in the filesystem.
  • Dynamic and security testing:
  • Perform web security tests with traversal-like paths (e.g., segments using ..) targeting known directory listing endpoints to determine whether listing escapes the configured root.
  • Use automated web scanners or DAST tools configured to probe for path traversal and directory listing exposures.
  • Automated code review or SAST tools that understand Ruby and Rack can be configured with rules to highlight unsafe directory listing usage and weak path validation patterns.

Sources

SourceLink
github.comgithub.com/rack/rack/commit/75c5745c286637a8f049a33790c71237762069e7
github.comgithub.com/rack/rack/security/advisories/GHSA-mxw3-3hh2-x2mh
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-22860
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2440737
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-22860.json

Frequently asked

questions

Exploitability depends on whether the application exposes a Rack::Directory-backed endpoint and whether that endpoint is reachable from untrusted networks. In many cases, if directory listing is accessible over HTTP and not gated by authentication, the issue can be exploited by any external attacker who can send crafted requests.

Not necessarily. If the directory listing endpoint is public or semi-public, no authentication is required. However, in applications where directory listing endpoints are behind login or restricted to certain roles, an attacker would first need to satisfy those access controls before exploiting the traversal behavior.

The safest pattern is to ensure that all paths derived from HTTP requests are canonicalized and then validated using a strict containment check against the configured root directory, rather than relying on string prefix matches. In addition, disabling or restricting directory listing in production, where feasible, significantly reduces the attack surface.

Establish coding practices that treat all filesystem paths influenced by user input as untrusted, requiring normalization and explicit validation. Prefer tested framework utilities for secure path handling over custom string checks, enforce least-privilege filesystem permissions, and include path traversal checks as part of code review and automated security testing processes.

Find out what's already
exploitable in your codebase.