|
| 1 | +--- |
| 2 | +gem: rack |
| 3 | +cve: 2025-61780 |
| 4 | +ghsa: r657-rxjc-j557 |
| 5 | +url: https://github.com/rack/rack/security/advisories/GHSA-r657-rxjc-j557 |
| 6 | +title: Rack has a Possible Information Disclosure Vulnerability |
| 7 | +date: 2025-10-10 |
| 8 | +description: | |
| 9 | + ## Summary |
| 10 | +
|
| 11 | + A possible information disclosure vulnerability existed in |
| 12 | + `Rack::Sendfile` when running behind a proxy that supports |
| 13 | + `x-sendfile` headers (such as Nginx). Specially crafted headers |
| 14 | + could cause `Rack::Sendfile` to miscommunicate with the proxy and |
| 15 | + trigger unintended internal requests, potentially bypassing |
| 16 | + proxy-level access restrictions. |
| 17 | +
|
| 18 | + ## Details |
| 19 | +
|
| 20 | + When `Rack::Sendfile` received untrusted `x-sendfile-type` or |
| 21 | + `x-accel-mapping` headers from a client, it would interpret them |
| 22 | + as proxy configuration directives. This could cause the middleware |
| 23 | + to send a "redirect" response to the proxy, prompting it to reissue |
| 24 | + a new internal request that was |
| 25 | + **not subject to the proxy's access controls**. |
| 26 | +
|
| 27 | + An attacker could exploit this by: |
| 28 | + 1. Setting a crafted `x-sendfile-type: x-accel-redirect` header. |
| 29 | + 2. Setting a crafted `x-accel-mapping` header. |
| 30 | + 3. Requesting a path that qualifies for proxy-based acceleration. |
| 31 | +
|
| 32 | + ## Impact |
| 33 | +
|
| 34 | + Attackers could bypass proxy-enforced restrictions and access internal |
| 35 | + endpoints intended to be protected (such as administrative pages). |
| 36 | + The vulnerability did not allow arbitrary file reads but could |
| 37 | + expose sensitive application routes. |
| 38 | +
|
| 39 | + This issue only affected systems meeting all of the following conditions: |
| 40 | +
|
| 41 | + * The application used `Rack::Sendfile` with a proxy that supports |
| 42 | + `x-accel-redirect` (e.g., Nginx). |
| 43 | + * The proxy did **not** always set or remove the `x-sendfile-type` |
| 44 | + and `x-accel-mapping` headers. |
| 45 | + * The application exposed an endpoint that returned a body |
| 46 | + responding to `.to_path`. |
| 47 | +
|
| 48 | + ## Mitigation |
| 49 | +
|
| 50 | + * Upgrade to a fixed version of Rack which requires explicit |
| 51 | + configuration to enable `x-accel-redirect`: |
| 52 | +
|
| 53 | + ```ruby |
| 54 | + use Rack::Sendfile, "x-accel-redirect" |
| 55 | + ``` |
| 56 | +
|
| 57 | + * Alternatively, configure the proxy to always set or strip |
| 58 | + the headers (you should be doing this!): |
| 59 | +
|
| 60 | + ```nginx |
| 61 | + proxy_set_header x-sendfile-type x-accel-redirect; |
| 62 | + proxy_set_header x-accel-mapping /var/www/=/files/; |
| 63 | + ``` |
| 64 | +
|
| 65 | + * Or in Rails applications, disable sendfile completely: |
| 66 | +
|
| 67 | + ```ruby |
| 68 | + config.action_dispatch.x_sendfile_header = nil |
| 69 | + ``` |
| 70 | +cvss_v3: 5.8 |
| 71 | +patched_versions: |
| 72 | + - "~> 2.2.20" |
| 73 | + - "~> 3.1.18" |
| 74 | + - ">= 3.2.3" |
| 75 | +related: |
| 76 | + url: |
| 77 | + - https://github.com/rack/rack/security/advisories/GHSA-r657-rxjc-j557 |
| 78 | + - https://github.com/rack/rack/commit/57277b7741581fa827472c5c666f6e6a33abd784 |
| 79 | + - https://github.com/rack/rack/commit/7e69f65eefe9cd2868df9f9f3b0977b86f93523a |
| 80 | + - https://github.com/rack/rack/commit/fba2c8bc63eb787ff4b19bc612d315fda6126d85 |
| 81 | + - https://github.com/advisories/GHSA-r657-rxjc-j557 |
0 commit comments