|
| 1 | +--- |
| 2 | +gem: unpoly-rails |
| 3 | +cve: 2023-28846 |
| 4 | +ghsa: m875-3xf6-mf78 |
| 5 | +url: https://github.com/unpoly/unpoly-rails/security/advisories/GHSA-m875-3xf6-mf78 |
| 6 | +title: unpoly-rails Denial of Service vulnerability |
| 7 | +date: 2023-03-30 |
| 8 | +description: | |
| 9 | + There is a possible Denial of Service (DoS) vulnerability in the unpoly-rails |
| 10 | + gem that implements the [Unpoly server protocol](https://unpoly.com/up.protocol) |
| 11 | + for Rails applications. |
| 12 | +
|
| 13 | + ### Impact |
| 14 | +
|
| 15 | + This issues affects Rails applications |
| 16 | + that operate as an upstream of a load balancer's that uses [passive health |
| 17 | + checks](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-health-check/#passive-health-checks). |
| 18 | +
|
| 19 | + The [unpoly-rails](https://github.com/unpoly/unpoly-rails/) gem echoes the request URL |
| 20 | + as an `X-Up-Location` response header. By making a request with exceedingly long |
| 21 | + URLs (paths or query string), an attacker can cause unpoly-rails to write a exceedingly |
| 22 | + large response header. |
| 23 | +
|
| 24 | + If the response header is too large to be parsed by a load balancer downstream |
| 25 | + of the Rails application, it may cause the load balancer to remove the upstream |
| 26 | + from a load balancing group. This causes that application instance to become |
| 27 | + unavailable until a configured timeout is reached or until an active healthcheck |
| 28 | + succeeds. |
| 29 | +
|
| 30 | + ### Workarounds |
| 31 | +
|
| 32 | + If you cannot upgrade to a fixed release, several workarounds are available: |
| 33 | +
|
| 34 | + - Configure your load balancer to |
| 35 | + use active health checks, e.g. by periodically requesting a route with a known response |
| 36 | + that indicates healthiness. |
| 37 | + - Configure your load balancer so the [maximum size |
| 38 | + of response headers](https://makandracards.com/operations/537537-nginx-proxy-buffer-tuning) |
| 39 | + is at least twice the [maximum size of a URL](https://tryhexadecimal.com/guides/http/414-request-uri-too-long). |
| 40 | + - Instead of changing your server configuration you may also configure your Rails |
| 41 | + application to delete redundant `X-Up-Location` headers set by unpoly-rails: |
| 42 | +
|
| 43 | + ```ruby |
| 44 | + class ApplicationController < ActionController::Base |
| 45 | +
|
| 46 | + after_action :remove_redundant_up_location_header |
| 47 | +
|
| 48 | + private |
| 49 | +
|
| 50 | + def remove_redundant_up_location_header |
| 51 | + if request.original_url == response.headers['X-Up-Location'] |
| 52 | + response.headers.delete('X-Up-Location') |
| 53 | + end |
| 54 | + end |
| 55 | +
|
| 56 | + end |
| 57 | + ``` |
| 58 | +cvss_v3: 5.9 |
| 59 | +patched_versions: |
| 60 | +- ">= 2.7.2.2" |
| 61 | +related: |
| 62 | + url: |
| 63 | + - https://github.com/unpoly/unpoly-rails/commit/cd9ad0007daceeb3b2354fdcab4f88350427bf16 |
| 64 | + - https://docs.nginx.com/nginx/admin-guide/load-balancer/http-health-check/#passive-health-checks |
| 65 | + - https://makandracards.com/operations/537537-nginx-proxy-buffer-tuning |
| 66 | + - https://tryhexadecimal.com/guides/http/414-request-uri-too-long |
| 67 | + - https://unpoly.com/up.protocol |
0 commit comments