# GHSA-MHJ6-XC86-54M8: rack path traversal

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-11-20
- Modified: 2026-12-02

## Tracked as

- [CVE-2026-142593](https://cve.now/CVE-2026-142593.md): Rack is a modular Ruby web server interface

## Affected versions

- rack (RubyGems): fixed in 2.2.26
- rack (RubyGems): from 3.0, fixed in 3.1.24
- rack (RubyGems): from 3.2, fixed in 3.2.9

## Description

## Summary

`Rack::Directory#get` decides whether a request path containing `..` stays inside the root by expanding it lexically with `File.expand_path`, but then joins the original, unnormalized path onto the root and passes it to `File.stat` and `Dir.foreach`. The operating system resolves a symbolic link before applying a `..` that follows it, so when a directory under the root is a symlink, a request such as `/system/../` passes the check while the filesystem lists the parent of the link's target, and `/system/../config/` lists a sibling of the target. Both are outside the root. This results in disclosure of file and directory names, sizes and modification times outside the served tree.

## Details

The check and the filesystem access use different paths:

```ruby
def get(env)
  path_info = Utils.unescape_path(env[PATH_INFO])
  if client_error_response = check_bad_request(path_info) || check_forbidden(path_info)
    client_error_response
  else
    path = ::File.join(@root, path_info)         # unnormalized
    list_path(env, path, path_info, script_name) # File.stat, Dir.foreach
  end
end

def check_forbidden(path_info)
  return unless path_info.include? ".."
  expanded_path = ::File.expand_path(::File.join(@root, path_info))  # lexical
  return if expanded_path == @root || expanded_path.start_with?(@root_with_separator)
  # 403
end
```

With `public/system` linked to `shared/system`, `File.expand_path("public/system/../")` is `public`, so the request is allowed, but `Dir.foreach("public/system/../")` is evaluated by the kernel as `shared/system/..`, which is `shared`. The climb is bounded to one level above each symlink target, but any further symlink discovered in a listing can be used to climb again. Percent-encoded forms such as `%2E%2E` behave the same way. The `Rack::Files` application that `Rack::Directory` delegates to for files normalizes the path with `Utils.clean_path_info` before touching the filesystem, so file contents outside the root are not readable through this path; only directory listings leak.

`Rack::Directory` documents that it follows symbolic links, meaning that the link's target is served. This issue goes further: the target's parent and siblings become browsable.

All supported versions since 2.2.0 are affected. Earlier versions rejected every path containing `..`.

## Impact

Applications that mount `Rack::Directory`, directly or through `rackup` with a directory application, with any symbolic link to a directory under the root. The Capistrano convention of linking `public/system`, `public/uploads` or `public/assets` into a release-independent `shared/` directory is the common case, and `shared/` typically also holds `config/database.yml`, `config/master.key`, logs and PID files. An unauthenticated attacker obtains the names, sizes and modification times of those entries, and can walk further through any other symlinks found. No authentication, malformed HTTP, or large payload is required. File contents are not disclosed.

## Mitigation

* Update to a patched version of Rack, in which `Rack::Directory` normalizes the request path with `Utils.clean_path_info` before accessing the filesystem, as `Rack::Files` already does.
* Avoid symbolic links to directories under a root served by `Rack::Directory`, or avoid exposing `Rack::Directory` to untrusted clients.
* At a reverse proxy, reject request paths containing `..` or `%2E%2E` segments.

## References

- https://github.com/rack/rack/security/advisories/GHSA-mhj6-xc86-54m8

Page: https://cve.now/GHSA-MHJ6-XC86-54M8

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
