rack 3.1.13 → 3.1.14

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: c37d6fcc7c80a646ee683678ba8c3d17646af8d98f31902b8e6ee3449f914821
4
- data.tar.gz: a28c9a12f6a1ee7ba418c5e997c93793332e84baa9974df03fae28f04e0f1c9f
3
+ metadata.gz: 558fa2ba3e85c5e5c3775d72153132d6f667aa7390421fb6769b6cc26dd3bd72
4
+ data.tar.gz: 135df43165c5e6fa3a69cd4857ee2e514cfe7841ed3728889e61185268e86531
5
5
  SHA512:
6
- metadata.gz: 23bedeb70ddc2c16a70bee1112dd5b9fe2ae6f25bc4151e927073ade7e604349150855e37c26277ab06b9830b4373306c72ca3806bdd140bbf24881a7153b4d7
7
- data.tar.gz: f7ab42b0cadfa26487f04dfc1cb55d19fe18c662f51a800fa271c95ea29724834a0f773f480a891d04af68b3182065e5f6e14af64f86ffd55977a1cc26bef1cf
6
+ metadata.gz: 3543b51083a592a6609ac760ee6b4a692b442496258470c3d70cd94ada81c22439c21e5637599e6d85fd0c25983fc0819883f2449466cfb3c41ed8154287b221
7
+ data.tar.gz: a1da3c54d64e956c1b4b02065da3deaff9ef9e212e2c5366260691caef698bea993ceb9b26e0a26d72f37481fb0f0a91803fe99e864baffbbfa10e31ca4e79cc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. For info on how to format all future additions to this file please reference [Keep A Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [3.1.14] - 2025-05-06
6
+
7
+ ### Security
8
+
9
+ - [CVE-2025-46727](https://github.com/rack/rack/security/advisories/GHSA-gjh7-p2fx-99vx) Unbounded parameter parsing in `Rack::QueryParser` can lead to memory exhaustion.
10
+
5
11
  ## [3.1.13] - 2025-04-13
6
12
 
7
13
  - Ensure `Rack::ETag` correctly updates response body. ([#2324](https://github.com/rack/rack/pull/2324), [@ioquatix])
@@ -133,6 +139,12 @@ Rack v3.1 is primarily a maintenance release that removes features deprecated in
133
139
 
134
140
  - In `Rack::Files`, ignore the `Range` header if served file is 0 bytes. ([#2159](https://github.com/rack/rack/pull/2159), [@zarqman])
135
141
 
142
+ ## [3.0.16] - 2025-05-06
143
+
144
+ ### Security
145
+
146
+ - [CVE-2025-46727](https://github.com/rack/rack/security/advisories/GHSA-gjh7-p2fx-99vx) Unbounded parameter parsing in `Rack::QueryParser` can lead to memory exhaustion.
147
+
136
148
  ## [3.0.15] - 2025-04-13
137
149
 
138
150
  - Ensure `Rack::ETag` correctly updates response body. ([#2324](https://github.com/rack/rack/pull/2324), [@ioquatix])
@@ -331,6 +343,12 @@ Rack v3.1 is primarily a maintenance release that removes features deprecated in
331
343
  - Fix multipart filename generation for filenames that contain spaces. Encode spaces as "%20" instead of "+" which will be decoded properly by the multipart parser. ([#1736](https://github.com/rack/rack/pull/1645), [@muirdm](https://github.com/muirdm))
332
344
  - `Rack::Request#scheme` returns `ws` or `wss` when one of the `X-Forwarded-Scheme` / `X-Forwarded-Proto` headers is set to `ws` or `wss`, respectively. ([#1730](https://github.com/rack/rack/issues/1730), [@erwanst](https://github.com/erwanst))
333
345
 
346
+ ## [2.2.14] - 2025-05-06
347
+
348
+ ### Security
349
+
350
+ - [CVE-2025-46727](https://github.com/rack/rack/security/advisories/GHSA-gjh7-p2fx-99vx) Unbounded parameter parsing in `Rack::QueryParser` can lead to memory exhaustion.
351
+
334
352
  ## [2.2.13] - 2025-03-11
335
353
 
336
354
  ### Security
data/README.md CHANGED
@@ -183,6 +183,33 @@ quickly and without doing the same web stuff all over:
183
183
  Rack exposes several configuration parameters to control various features of the
184
184
  implementation.
185
185
 
186
+ ### `RACK_QUERY_PARSER_BYTESIZE_LIMIT`
187
+
188
+ This environment variable sets the default for the maximum query string bytesize
189
+ that `Rack::QueryParser` will attempt to parse. Attempts to use a query string
190
+ that exceeds this number of bytes will result in a
191
+ `Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
192
+ provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
193
+
194
+ The default limit can be overridden on a per-`Rack::QueryParser` basis using
195
+ the `bytesize_limit` keyword argument when creating the `Rack::QueryParser`.
196
+
197
+ ### `RACK_QUERY_PARSER_PARAMS_LIMIT`
198
+
199
+ This environment variable sets the default for the maximum number of query
200
+ parameters that `Rack::QueryParser` will attempt to parse. Attempts to use a
201
+ query string with more than this many query parameters will result in a
202
+ `Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
203
+ provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
204
+
205
+ The default limit can be overridden on a per-`Rack::QueryParser` basis using
206
+ the `params_limit` keyword argument when creating the `Rack::QueryParser`.
207
+
208
+ This is implemented by counting the number of parameter separators in the
209
+ query string, before attempting parsing, so if the same parameter key is
210
+ used multiple times in the query, each counts as a separate parameter for
211
+ this check.
212
+
186
213
  ### `param_depth_limit`
187
214
 
188
215
  ```ruby
@@ -21,21 +21,47 @@ module Rack
21
21
  include BadRequest
22
22
  end
23
23
 
24
- # ParamsTooDeepError is the error that is raised when params are recursively
25
- # nested over the specified limit.
26
- class ParamsTooDeepError < RangeError
24
+ # QueryLimitError is for errors raised when the query provided exceeds one
25
+ # of the query parser limits.
26
+ class QueryLimitError < RangeError
27
27
  include BadRequest
28
28
  end
29
29
 
30
- def self.make_default(param_depth_limit)
31
- new Params, param_depth_limit
30
+ # ParamsTooDeepError is the old name for the error that is raised when params
31
+ # are recursively nested over the specified limit. Make it the same as
32
+ # as QueryLimitError, so that code that rescues ParamsTooDeepError error
33
+ # to handle bad query strings also now handles other limits.
34
+ ParamsTooDeepError = QueryLimitError
35
+
36
+ def self.make_default(param_depth_limit, **options)
37
+ new(Params, param_depth_limit, **options)
32
38
  end
33
39
 
34
40
  attr_reader :param_depth_limit
35
41
 
36
- def initialize(params_class, param_depth_limit)
42
+ env_int = lambda do |key, val|
43
+ if str_val = ENV[key]
44
+ begin
45
+ val = Integer(str_val, 10)
46
+ rescue ArgumentError
47
+ raise ArgumentError, "non-integer value provided for environment variable #{key}"
48
+ end
49
+ end
50
+
51
+ val
52
+ end
53
+
54
+ BYTESIZE_LIMIT = env_int.call("RACK_QUERY_PARSER_BYTESIZE_LIMIT", 4194304)
55
+ private_constant :BYTESIZE_LIMIT
56
+
57
+ PARAMS_LIMIT = env_int.call("RACK_QUERY_PARSER_PARAMS_LIMIT", 4096)
58
+ private_constant :PARAMS_LIMIT
59
+
60
+ def initialize(params_class, param_depth_limit, bytesize_limit: BYTESIZE_LIMIT, params_limit: PARAMS_LIMIT)
37
61
  @params_class = params_class
38
62
  @param_depth_limit = param_depth_limit
63
+ @bytesize_limit = bytesize_limit
64
+ @params_limit = params_limit
39
65
  end
40
66
 
41
67
  # Stolen from Mongrel, with some small modifications:
@@ -47,7 +73,7 @@ module Rack
47
73
 
48
74
  params = make_params
49
75
 
50
- (qs || '').split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
76
+ check_query_string(qs, separator).split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
51
77
  next if p.empty?
52
78
  k, v = p.split('=', 2).map!(&unescaper)
53
79
 
@@ -74,7 +100,7 @@ module Rack
74
100
  params = make_params
75
101
 
76
102
  unless qs.nil? || qs.empty?
77
- (qs || '').split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
103
+ check_query_string(qs, separator).split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
78
104
  k, v = p.split('=', 2).map! { |s| unescape(s) }
79
105
 
80
106
  _normalize_params(params, k, v, 0)
@@ -189,6 +215,22 @@ module Rack
189
215
  true
190
216
  end
191
217
 
218
+ def check_query_string(qs, sep)
219
+ if qs
220
+ if qs.bytesize > @bytesize_limit
221
+ raise QueryLimitError, "total query size (#{qs.bytesize}) exceeds limit (#{@bytesize_limit})"
222
+ end
223
+
224
+ if (param_count = qs.count(sep.is_a?(String) ? sep : '&')) >= @params_limit
225
+ raise QueryLimitError, "total number of query parameters (#{param_count+1}) exceeds limit (#{@params_limit})"
226
+ end
227
+
228
+ qs
229
+ else
230
+ ''
231
+ end
232
+ end
233
+
192
234
  def unescape(string, encoding = Encoding::UTF_8)
193
235
  URI.decode_www_form_component(string, encoding)
194
236
  end
data/lib/rack/version.rb CHANGED
@@ -12,7 +12,7 @@
12
12
  # so it should be enough just to <tt>require 'rack'</tt> in your code.
13
13
 
14
14
  module Rack
15
- RELEASE = "3.1.13"
15
+ RELEASE = "3.1.14"
16
16
 
17
17
  # Return the Rack release as a dotted string.
18
18
  def self.release
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.13
4
+ version: 3.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leah Neukirchen
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-04-13 00:00:00.000000000 Z
11
+ date: 2025-05-06 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: minitest
@@ -142,6 +143,7 @@ metadata:
142
143
  changelog_uri: https://github.com/rack/rack/blob/main/CHANGELOG.md
143
144
  documentation_uri: https://rubydoc.info/github/rack/rack
144
145
  source_code_uri: https://github.com/rack/rack
146
+ post_install_message:
145
147
  rdoc_options: []
146
148
  require_paths:
147
149
  - lib
@@ -156,7 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
158
  - !ruby/object:Gem::Version
157
159
  version: '0'
158
160
  requirements: []
159
- rubygems_version: 3.6.2
161
+ rubygems_version: 3.5.22
162
+ signing_key:
160
163
  specification_version: 4
161
164
  summary: A modular Ruby webserver interface.
162
165
  test_files: []