Repository navigation
chore(deps): update dependency rack to '< 3.2' [security] - #646
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## staging #646 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 198 198
Lines 3027 3027
=========================================
Hits 3027 3027 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
renovate
Bot
force-pushed
the
renovate/rubygems-rack-vulnerability
branch
from
December 3, 2026 11:06
0c19b93 to
db4330c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
This PR body was truncated due to platform limits.
This PR contains the following updates:
'< 3.1'→'< 3.2'Rack has a Possible Information Disclosure Vulnerability
CVE-2025-61780 / GHSA-r657-rxjc-j557
More information
Details
Summary
A possible information disclosure vulnerability existed in
Rack::Sendfilewhen running behind a proxy that supportsx-sendfileheaders (such as Nginx). Specially crafted headers could causeRack::Sendfileto miscommunicate with the proxy and trigger unintended internal requests, potentially bypassing proxy-level access restrictions.Details
When
Rack::Sendfilereceived untrustedx-sendfile-typeorx-accel-mappingheaders from a client, it would interpret them as proxy configuration directives. This could cause the middleware to send a "redirect" response to the proxy, prompting it to reissue a new internal request that was not subject to the proxy's access controls.An attacker could exploit this by:
x-sendfile-type: x-accel-redirectheader.x-accel-mappingheader.Impact
Attackers could bypass proxy-enforced restrictions and access internal endpoints intended to be protected (such as administrative pages). The vulnerability did not allow arbitrary file reads but could expose sensitive application routes.
This issue only affected systems meeting all of the following conditions:
Rack::Sendfilewith a proxy that supportsx-accel-redirect(e.g., Nginx).x-sendfile-typeandx-accel-mappingheaders..to_path.Mitigation
Upgrade to a fixed version of Rack which requires explicit configuration to enable
x-accel-redirect:Alternatively, configure the proxy to always set or strip the headers (you should be doing this!):
Or in Rails applications, disable sendfile completely:
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack is vulnerable to a memory-exhaustion DoS through unbounded URL-encoded body parsing
CVE-2025-61919 / GHSA-6xw4-3v39-52mm
More information
Details
Summary
Rack::Request#POSTreads the entire request body into memory forContent-Type: application/x-www-form-urlencoded, callingrack.input.read(nil)without enforcing a length or cap. Large request bodies can therefore be buffered completely into process memory before parsing, leading to denial of service (DoS) through memory exhaustion.Details
When handling non-multipart form submissions, Rack’s request parser performs:
Since
readis called with no argument, the entire request body is loaded into a RubyString. This occurs before query parameter parsing or enforcement of anyparams_limit. As a result, Rack applications without an upstream body-size limit can experience unbounded memory allocation proportional to request size.Impact
Attackers can send large
application/x-www-form-urlencodedbodies to consume process memory, causing slowdowns or termination by the operating system (OOM). The effect scales linearly with request size and concurrency. Even with parsing limits configured, the issue occurs before those limits are enforced.Mitigation
query_parser.bytesize_limit, preventing unbounded reads ofapplication/x-www-form-urlencodedbodies.client_max_body_size, ApacheLimitRequestBody).Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack has a Directory Traversal via Rack:Directory
CVE-2026-22860 / GHSA-mxw3-3hh2-x2mh
More information
Details
Summary
Rack::Directory’s path check used a string prefix match on the expanded path. A request like/../root_example/can escape the configured root if the target path starts with the root string, allowing directory listing outside the intended root.Details
In
directory.rb,File.expand_path(File.join(root, path_info)).start_with?(root)does not enforce a path boundary. If the server root is/var/www/root, a path like/var/www/root_backuppasses the check because it shares the same prefix, soRack::Directorywill list that directory also.Impact
Information disclosure via directory listing outside the configured root when
Rack::Directoryis exposed to untrusted clients and a directory shares the root prefix (e.g.,public2,www_backup).Mitigation
Rack::Directory.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Stored XSS in Rack::Directory via javascript: filenames rendered into anchor href
CVE-2026-25500 / GHSA-whrj-4476-wvmp
More information
Details
Summary
Rack::Directorygenerates an HTML directory index where each file entry is rendered as a clickable link. If a file exists on disk whose basename begins with thejavascript:scheme (e.g.javascript:alert(1)), the generated index includes an anchor whosehrefattribute is exactlyjavascript:alert(1). Clicking this entry executes arbitrary JavaScript in the context of the hosting application.This results in a client-side XSS condition in directory listings generated by
Rack::Directory.Details
Rack::Directoryrenders directory entries using an HTML row template similar to:The
%splaceholder is populated directly with the file’s basename. If the basename begins withjavascript:, the resulting HTML contains an executable JavaScript URL:Because the value is inserted directly into the
hrefattribute without scheme validation or normalization, browsers interpret it as a JavaScript URI. When a user clicks the link, the JavaScript executes in the origin of the Rack application.Impact
If
Rack::Directoryis used to expose filesystem contents over HTTP, an attacker who can create or upload files within that directory may introduce a malicious filename beginning withjavascript:.When a user visits the directory listing and clicks the entry, arbitrary JavaScript executes in the application's origin. Exploitation requires user interaction (clicking the malicious entry).
Mitigation
Rack::Directoryprefixes generated anchors with a relative path indicator (e.g../filename).Rack::Directory.HackerOne profile:
https://hackerone.com/thesmartshadow
GitHub account owner:
Ali Firas (@thesmartshadow)
Severity
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack:: Static header_rules bypass via URL-encoded paths
CVE-2026-34786 / GHSA-q4qf-9j86-f5mh
More information
Details
Summary
Rack::Static#applicable_rulesevaluates severalheader_rulestypes against the raw URL-encodedPATH_INFO, while the underlying file-serving path is decoded before the file is served. As a result, a request for a URL-encoded variant of a static path can serve the same file without the headers thatheader_ruleswere intended to apply.In deployments that rely on
Rack::Staticto attach security-relevant response headers to static content, this can allow an attacker to bypass those headers by requesting an encoded form of the path.Details
Rack::Static#applicable_rulesmatches rule types such as:fonts,Array, andRegexpdirectly against the incomingPATH_INFO. For example:These checks operate on the raw request path. If the request contains encoded characters such as
%2Ein place of., the rule may fail to match even though the file path is later decoded and served successfully by the static file server.For example, both of the following requests may resolve to the same file on disk:
but only the unencoded form may receive the headers configured through
header_rules.This creates a canonicalization mismatch between the path used for header policy decisions and the path ultimately used for file serving.
Impact
Applications that rely on
Rack::Staticheader_rulesto apply security-relevant headers to static files may be affected.In affected deployments, an attacker can request an encoded variant of a static file path and receive the same file without the intended headers. Depending on how
header_rulesare used, this may bypass protections such as clickjacking defenses, content restrictions, or other response policies applied to static content.The practical impact depends on the configured rules and the types of files being served. If
header_rulesare only used for non-security purposes such as caching, the issue may have limited security significance.Mitigation
header_rulesto a decoded path consistently with static file resolution.Rack::Staticheader_rulesfor security-critical headers where encoded path variants may reach the application.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack::Static prefix matching can expose unintended files under the static root
CVE-2026-34785 / GHSA-h2jq-g4cq-5ppq
More information
Details
Summary
Rack::Staticdetermines whether a request should be served as a static file using a simple string prefix check. When configured with URL prefixes such as"/css", it matches any request path that begins with that string, including unrelated paths such as"/css-config.env"or"/css-backup.sql".As a result, files under the static root whose names merely share the configured prefix may be served unintentionally, leading to information disclosure.
Details
Rack::Static#route_fileperforms static-route matching using logic equivalent to:This checks only whether the request path starts with the configured prefix string. It does not require a path segment boundary after the prefix.
For example, with:
the following path is matched as intended:
but these paths are also matched:
If such files exist under the configured static root, Rack forwards the request to the file server and serves them as static content.
This means a configuration intended to expose only directory trees such as
/css/...and/js/...may also expose sibling files whose names begin with those same strings.Impact
An attacker can request files under the configured static root whose names share a configured URL prefix and obtain their contents.
In affected deployments, this may expose configuration files, secrets, backups, environment files, or other unintended static content located under the same root directory.
Mitigation
prefix + "/".Rack::Staticroot directory.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack's multipart byte range processing allows denial of service via excessive overlapping ranges
CVE-2026-34826 / GHSA-x8cg-fq8g-mxfx
More information
Details
Summary
Rack::Utils.get_byte_rangesparses the HTTPRangeheader without limiting the number of individual byte ranges. Although the existing fix for CVE-2024-26141 rejects ranges whose total byte coverage exceeds the file size, it does not restrict the count of ranges. An attacker can supply many small overlapping ranges such as0-0,0-0,0-0,...to trigger disproportionate CPU, memory, I/O, and bandwidth consumption per request.This results in a denial of service condition in Rack file-serving paths that process multipart byte range responses.
Details
Rack::Utils.get_byte_rangesaccepts a comma-separated list of byte ranges and validates them based on their aggregate size, but does not impose a limit on how many individual ranges may be supplied.As a result, a request such as:
Range: bytes=0-0,0-0,0-0,0-0,...can contain thousands of overlapping one-byte ranges while still satisfying the total-size check added for CVE-2024-26141.
When such a header is processed by Rack’s file-serving code, each range causes additional work, including multipart response generation, per-range iteration, file seek and read operations, and temporary string allocation for response size calculation and output. This allows a relatively small request header to trigger disproportionately expensive processing and a much larger multipart response.
The issue is distinct from CVE-2024-26141. That fix prevents range sets whose total byte coverage exceeds the file size, but does not prevent a large number of overlapping ranges whose summed size remains within that limit.
Impact
Applications that expose file-serving paths with byte range support may be vulnerable to denial of service.
An unauthenticated attacker can send crafted
Rangeheaders containing many small overlapping ranges to consume excessive CPU time, memory, file I/O, and bandwidth. Repeated requests may reduce application availability and increase pressure on workers and garbage collection.Mitigation
Rangeheaders.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack's multipart header parsing allows Denial of Service via escape-heavy quoted parameters
CVE-2026-34827 / GHSA-v6x5-cg8r-vv6x
More information
Details
Summary
Rack::Multipart::Parser#handle_mime_headparses quoted multipart parameters such asContent-Disposition: form-data; name="..."using repeatedString#indexsearches combined withString#slice!prefix deletion. For escape-heavy quoted values, this causes super-linear processing.An unauthenticated attacker can send a crafted
multipart/form-datarequest containing many parts with long backslash-escaped parameter values to trigger excessive CPU usage during multipart parsing.This results in a denial of service condition in Rack applications that accept multipart form data.
Details
Rack::Multipart::Parser#handle_mime_headparses quoted parameter values by repeatedly:slice!.An attacker can exploit this by sending a multipart request with many parts whose
nameparameters contain long escape-heavy values such as:Under default Rack limits, a request can contain up to 4095 parts. If many of those parts use long quoted values with dense escape characters, the parser performs disproportionately expensive CPU work while remaining within normal request size and part-count limits.
Impact
Any Rack application that accepts
multipart/form-datarequests may be affected, including file upload endpoints and standard HTML form handlers.An unauthenticated attacker can send crafted multipart requests that consume excessive CPU time during request parsing. Repeated requests can tie up application workers, reduce throughput, and degrade or deny service availability.
Mitigation
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack's greedy multipart boundary parsing can cause parser differentials and WAF bypass.
CVE-2026-26961 / GHSA-vgpv-f759-9wx3
More information
Details
Summary
Rack::Multipart::Parserextracts theboundaryparameter frommultipart/form-datausing a greedy regular expression. When aContent-Typeheader contains multipleboundaryparameters, Rack selects the last one rather than the first.In deployments where an upstream proxy, WAF, or intermediary interprets the first
boundaryparameter, this mismatch can allow an attacker to smuggle multipart content past upstream inspection and have Rack parse a different body structure than the intermediary validated.Details
Rack identifies the multipart boundary using logic equivalent to:
Because the expression is greedy, it matches the last
boundary=parameter in a header such as:Content-Type: multipart/form-data; boundary=safe; boundary=maliciousAs a result, Rack parses the request body using
malicious, while another component may interpret the same header usingsafe.This creates an interpretation conflict. If an upstream WAF or proxy inspects multipart parts using the first boundary and Rack later parses the body using the last boundary, a client may be able to place malicious form fields or uploaded content in parts that Rack accepts but the upstream component did not inspect as intended.
This issue is most relevant in layered deployments where security decisions are made before the request reaches Rack.
Impact
Applications that accept
multipart/form-datauploads behind an inspecting proxy or WAF may be affected.In such deployments, an attacker may be able to bypass upstream filtering of uploaded files or form fields by sending a request with multiple
boundaryparameters and relying on the intermediary and Rack to parse the request differently.The practical impact depends on deployment architecture. If no upstream component relies on a different multipart interpretation, this behavior may not provide meaningful additional attacker capability.
Mitigation
Content-Typeheaders or parses duplicateboundaryparameters consistently.boundaryparameters.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack: Forwarded Header semicolon injection enables Host and Scheme spoofing
CVE-2026-32762 / GHSA-qfgr-crr9-7r49
More information
Details
Summary
Rack::Utils.forwarded_valuesparses the RFC 7239Forwardedheader by splitting on semicolons before handling quoted-string values. Because quoted values may legally contain semicolons, a header such as:Forwarded: for="127.0.0.1;host=evil.com;proto=https"can be interpreted by Rack as multiple
Forwardeddirectives rather than as a single quotedforvalue.In deployments where an upstream proxy, WAF, or intermediary validates or preserves quoted
Forwardedvalues differently, this discrepancy can allow an attacker to smugglehost,proto,for, orbyparameters through a single header value.Details
Rack::Utils.forwarded_valuesprocesses the header using logic equivalent to:The method splits on
;before it parses individualname=valuepairs. This is inconsistent with RFC 7239, which permits quoted-string values, and quoted strings may contain semicolons as literal content.As a result, a header value such as:
Forwarded: for="127.0.0.1;host=evil.com;proto=https"is not treated as a single
forvalue. Instead, Rack may interpret it as if the client had supplied separatefor,host, andprotodirectives.This creates an interpretation conflict when another component in front of Rack treats the quoted value as valid literal content, while Rack reparses it as multiple forwarding parameters.
Impact
Applications that rely on
Forwardedto derive request metadata may observe attacker-controlled values forhost,proto,for, or related URL components.In affected deployments, this can lead to host or scheme spoofing in derived values such as
req.host,req.scheme,req.base_url, orreq.url. Applications that use those values for password reset links, redirects, absolute URL generation, logging, IP-based decisions, or backend requests may be vulnerable to downstream security impact.The practical security impact depends on deployment architecture. If clients can already supply arbitrary trusted
Forwardedparameters directly, this bug may not add meaningful attacker capability. The issue is most relevant where an upstream component and Rack interpret the sameForwardedheader differently.Mitigation
Forwardedquoted-string values before splitting on parameter delimiters.Forwardedheaders unless they are normalized or regenerated by a trusted reverse proxy.Forwardedheaders at the edge and reconstructing them from trusted proxy metadata.req.host,req.scheme,req.base_url, orreq.urlfor security-sensitive operations unless the forwarding chain is explicitly trusted and validated.Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack has quadratic complexity in Rack::Utils.select_best_encoding via wildcard Accept-Encoding header
CVE-2026-34230 / GHSA-v569-hp3g-36wr
More information
Details
Summary
Rack::Utils.select_best_encodingprocessesAccept-Encodingvalues with quadratic time complexity when the header contains many wildcard (*) entries. Because this method is used byRack::Deflaterto choose a response encoding, an unauthenticated attacker can send a single request with a craftedAccept-Encodingheader and cause disproportionate CPU consumption on the compression middleware path.This results in a denial of service condition for applications using
Rack::Deflater.Details
Rack::Utils.select_best_encodingexpands parsedAccept-Encodingvalues into a list of candidate encodings. When an entry is*, the method computes the set of concrete encodings by subtracting the encodings already present in the request:Because
accept_encoding.map(&:first)is evaluated inside the loop, it is recomputed for each wildcard entry. If the request containsNwildcard entries, this produces repeated scans over the full parsed header and causes quadratic behavior.After expansion, the method also performs additional work over
expanded_accept_encoding, including per-entry deletion, which further increases the cost for large inputs.Rack::Deflaterinvokes this method for each request when the middleware is enabled:As a result, a client can trigger this expensive code path simply by sending a large
Accept-Encodingheader containing many repeated wildcard values.For example, a request with an approximately 8 KB
Accept-Encodingheader containing about 1,000*;q=0.5entries can cause roughly 170 ms of CPU time in a single request on theRack::Deflaterpath, compared to a negligible baseline for a normal header.This issue is distinct from CVE-2024-26146. That issue concerned regular expression denial of service during
Acceptheader parsing, whereas this issue arises later during encoding selection after the header has already been parsed.Impact
Any Rack application using
Rack::Deflatermay be affected.An unauthenticated attacker can send requests with crafted
Accept-Encodingheaders to trigger excessive CPU usage in the encoding selection logic. Repeated requests can consume worker time disproportionately and reduce application availability.The attack does not require invalid HTTP syntax or large payload bodies. A single header-sized request is sufficient to reach the vulnerable code path.
Mitigation
Rack::Deflateron untrusted traffic.Accept-Encodingvalues.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack has a root directory disclosure via unescaped regex interpolation in Rack::Directory
CVE-2026-34763 / GHSA-7mqq-6cf9-v2qp
More information
Details
Summary
Rack::Directoryinterpolates the configuredrootpath directly into a regular expression when deriving the displayed directory path. Ifrootcontains regex metacharacters such as+,*, or., the prefix stripping can fail and the generated directory listing may expose the full filesystem path in the HTML output.Details
Rack::Directory::DirectoryBody#eachcomputes the visible path using code equivalent to:Here,
rootis a developer-configured filesystem path. It is normalized earlier withFile.expand_path(root)and then inserted directly into a regular expression without escaping.Because the value is treated as regex syntax rather than as a literal string, metacharacters in the configured path can change how the prefix match behaves. When that happens, the expected root prefix is not removed from
path, and the absolute filesystem path is rendered into the HTML directory listing.Impact
If
Rack::Directoryis configured to serve a directory whose absolute path contains regex metacharacters, the generated directory listing may disclose the full server filesystem path instead of only the request-relative path.This can expose internal deployment details such as directory layout, usernames, mount points, or naming conventions that would otherwise not be visible to clients.
Mitigation
Rack::Directorywith a root path that contains regular expression metacharacters.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack's multipart parsing without Content-Length header allows unbounded chunked file uploads
CVE-2026-34829 / GHSA-8vqr-qjwx-82mw
More information
Details
Summary
Rack::Multipart::Parseronly wraps the request body in aBoundedIOwhenCONTENT_LENGTHis present. When amultipart/form-datarequest is sent without aContent-Lengthheader, such as with HTTP chunked transfer encoding, multipart parsing continues until end-of-stream with no total size limit.For file parts, the uploaded body is written directly to a temporary file on disk rather than being constrained by the buffered in-memory upload limit. An unauthenticated attacker can therefore stream an arbitrarily large multipart file upload and consume unbounded disk space.
This results in a denial of service condition for Rack applications that accept multipart form data.
Details
Rack::Multipart::Parser.parseappliesBoundedIOonly whencontent_lengthis notnil:When
CONTENT_LENGTHis absent, the parser reads the multipart body until EOF without a global byte limit.Although Rack enforces
BUFFERED_UPLOAD_BYTESIZE_LIMITfor retained non-file parts, file uploads are handled differently. When a multipart part includes a filename, the body is streamed to aTempfile, and the retained-size accounting is not applied to that file content. As a result, file parts are not subject to the same upload size bound.An attacker can exploit this by sending a chunked
multipart/form-datarequest containing a file part and continuously streaming data without declaring aContent-Length. Rack will continue writing the uploaded data to disk until the client stops or the server exhausts available storage.Impact
Any Rack application that accepts
multipart/form-datauploads may be affected if no upstream component enforces a request body size limit.An unauthenticated attacker can send a large chunked file upload to consume disk space on the application host. This may cause request failures, application instability, or broader service disruption if the host runs out of available storage.
The practical impact depends on deployment architecture. Reverse proxies or application servers that enforce upload limits may reduce or eliminate exploitability, but Rack itself does not impose a total multipart upload limit in this code path when
CONTENT_LENGTHis absent.Mitigation
CONTENT_LENGTHis absent.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:HReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Rack::Sendfile header-based X-Accel-Mapping regex injection enables unauthorized X-Accel-Redirect
CVE-2026-34830 / GHSA-qv7j-4883-hwh7
More information
Details
Summary
Rack::Sendfile#map_accel_pathinterpolates the value of theX-Accel-Mappingrequest header directly into a regular expression when rewriting file paths forX-Accel-Redirect. Because the header value is not escaped, an attacker who can supplyX-Accel-Mappingto the backend can inject regex metacharacters and control the generatedX-Accel-Redirectresponse header.In deployments using
Rack::Sendfilewithx-accel-redirect, this can allow an attacker to cause nginx to serve unintended files from configured internal locations.Details
Rack::Sendfile#map_accel_pathprocesses header-supplied mappings using logic equivalent to:Here,
internalcomes from theHTTP_X_ACCEL_MAPPINGrequest header and is inserted directly into a regular expression without escaping. This gives the header value regex semantics rather than treating it as a literal prefix.As a result, an attacker can supply metacharacters such as
.*or capture groups to alter how the path substitution is performed. For example, a mapping such as:X-Accel-Mapping: .*=/protected/secret.txtcauses the entire source path to match and rewrites the redirect target to a clean attacker-chosen internal path.
This differs from the documented behavior of the header-based mapping path, which is described as a simple substitution. While application-supplied mappings may intentionally support regular expressions, header-supplied mappings should be treated as literal path prefixes.
The issue is only exploitable when untrusted
X-Accel-Mappingheaders can reach Rack. One realistic case is a reverse proxy configuration that intends to setX-Accel-Mappingitself, but fails to do so on some routes, allowing a client-supplied header to pass through unchanged.Impact
Applications using
Rack::Sendfilewithx-accel-redirectmay be affected if the backend accepts attacker-controlledX-Accel-Mappingheaders.In affected deployments, an attacker may be able to control the
X-Accel-Redirectresponse header and cause nginx to serve files from internal locations that were not intended to be reachable through the application. This can lead to unauthorized file disclosure.The practical impact depends on deployment architecture. If the proxy always strips or overwrites
X-Accel-Mapping, or if the application uses explicit configured mappings instead of the request header, exploitability may be eliminated.Mitigation
X-Accel-Mappingvalues as literal strings rather than regular expressions.X-Accel-Mappingheaders at the reverse proxy so client-supplied values never reach Rack.X-Accel-Mappingis consistently set on all backend routes.Severity
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:NReferences