rack-proxy 0.7.7 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 888784aa8d1d28ae0dc2a1352aa44ba8e639d5cd604043facbb31da3fa1dc759
4
- data.tar.gz: 9ba49effcffcacb930ab08fe2f6a9fd08040b60800b8aa8e5ccc274053f36c4e
3
+ metadata.gz: 0b7446fb448e8e91e1fbc8a052fc170901649bcb3df26fbabf7741ca5b331449
4
+ data.tar.gz: c87d52a7ebe5e144e9254e84ebae969f3b8f4fed74c79483ce89ae9075e2b547
5
5
  SHA512:
6
- metadata.gz: 606ed720fb5b8c67cd1fc3058b9644e88fb2e7768d4fce4606ba0332fac24cadca11a36ab50d97cb7ff5767664864b1c1a2cf5108cd58a66fecfb3b93de37517
7
- data.tar.gz: a91cc8541d7af6c390fe1c0faa3c923942a14cce746eebc3d170b95b45aafc5871a04ad1ec9fee6f0c07500534755c794f76d0c14bccdcf5fdaad06e239aeb07
6
+ metadata.gz: 1b0cbe8b0bb1e23edba280b7be30259fb347f51f4c415b1f33b3052fafbd9ceeb886ee3b60a1ac2bedd4bee98730693e77ada746894dd427ed967d1aa62bae8f
7
+ data.tar.gz: ff6513f7e571fc101ace25a01fc81e14251e23b5fc6c11b44089c754384b0462d620f95b38324cfe9e888fd86390fd85beb3a416f85644cf5cc5f08d0011c292
data/CHANGELOG.md ADDED
@@ -0,0 +1,249 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project aims to
5
+ follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ Nothing yet.
10
+
11
+ ## [2.0.0] - 2026-09-05
12
+
13
+ ### Breaking changes
14
+
15
+ - Non-streaming requests no longer automatically retry transport failures.
16
+ This prevents replay with consumed request input; applications that require
17
+ retries must implement them with a fresh body and an explicit retry policy.
18
+ - Rack 3 response hooks receive arrays for repeated header values, including
19
+ `Set-Cookie`, and non-streaming statuses are integers. Update hooks that
20
+ assumed newline-separated headers or string statuses. Rack 2 retains its
21
+ newline-separated header representation.
22
+ - Invalid or ambiguous HTTP framing is now rejected, incomplete responses fail,
23
+ and uploads without a known length use fresh chunked framing. Backends must
24
+ accept properly framed HTTP/1.1 requests and send valid, complete responses.
25
+
26
+ ### Security
27
+
28
+ - Reframe decoded request bodies without a `CONTENT_LENGTH` using chunked
29
+ encoding instead of sending body bytes after `Content-Length: 0`. Bound
30
+ known-length input streams so excess bytes cannot become another backend
31
+ request; malformed lengths and prematurely ended uploads return `400`.
32
+ - Reject ambiguous backend framing (`Transfer-Encoding` with `Content-Length`,
33
+ conflicting or invalid lengths, and unsupported transfer codings) with `502`.
34
+ - Strip response headers named by the backend's `Connection` fields as well as
35
+ the standard hop-by-hop headers.
36
+ - Enforce `max_response_length` before buffering each chunk in non-streaming
37
+ mode, including rejecting declared oversized responses before reading them.
38
+ - Detect premature EOF in fixed-length responses: return `502` before sending
39
+ headers, or raise while streaming so the server aborts the incomplete transfer.
40
+ - Disable Net::HTTP transport retries in non-streaming mode as well as streaming
41
+ mode, preventing replay with an already-consumed request body.
42
+
43
+ ### Fixed
44
+
45
+ - Return integer statuses in non-streaming mode and preserve multiple response
46
+ header values as arrays on Rack 3 (including `Set-Cookie`). Rack 2 keeps its
47
+ newline-separated representation.
48
+ - Remove entity headers forbidden by Rack on 1xx/204/304 responses. HEAD and
49
+ 304 representation sizes no longer incorrectly trigger the response body cap.
50
+ - Replace a remaining live-host test with a local fixture and simulate failed
51
+ DNS resolution without sending external DNS queries. Add offline adversarial
52
+ framing, size-limit, retry, and `Rack::Lint` regression checks.
53
+
54
+ ## [1.0.2] - 2026-09-01
55
+
56
+ Housekeeping — no library behavior changes. **No action is needed by users:**
57
+ the shipped gem does not depend on `json` and was never affected by the
58
+ advisory below.
59
+
60
+ ### Security
61
+
62
+ - Development dependency `json` bumped 2.21.1 → 2.21.2 to clear
63
+ CVE-2026-71847 / GHSA-9hj4-r449-hfvc (`JSON::ResumableParser#partial_value`
64
+ dereferences a freed input buffer on truncated duplicate-key streams).
65
+ `json` reaches this repo only transitively (`standard` → `rubocop` → `json`)
66
+ and lives solely in the development `Gemfile.lock`; the bump keeps the CI
67
+ `bundler-audit` gate green.
68
+
69
+ ### Changed
70
+
71
+ - Release workflow: the laggy rubygems full-index await was replaced with a
72
+ versions-API check, so a successful publish no longer fails the run. (#142)
73
+
74
+ ## [1.0.1] - 2026-07-23
75
+
76
+ Docs and housekeeping — no library behavior changes.
77
+
78
+ ### Changed
79
+
80
+ - README modernized: badges, quick start, a "How it works" pipeline overview,
81
+ grouped options, and tightened recipes.
82
+ - Removed the internal modernization roadmap document, completed by 1.0.0.
83
+ - Development dependencies refreshed (rake 13.4.2, test-unit 3.7.8,
84
+ rack-test 2.2.0) and CI bumped to `actions/checkout@v7`. (#136–#139)
85
+
86
+ ## [1.0.0] - 2026-07-18
87
+
88
+ The 2026 modernization + security-hardening release. From 1.0.0 on this
89
+ project follows SemVer strictly: breaking changes only in majors.
90
+
91
+ ### Breaking changes
92
+
93
+ Read this list before upgrading from 0.8.x; everything else below is additive
94
+ or a compatible fix. See the README's "Upgrading" section for migration steps.
95
+
96
+ - **Host-derived (dynamic) backends are refused by default.** With no
97
+ `:backend` and no `env["rack.backend"]`, requests now get `502` unless you
98
+ pass `allow_dynamic_backend: true`. A bare `Rack::Proxy.new` is no longer an
99
+ open proxy. Combine the opt-in with a `backend_allowed?` allowlist.
100
+ - **`net_http_hacked` is gone** — the file, `require "net_http_hacked"`, and
101
+ the `begin_request_hacked`/`end_request_hacked` methods (see Removed).
102
+ - **The bundled examples left the gem** — `require "rack_proxy_examples/..."`
103
+ raises `LoadError`; copy the snippets from `examples/` instead (see Removed).
104
+ - **Backend failures no longer raise.** `OpenSSL::SSL::SSLError`, `EOFError`,
105
+ timeouts, resets, and malformed backend responses now become a `502` triplet
106
+ instead of an exception — `rescue`-based error handling around `proxy.call`
107
+ must inspect the status instead.
108
+ - **Hop-by-hop request headers are no longer forwarded** (`Connection`, `TE`,
109
+ `Transfer-Encoding`, `Proxy-Authorization`, `Upgrade`, anything named by
110
+ `Connection`).
111
+ - **gzip backend bodies are forwarded verbatim in `streaming: false` mode**
112
+ (previously they were transparently inflated); `rewrite_response` hooks that
113
+ read body text must inflate it themselves.
114
+ - **Supported runtimes: Ruby >= 3.0 and Rack >= 2.0, < 4** (was Ruby >= 2.6,
115
+ rack unpinned).
116
+ - Smaller wire/API changes: body-less POST/PUT sends `Content-Length: 0` on
117
+ the streaming path; the streaming body is thread-affine (iterate it on the
118
+ thread that called the app, as mainstream servers do); `HttpStreamingResponse`
119
+ raises `IOError` on use-after-close; early termination closes the backend
120
+ connection instead of draining it.
121
+
122
+ ### Security
123
+
124
+ - Refuse Host-derived backends unless `allow_dynamic_backend: true` is set
125
+ (see Breaking changes) — closes the default open-proxy/SSRF pivot.
126
+ - Strip hop-by-hop headers from the **forwarded request** (Connection, TE,
127
+ Transfer-Encoding, Proxy-Authorization, …, plus any header named by the inbound
128
+ `Connection` header), closing a Content-Length/Transfer-Encoding request-smuggling
129
+ surface. Hop-by-hop headers were previously stripped only from the response.
130
+ - Add `backend_allowed?(backend)` — an overridable per-request allowlist hook,
131
+ consulted for every request (static backends included). A refused backend
132
+ responds `502`.
133
+ - Add `:max_response_length` to cap the backend response size (bounds memory
134
+ against a hostile/huge backend). Enforced incrementally while streaming.
135
+ - Add `:ca_file` / `:cert_store` so private-CA backends can be verified under the
136
+ default `VERIFY_PEER` instead of disabling verification.
137
+ - Add `:open_timeout` / `:write_timeout` to bound connect and per-write stalls
138
+ (previously only `:read_timeout` was configurable).
139
+
140
+ ### Added
141
+
142
+ - `:min_version` / `:max_version` TLS options (mapping to `Net::HTTP#min_version=`
143
+ / `#max_version=`). `:ssl_version` still works but is deprecated (it pins an
144
+ exact protocol and forbids TLS 1.3).
145
+ - `HttpStreamingResponse#close` so Rack servers release the backend connection on
146
+ early termination (HEAD, 304, client disconnect) instead of leaking it until GC.
147
+ - Opt-in request hardening: `strip_credentials: true` drops the client's
148
+ `Cookie`/`Authorization` headers from the forwarded request, and
149
+ `replace_x_forwarded_for: true` forwards only this hop's `REMOTE_ADDR`
150
+ instead of appending to the client-supplied `X-Forwarded-For` chain.
151
+ - Project scaffolding: `SECURITY.md`, `CHANGELOG.md`, `CONTRIBUTING.md`,
152
+ `CLAUDE.md`/`AGENTS.md`, GitHub Actions CI (Ruby 3.1–3.4 × Rack 2/3),
153
+ Dependabot, issue/PR templates, SimpleCov with a ratcheted coverage floor
154
+ (`COVERAGE=1`), and Standard (`standardrb`) + `bundler-audit` enforced by a
155
+ CI lint job.
156
+
157
+ ### Changed
158
+
159
+ - **The streaming path no longer monkey-patches `net/http`.**
160
+ `Rack::HttpStreamingResponse` now runs the public block form of
161
+ `Net::HTTP#request` inside a Fiber (pausing at the response head, resuming
162
+ per body chunk), replacing the 2010-era patch of private `net/http` internals
163
+ in `net_http_hacked.rb`. Behavioral notes: the streaming session sets
164
+ `max_retries = 0` so a transport error can never silently replay the request
165
+ mid-stream; early termination (client abort, HEAD, 204/304) now closes
166
+ the backend connection immediately instead of draining the remaining body;
167
+ and a body-less POST/PUT/PATCH on the streaming path now carries
168
+ `Content-Length: 0` (matching the non-streaming path and plain `Net::HTTP` —
169
+ the old patched path sent no `Content-Length` at all).
170
+ - Backend and construction failures now map to status codes instead of raising a
171
+ `500`: `400` (malformed request URI), `501` (unknown HTTP method), `502`
172
+ (broadened backend-error set incl. `ECONNRESET`, `EPIPE`, read/write timeouts,
173
+ `EOFError`, `OpenSSL::SSL::SSLError`, protocol errors, and malformed backend
174
+ responses — `Net::HTTPBadResponse` / `Net::HTTPHeaderSyntaxError`).
175
+ - gzip-encoded backend responses are forwarded verbatim (Content-Encoding and
176
+ Content-Length preserved) instead of being transparently inflated.
177
+ - Skip all `1xx` interim responses (including `103 Early Hints`) on the streaming
178
+ path, so a backend's `103` is no longer mistaken for the final response.
179
+ - `rack` dependency constrained to `>= 2.0, < 4`; the library now `require`s rack
180
+ itself.
181
+ - Test suite is fully offline (local WEBrick server); the previous live-host
182
+ tests are gated behind `LIVE=1`.
183
+
184
+ ### Deprecated
185
+
186
+ - `:ssl_version` — use `:min_version` / `:max_version`.
187
+
188
+ ### Removed
189
+
190
+ - `lib/net_http_hacked.rb` — the 2010-era monkey-patch of private `Net::HTTP`
191
+ internals. The library stopped using it when streaming moved to the public
192
+ `Net::HTTP` API (see Changed); `require "net_http_hacked"` and the
193
+ `begin_request_hacked` / `end_request_hacked` methods are gone. If external
194
+ code still depends on them, vendor the file from a 0.8.x release — and plan
195
+ to migrate; it breaks under modern net/http refactors.
196
+
197
+ - The bundled examples moved from the gem load path
198
+ (`lib/rack_proxy_examples/`) to [`examples/`](examples/) in the repository.
199
+ `require "rack_proxy_examples/..."` no longer works — copy the example class
200
+ into your app instead (they were never safe to require blindly: each one
201
+ installs itself into the Rails middleware stack when Rails is booted).
202
+
203
+ ## [0.8.3] - 2025
204
+
205
+ ### Fixed
206
+
207
+ - Handle non-rewindable request body streams (Rack 3 input streams need not
208
+ respond to `#rewind`). (#128)
209
+
210
+ ## [0.8.2] - 2025
211
+
212
+ ### Fixed
213
+
214
+ - Harden `build_header_hash` against a top-level `::Headers` constant defined by
215
+ the host app being picked up instead of `Rack::Headers`.
216
+
217
+ ## [0.8.1] - 2025
218
+
219
+ ### Added
220
+
221
+ - `:logger` option, wired to `Net::HTTP#set_debug_output` for wire-level debug
222
+ output. (#80)
223
+
224
+ ## [0.8.0] - 2025
225
+
226
+ ### Changed
227
+
228
+ - **BREAKING:** TLS certificate verification now defaults to `VERIFY_PEER`
229
+ (Ruby's `Net::HTTP` default). Previous versions silently used `VERIFY_NONE` for
230
+ HTTPS backends. Pass `ssl_verify_none: true` (or `verify_mode:`) to opt out. (#113)
231
+
232
+ ### Fixed
233
+
234
+ - Return `502` on backend connection errors instead of raising; correct body
235
+ handling for empty responses and no-entity-body statuses (1xx/204/304). (#58, #122, #123)
236
+
237
+ ---
238
+
239
+ Older releases (≤ 0.7.8) predate this changelog; see the git history and tags.
240
+
241
+ [Unreleased]: https://github.com/ncr/rack-proxy/compare/v2.0.0...HEAD
242
+ [2.0.0]: https://github.com/ncr/rack-proxy/compare/v1.0.2...v2.0.0
243
+ [1.0.2]: https://github.com/ncr/rack-proxy/compare/v1.0.1...v1.0.2
244
+ [1.0.1]: https://github.com/ncr/rack-proxy/compare/v1.0.0...v1.0.1
245
+ [1.0.0]: https://github.com/ncr/rack-proxy/compare/v0.8.3...v1.0.0
246
+ [0.8.3]: https://github.com/ncr/rack-proxy/compare/v0.8.2...v0.8.3
247
+ [0.8.2]: https://github.com/ncr/rack-proxy/compare/v0.8.1...v0.8.2
248
+ [0.8.1]: https://github.com/ncr/rack-proxy/compare/v0.8.0...v0.8.1
249
+ [0.8.0]: https://github.com/ncr/rack-proxy/compare/v0.7.8...v0.8.0
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013 Jacek Becela jacek.becela@gmail.com
3
+ Copyright (c) 2010-2026 Jacek Becela and contributors jacek.becela@gmail.com
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal