rack 2.2.4 → 2.2.6.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rack might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/README.rdoc +17 -3
- data/lib/rack/method_override.rb +1 -1
- data/lib/rack/multipart/parser.rb +15 -4
- data/lib/rack/multipart.rb +2 -2
- data/lib/rack/request.rb +2 -2
- data/lib/rack/urlmap.rb +1 -1
- data/lib/rack/utils.rb +21 -9
- data/lib/rack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '078561a77beb0af3f12ba96b1a506598140482eec56592a6800e7bf14d5b57c9'
|
4
|
+
data.tar.gz: d14d73096818a28e4dc1e9e98309164029ba0c24768468c6299d11d11fe6a839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 577296b45efdde2334fa386c57b6a9dcd8409cf8949875bcd78970041a078af1fa48e7cf030c6e4bf1377a7eecc771332aeec4c135df25ca74116ae56ab015de
|
7
|
+
data.tar.gz: f589a73eb2b74eea08499e4e945df139612619c1d6543edc0d8ebe78bb2b8181625464d607150a3ef89b86659f6a1bb1838a7940bd64bd418d2ac21873a067db
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,33 @@
|
|
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
|
+
## [2.2.6.4] - 2023-03-13
|
6
|
+
|
7
|
+
- [CVE-2023-27539] Avoid ReDoS in header parsing
|
8
|
+
|
9
|
+
## [2.2.6.3] - 2023-03-02
|
10
|
+
|
11
|
+
- [CVE-2023-27530] Introduce multipart_total_part_limit to limit total parts
|
12
|
+
|
13
|
+
## [2.2.6.2] - 2022-01-17
|
14
|
+
|
15
|
+
- [CVE-2022-44570] Fix ReDoS in Rack::Utils.get_byte_ranges
|
16
|
+
|
17
|
+
## [2.2.6.1] - 2022-01-17
|
18
|
+
|
19
|
+
- [CVE-2022-44571] Fix ReDoS vulnerability in multipart parser
|
20
|
+
- [CVE-2022-44572] Forbid control characters in attributes (also ReDoS)
|
21
|
+
|
22
|
+
## [2.2.6] - 2022-01-17
|
23
|
+
|
24
|
+
- Extend `Rack::MethodOverride` to handle `QueryParser::ParamsTooDeepError` error. ([#2011](https://github.com/rack/rack/pull/2011), [@byroot](https://github.com/byroot))
|
25
|
+
|
26
|
+
## [2.2.5] - 2022-12-27
|
27
|
+
|
28
|
+
### Fixed
|
29
|
+
|
30
|
+
- `Rack::URLMap` uses non-deprecated form of `Regexp.new`. ([#1998](https://github.com/rack/rack/pull/1998), [@weizheheng](https://github.com/weizheheng))
|
31
|
+
|
5
32
|
## [2.2.4] - 2022-06-30
|
6
33
|
|
7
34
|
- Better support for lower case headers in `Rack::ETag` middleware. ([#1919](https://github.com/rack/rack/pull/1919), [@ioquatix](https://github.com/ioquatix))
|
data/README.rdoc
CHANGED
@@ -202,16 +202,30 @@ Limiting the depth prevents a possible stack overflow when parsing parameters.
|
|
202
202
|
|
203
203
|
Defaults to 100.
|
204
204
|
|
205
|
-
===
|
205
|
+
=== multipart_file_limit
|
206
206
|
|
207
|
-
The maximum number of parts a request can contain.
|
207
|
+
The maximum number of parts with a filename a request can contain.
|
208
208
|
Accepting too many part can lead to the server running out of file handles.
|
209
209
|
|
210
210
|
The default is 128, which means that a single request can't upload more than 128 files at once.
|
211
211
|
|
212
212
|
Set to 0 for no limit.
|
213
213
|
|
214
|
-
Can also be set via the +
|
214
|
+
Can also be set via the +RACK_MULTIPART_FILE_LIMIT+ environment variable.
|
215
|
+
|
216
|
+
(This is also aliased as +multipart_part_limit+ and +RACK_MULTIPART_PART_LIMIT+ for compatibility)
|
217
|
+
|
218
|
+
=== multipart_total_part_limit
|
219
|
+
|
220
|
+
The maximum total number of parts a request can contain of any type, including
|
221
|
+
both file and non-file form fields.
|
222
|
+
|
223
|
+
The default is 4096, which means that a single request can't contain more than
|
224
|
+
4096 parts.
|
225
|
+
|
226
|
+
Set to 0 for no limit.
|
227
|
+
|
228
|
+
Can also be set via the +RACK_MULTIPART_TOTAL_PART_LIMIT+ environment variable.
|
215
229
|
|
216
230
|
== Changelog
|
217
231
|
|
data/lib/rack/method_override.rb
CHANGED
@@ -43,7 +43,7 @@ module Rack
|
|
43
43
|
|
44
44
|
def method_override_param(req)
|
45
45
|
req.POST[METHOD_OVERRIDE_PARAM_KEY]
|
46
|
-
rescue Utils::InvalidParameterError, Utils::ParameterTypeError
|
46
|
+
rescue Utils::InvalidParameterError, Utils::ParameterTypeError, QueryParser::ParamsTooDeepError
|
47
47
|
req.get_header(RACK_ERRORS).puts "Invalid or incomplete POST params"
|
48
48
|
rescue EOFError
|
49
49
|
req.get_header(RACK_ERRORS).puts "Bad request content body"
|
@@ -5,6 +5,7 @@ require 'strscan'
|
|
5
5
|
module Rack
|
6
6
|
module Multipart
|
7
7
|
class MultipartPartLimitError < Errno::EMFILE; end
|
8
|
+
class MultipartTotalPartLimitError < StandardError; end
|
8
9
|
|
9
10
|
class Parser
|
10
11
|
(require_relative '../core_ext/regexp'; using ::Rack::RegexpExtensions) if RUBY_VERSION < '2.4'
|
@@ -140,7 +141,7 @@ module Rack
|
|
140
141
|
|
141
142
|
@mime_parts[mime_index] = klass.new(body, head, filename, content_type, name)
|
142
143
|
|
143
|
-
|
144
|
+
check_part_limits
|
144
145
|
end
|
145
146
|
|
146
147
|
def on_mime_body(mime_index, content)
|
@@ -152,13 +153,23 @@ module Rack
|
|
152
153
|
|
153
154
|
private
|
154
155
|
|
155
|
-
def
|
156
|
-
|
157
|
-
|
156
|
+
def check_part_limits
|
157
|
+
file_limit = Utils.multipart_file_limit
|
158
|
+
part_limit = Utils.multipart_total_part_limit
|
159
|
+
|
160
|
+
if file_limit && file_limit > 0
|
161
|
+
if @open_files >= file_limit
|
158
162
|
@mime_parts.each(&:close)
|
159
163
|
raise MultipartPartLimitError, 'Maximum file multiparts in content reached'
|
160
164
|
end
|
161
165
|
end
|
166
|
+
|
167
|
+
if part_limit && part_limit > 0
|
168
|
+
if @mime_parts.size >= part_limit
|
169
|
+
@mime_parts.each(&:close)
|
170
|
+
raise MultipartTotalPartLimitError, 'Maximum total multiparts in content reached'
|
171
|
+
end
|
172
|
+
end
|
162
173
|
end
|
163
174
|
end
|
164
175
|
|
data/lib/rack/multipart.rb
CHANGED
@@ -18,10 +18,10 @@ module Rack
|
|
18
18
|
VALUE = /"(?:\\"|[^"])*"|#{TOKEN}/
|
19
19
|
BROKEN = /^#{CONDISP}.*;\s*filename=(#{VALUE})/i
|
20
20
|
MULTIPART_CONTENT_TYPE = /Content-Type: (.*)#{EOL}/ni
|
21
|
-
MULTIPART_CONTENT_DISPOSITION = /Content-Disposition
|
21
|
+
MULTIPART_CONTENT_DISPOSITION = /Content-Disposition:[^:]*;\s*name=(#{VALUE})/ni
|
22
22
|
MULTIPART_CONTENT_ID = /Content-ID:\s*([^#{EOL}]*)/ni
|
23
23
|
# Updated definitions from RFC 2231
|
24
|
-
ATTRIBUTE_CHAR = %r{[^ \
|
24
|
+
ATTRIBUTE_CHAR = %r{[^ \x00-\x1f\x7f)(><@,;:\\"/\[\]?='*%]}
|
25
25
|
ATTRIBUTE = /#{ATTRIBUTE_CHAR}+/
|
26
26
|
SECTION = /\*[0-9]+/
|
27
27
|
REGULAR_PARAMETER_NAME = /#{ATTRIBUTE}#{SECTION}?/
|
data/lib/rack/request.rb
CHANGED
@@ -572,8 +572,8 @@ module Rack
|
|
572
572
|
end
|
573
573
|
|
574
574
|
def parse_http_accept_header(header)
|
575
|
-
header.to_s.split(
|
576
|
-
attribute, parameters = part.split(
|
575
|
+
header.to_s.split(",").each(&:strip!).map do |part|
|
576
|
+
attribute, parameters = part.split(";", 2).each(&:strip!)
|
577
577
|
quality = 1.0
|
578
578
|
if parameters and /\Aq=([\d.]+)/ =~ parameters
|
579
579
|
quality = $1.to_f
|
data/lib/rack/urlmap.rb
CHANGED
@@ -35,7 +35,7 @@ module Rack
|
|
35
35
|
end
|
36
36
|
|
37
37
|
location = location.chomp('/')
|
38
|
-
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)",
|
38
|
+
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", Regexp::NOENCODING)
|
39
39
|
|
40
40
|
[host, location, match, app]
|
41
41
|
}.sort_by do |(host, location, _, _)|
|
data/lib/rack/utils.rb
CHANGED
@@ -58,13 +58,24 @@ module Rack
|
|
58
58
|
end
|
59
59
|
|
60
60
|
class << self
|
61
|
-
attr_accessor :
|
61
|
+
attr_accessor :multipart_total_part_limit
|
62
|
+
|
63
|
+
attr_accessor :multipart_file_limit
|
64
|
+
|
65
|
+
# multipart_part_limit is the original name of multipart_file_limit, but
|
66
|
+
# the limit only counts parts with filenames.
|
67
|
+
alias multipart_part_limit multipart_file_limit
|
68
|
+
alias multipart_part_limit= multipart_file_limit=
|
62
69
|
end
|
63
70
|
|
64
|
-
# The maximum number of parts a request can contain. Accepting too
|
65
|
-
# can lead to the server running out of file handles.
|
71
|
+
# The maximum number of file parts a request can contain. Accepting too
|
72
|
+
# many parts can lead to the server running out of file handles.
|
66
73
|
# Set to `0` for no limit.
|
67
|
-
self.
|
74
|
+
self.multipart_file_limit = (ENV['RACK_MULTIPART_PART_LIMIT'] || ENV['RACK_MULTIPART_FILE_LIMIT'] || 128).to_i
|
75
|
+
|
76
|
+
# The maximum total number of parts a request can contain. Accepting too
|
77
|
+
# many can lead to excessive memory use and parsing time.
|
78
|
+
self.multipart_total_part_limit = (ENV['RACK_MULTIPART_TOTAL_PART_LIMIT'] || 4096).to_i
|
68
79
|
|
69
80
|
def self.param_depth_limit
|
70
81
|
default_query_parser.param_depth_limit
|
@@ -348,17 +359,18 @@ module Rack
|
|
348
359
|
return nil unless http_range && http_range =~ /bytes=([^;]+)/
|
349
360
|
ranges = []
|
350
361
|
$1.split(/,\s*/).each do |range_spec|
|
351
|
-
return nil
|
352
|
-
|
353
|
-
|
354
|
-
|
362
|
+
return nil unless range_spec.include?('-')
|
363
|
+
range = range_spec.split('-')
|
364
|
+
r0, r1 = range[0], range[1]
|
365
|
+
if r0.nil? || r0.empty?
|
366
|
+
return nil if r1.nil?
|
355
367
|
# suffix-byte-range-spec, represents trailing suffix of file
|
356
368
|
r0 = size - r1.to_i
|
357
369
|
r0 = 0 if r0 < 0
|
358
370
|
r1 = size - 1
|
359
371
|
else
|
360
372
|
r0 = r0.to_i
|
361
|
-
if r1.
|
373
|
+
if r1.nil?
|
362
374
|
r1 = size - 1
|
363
375
|
else
|
364
376
|
r1 = r1.to_i
|
data/lib/rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.4
|
4
|
+
version: 2.2.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|