rack 3.0.15 → 3.0.16
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +27 -0
- data/lib/rack/query_parser.rb +51 -8
- data/lib/rack/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaf5a33f441d4e1a6b0a9600e54b74901556464d1ce61a232ce43b0cca7139ec
|
4
|
+
data.tar.gz: 0df47d8d7aa5a9bb86fb73ef60e73aa339a4c5ba070fbdd4e7d369b83e054dc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae3b3583f15553fc4e42e147d9774aeae5fd76ae1bc24ebaf18ce5d3199a4cb341ef5476d8e4ecb5527430acb3718c23ad77b5c742df5b6acbbca37756337cdd
|
7
|
+
data.tar.gz: eb8880792c8bf5e6f61574edad0e6b56105b399adc393f82f25d3fa25b9e4d1c67a5365e342a7065a884635a6d9498b0c89ec4653644fd6f3036f354117986ff
|
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.0.16] - 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.0.15] - 2025-04-13
|
6
12
|
|
7
13
|
- Ensure `Rack::ETag` correctly updates response body. ([#2324](https://github.com/rack/rack/pull/2324), [@ioquatix])
|
@@ -204,6 +210,12 @@ All notable changes to this project will be documented in this file. For info on
|
|
204
210
|
- 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))
|
205
211
|
- `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))
|
206
212
|
|
213
|
+
## [2.2.14] - 2025-05-06
|
214
|
+
|
215
|
+
### Security
|
216
|
+
|
217
|
+
- [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.
|
218
|
+
|
207
219
|
## [2.2.13] - 2025-03-11
|
208
220
|
|
209
221
|
### Security
|
data/README.md
CHANGED
@@ -165,6 +165,33 @@ quickly and without doing the same web stuff all over:
|
|
165
165
|
Rack exposes several configuration parameters to control various features of the
|
166
166
|
implementation.
|
167
167
|
|
168
|
+
### `RACK_QUERY_PARSER_BYTESIZE_LIMIT`
|
169
|
+
|
170
|
+
This environment variable sets the default for the maximum query string bytesize
|
171
|
+
that `Rack::QueryParser` will attempt to parse. Attempts to use a query string
|
172
|
+
that exceeds this number of bytes will result in a
|
173
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
174
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
175
|
+
|
176
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
177
|
+
the `bytesize_limit` keyword argument when creating the `Rack::QueryParser`.
|
178
|
+
|
179
|
+
### `RACK_QUERY_PARSER_PARAMS_LIMIT`
|
180
|
+
|
181
|
+
This environment variable sets the default for the maximum number of query
|
182
|
+
parameters that `Rack::QueryParser` will attempt to parse. Attempts to use a
|
183
|
+
query string with more than this many query parameters will result in a
|
184
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
185
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
186
|
+
|
187
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
188
|
+
the `params_limit` keyword argument when creating the `Rack::QueryParser`.
|
189
|
+
|
190
|
+
This is implemented by counting the number of parameter separators in the
|
191
|
+
query string, before attempting parsing, so if the same parameter key is
|
192
|
+
used multiple times in the query, each counts as a separate parameter for
|
193
|
+
this check.
|
194
|
+
|
168
195
|
### `param_depth_limit`
|
169
196
|
|
170
197
|
```ruby
|
data/lib/rack/query_parser.rb
CHANGED
@@ -16,27 +16,54 @@ module Rack
|
|
16
16
|
# sequence.
|
17
17
|
class InvalidParameterError < ArgumentError; end
|
18
18
|
|
19
|
-
#
|
20
|
-
#
|
21
|
-
class
|
19
|
+
# QueryLimitError is for errors raised when the query provided exceeds one
|
20
|
+
# of the query parser limits.
|
21
|
+
class QueryLimitError < RangeError
|
22
|
+
end
|
23
|
+
|
24
|
+
# ParamsTooDeepError is the old name for the error that is raised when params
|
25
|
+
# are recursively nested over the specified limit. Make it the same as
|
26
|
+
# as QueryLimitError, so that code that rescues ParamsTooDeepError error
|
27
|
+
# to handle bad query strings also now handles other limits.
|
28
|
+
ParamsTooDeepError = QueryLimitError
|
22
29
|
|
23
|
-
def self.make_default(_key_space_limit=(not_deprecated = true; nil), param_depth_limit)
|
30
|
+
def self.make_default(_key_space_limit=(not_deprecated = true; nil), param_depth_limit, **options)
|
24
31
|
unless not_deprecated
|
25
32
|
warn("`first argument `key_space limit` is deprecated and no longer has an effect. Please call with only one argument, which will be required in a future version of Rack", uplevel: 1)
|
26
33
|
end
|
27
34
|
|
28
|
-
new Params, param_depth_limit
|
35
|
+
new Params, param_depth_limit, **options
|
29
36
|
end
|
30
37
|
|
31
38
|
attr_reader :param_depth_limit
|
32
39
|
|
33
|
-
|
40
|
+
env_int = lambda do |key, val|
|
41
|
+
if str_val = ENV[key]
|
42
|
+
begin
|
43
|
+
val = Integer(str_val, 10)
|
44
|
+
rescue ArgumentError
|
45
|
+
raise ArgumentError, "non-integer value provided for environment variable #{key}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
val
|
50
|
+
end
|
51
|
+
|
52
|
+
BYTESIZE_LIMIT = env_int.call("RACK_QUERY_PARSER_BYTESIZE_LIMIT", 4194304)
|
53
|
+
private_constant :BYTESIZE_LIMIT
|
54
|
+
|
55
|
+
PARAMS_LIMIT = env_int.call("RACK_QUERY_PARSER_PARAMS_LIMIT", 4096)
|
56
|
+
private_constant :PARAMS_LIMIT
|
57
|
+
|
58
|
+
def initialize(params_class, _key_space_limit=(not_deprecated = true; nil), param_depth_limit, bytesize_limit: BYTESIZE_LIMIT, params_limit: PARAMS_LIMIT)
|
34
59
|
unless not_deprecated
|
35
60
|
warn("`second argument `key_space limit` is deprecated and no longer has an effect. Please call with only two arguments, which will be required in a future version of Rack", uplevel: 1)
|
36
61
|
end
|
37
62
|
|
38
63
|
@params_class = params_class
|
39
64
|
@param_depth_limit = param_depth_limit
|
65
|
+
@bytesize_limit = bytesize_limit
|
66
|
+
@params_limit = params_limit
|
40
67
|
end
|
41
68
|
|
42
69
|
# Stolen from Mongrel, with some small modifications:
|
@@ -48,7 +75,7 @@ module Rack
|
|
48
75
|
|
49
76
|
params = make_params
|
50
77
|
|
51
|
-
(qs
|
78
|
+
check_query_string(qs, separator).split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
|
52
79
|
next if p.empty?
|
53
80
|
k, v = p.split('=', 2).map!(&unescaper)
|
54
81
|
|
@@ -75,7 +102,7 @@ module Rack
|
|
75
102
|
params = make_params
|
76
103
|
|
77
104
|
unless qs.nil? || qs.empty?
|
78
|
-
(qs
|
105
|
+
check_query_string(qs, separator).split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP).each do |p|
|
79
106
|
k, v = p.split('=', 2).map! { |s| unescape(s) }
|
80
107
|
|
81
108
|
_normalize_params(params, k, v, 0)
|
@@ -190,6 +217,22 @@ module Rack
|
|
190
217
|
true
|
191
218
|
end
|
192
219
|
|
220
|
+
def check_query_string(qs, sep)
|
221
|
+
if qs
|
222
|
+
if qs.bytesize > @bytesize_limit
|
223
|
+
raise QueryLimitError, "total query size (#{qs.bytesize}) exceeds limit (#{@bytesize_limit})"
|
224
|
+
end
|
225
|
+
|
226
|
+
if (param_count = qs.count(sep.is_a?(String) ? sep : '&')) >= @params_limit
|
227
|
+
raise QueryLimitError, "total number of query parameters (#{param_count+1}) exceeds limit (#{@params_limit})"
|
228
|
+
end
|
229
|
+
|
230
|
+
qs
|
231
|
+
else
|
232
|
+
''
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
193
236
|
def unescape(string, encoding = Encoding::UTF_8)
|
194
237
|
URI.decode_www_form_component(string, encoding)
|
195
238
|
end
|
data/lib/rack/version.rb
CHANGED
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.0.
|
4
|
+
version: 3.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-
|
11
|
+
date: 2025-05-06 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: minitest
|
@@ -148,6 +149,7 @@ metadata:
|
|
148
149
|
changelog_uri: https://github.com/rack/rack/blob/main/CHANGELOG.md
|
149
150
|
documentation_uri: https://rubydoc.info/github/rack/rack
|
150
151
|
source_code_uri: https://github.com/rack/rack
|
152
|
+
post_install_message:
|
151
153
|
rdoc_options: []
|
152
154
|
require_paths:
|
153
155
|
- lib
|
@@ -162,7 +164,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
164
|
- !ruby/object:Gem::Version
|
163
165
|
version: '0'
|
164
166
|
requirements: []
|
165
|
-
rubygems_version: 3.
|
167
|
+
rubygems_version: 3.5.22
|
168
|
+
signing_key:
|
166
169
|
specification_version: 4
|
167
170
|
summary: A modular Ruby webserver interface.
|
168
171
|
test_files: []
|