rack 2.0.9 → 2.0.9.2
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/HISTORY.md +11 -0
- data/SPEC +7 -8
- data/lib/rack/common_logger.rb +3 -0
- data/lib/rack/lint.rb +1 -1
- data/lib/rack/multipart/parser.rb +2 -1
- data/lib/rack/multipart.rb +3 -4
- data/lib/rack/utils.rb +6 -5
- data/lib/rack.rb +1 -1
- data/test/cgi/test.gz +0 -0
- data/test/multipart/filename_with_escaped_quotes_and_modification_param +1 -1
- data/test/spec_common_logger.rb +12 -0
- data/test/spec_lint.rb +5 -0
- data/test/spec_multipart.rb +1 -14
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc237005e0685c87558593892557c95cd2b19a69344a5e7730861c4737710068
|
4
|
+
data.tar.gz: c6f06fabfb75b648b39013635615bb0c234b46e06bb21ee0d34fa984bc8a4327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d96b990c872a04ed4dfc6eeea2ee24c7229d1bc382fb19ee56a2d63df67ef155e76e2ff760b5fce600101bf49f4359ed021959f1d72789821c71db4653e67a
|
7
|
+
data.tar.gz: bf4aceee4f04788e44dac8838ff210be458f6869264c380da218ad1d8f60651900212c6f2b6e1909666d9861a2d7865a85da8b4ff836b5ad075d3fe7cf9293f2
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
Tue Jan 17 12:27:04 2023 Aaron Patterson <tenderlove@ruby-lang.org>
|
2
|
+
|
3
|
+
* [CVE-2022-44571] Fix ReDoS vulnerability in multipart parser
|
4
|
+
* [CVE-2022-44570] Fix ReDoS in Rack::Utils.get_byte_ranges
|
5
|
+
* [CVE-2022-44572] Forbid control characters in attributes (also ReDoS)
|
6
|
+
|
7
|
+
Fri May 27 08:27:04 2022 Aaron Patterson <tenderlove@ruby-lang.org>
|
8
|
+
|
9
|
+
* [CVE-2022-30123] Fix shell escaping issue in Common Logger
|
10
|
+
* [CVE-2022-30122] Restrict parsing of broken MIME attachments
|
11
|
+
|
1
12
|
Sun Dec 4 18:48:03 2015 Jeremy Daer <jeremydaer@gmail.com>
|
2
13
|
|
3
14
|
* First-party "SameSite" cookies. Browsers omit SameSite cookies
|
data/SPEC
CHANGED
@@ -60,8 +60,8 @@ below.
|
|
60
60
|
the presence or absence of the
|
61
61
|
appropriate HTTP header in the
|
62
62
|
request. See
|
63
|
-
|
64
|
-
RFC3875 section 4.1.18
|
63
|
+
{https://tools.ietf.org/html/rfc3875#section-4.1.18
|
64
|
+
RFC3875 section 4.1.18} for
|
65
65
|
specific behavior.
|
66
66
|
In addition to this, the Rack environment must include these
|
67
67
|
Rack-specific variables:
|
@@ -98,13 +98,12 @@ Rack-specific variables:
|
|
98
98
|
Additional environment specifications have approved to
|
99
99
|
standardized middleware APIs. None of these are required to
|
100
100
|
be implemented by the server.
|
101
|
-
<tt>rack.session</tt>:: A hash like interface for storing
|
102
|
-
request session data.
|
101
|
+
<tt>rack.session</tt>:: A hash like interface for storing request session data.
|
103
102
|
The store must implement:
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
store(key, value) (aliased as []=);
|
104
|
+
fetch(key, default = nil) (aliased as []);
|
105
|
+
delete(key);
|
106
|
+
clear;
|
108
107
|
<tt>rack.logger</tt>:: A common object interface for logging messages.
|
109
108
|
The object must implement:
|
110
109
|
info(message, &block)
|
data/lib/rack/common_logger.rb
CHANGED
@@ -54,7 +54,10 @@ module Rack
|
|
54
54
|
length,
|
55
55
|
now - began_at ]
|
56
56
|
|
57
|
+
msg.gsub!(/[^[:print:]\n]/) { |c| "\\x#{c.ord}" }
|
58
|
+
|
57
59
|
logger = @logger || env[RACK_ERRORS]
|
60
|
+
|
58
61
|
# Standard library logger doesn't support write but it supports << which actually
|
59
62
|
# calls to write on the log device without formatting
|
60
63
|
if logger.respond_to?(:write)
|
data/lib/rack/lint.rb
CHANGED
@@ -295,7 +295,7 @@ module Rack
|
|
295
295
|
check_hijack env
|
296
296
|
|
297
297
|
## * The <tt>REQUEST_METHOD</tt> must be a valid token.
|
298
|
-
assert("REQUEST_METHOD unknown: #{env[REQUEST_METHOD]}") {
|
298
|
+
assert("REQUEST_METHOD unknown: #{env[REQUEST_METHOD].dump}") {
|
299
299
|
env[REQUEST_METHOD] =~ /\A[0-9A-Za-z!\#$%&'*+.^_`|~-]+\z/
|
300
300
|
}
|
301
301
|
|
@@ -302,8 +302,9 @@ module Rack
|
|
302
302
|
elsif filename = params['filename*']
|
303
303
|
encoding, _, filename = filename.split("'", 3)
|
304
304
|
end
|
305
|
-
when
|
305
|
+
when BROKEN
|
306
306
|
filename = $1
|
307
|
+
filename = $1 if filename =~ /^"(.*)"$/
|
307
308
|
end
|
308
309
|
|
309
310
|
return unless filename
|
data/lib/rack/multipart.rb
CHANGED
@@ -14,13 +14,12 @@ module Rack
|
|
14
14
|
TOKEN = /[^\s()<>,;:\\"\/\[\]?=]+/
|
15
15
|
CONDISP = /Content-Disposition:\s*#{TOKEN}\s*/i
|
16
16
|
VALUE = /"(?:\\"|[^"])*"|#{TOKEN}/
|
17
|
-
|
18
|
-
BROKEN_UNQUOTED = /^#{CONDISP}.*;\sfilename=(#{TOKEN})/i
|
17
|
+
BROKEN = /^#{CONDISP}.*;\s*filename=(#{VALUE})/i
|
19
18
|
MULTIPART_CONTENT_TYPE = /Content-Type: (.*)#{EOL}/ni
|
20
|
-
MULTIPART_CONTENT_DISPOSITION = /Content-Disposition
|
19
|
+
MULTIPART_CONTENT_DISPOSITION = /Content-Disposition:[^:]*;\s+name=(#{VALUE})/ni
|
21
20
|
MULTIPART_CONTENT_ID = /Content-ID:\s*([^#{EOL}]*)/ni
|
22
21
|
# Updated definitions from RFC 2231
|
23
|
-
ATTRIBUTE_CHAR = %r{[^ \
|
22
|
+
ATTRIBUTE_CHAR = %r{[^ \x00-\x1f\x7f)(><@,;:\\"/\[\]?='*%]}
|
24
23
|
ATTRIBUTE = /#{ATTRIBUTE_CHAR}+/
|
25
24
|
SECTION = /\*[0-9]+/
|
26
25
|
REGULAR_PARAMETER_NAME = /#{ATTRIBUTE}#{SECTION}?/
|
data/lib/rack/utils.rb
CHANGED
@@ -365,17 +365,18 @@ module Rack
|
|
365
365
|
return nil unless http_range && http_range =~ /bytes=([^;]+)/
|
366
366
|
ranges = []
|
367
367
|
$1.split(/,\s*/).each do |range_spec|
|
368
|
-
return nil
|
369
|
-
|
370
|
-
|
371
|
-
|
368
|
+
return nil unless range_spec.include?('-')
|
369
|
+
range = range_spec.split('-')
|
370
|
+
r0, r1 = range[0], range[1]
|
371
|
+
if r0.nil? || r0.empty?
|
372
|
+
return nil if r1.nil?
|
372
373
|
# suffix-byte-range-spec, represents trailing suffix of file
|
373
374
|
r0 = size - r1.to_i
|
374
375
|
r0 = 0 if r0 < 0
|
375
376
|
r1 = size - 1
|
376
377
|
else
|
377
378
|
r0 = r0.to_i
|
378
|
-
if r1.
|
379
|
+
if r1.nil?
|
379
380
|
r1 = size - 1
|
380
381
|
else
|
381
382
|
r1 = r1.to_i
|
data/lib/rack.rb
CHANGED
data/test/cgi/test.gz
CHANGED
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
--AaB03x
|
2
2
|
Content-Type: image/jpeg
|
3
|
-
Content-Disposition: attachment; name="files"; filename=""human" genome.jpeg"; modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
|
3
|
+
Content-Disposition: attachment; name="files"; filename="\"human\" genome.jpeg"; modification-date="Wed, 12 Feb 1997 16:29:51 -0500";
|
4
4
|
Content-Description: a complete map of the human genome
|
5
5
|
|
6
6
|
contents
|
data/test/spec_common_logger.rb
CHANGED
@@ -21,6 +21,10 @@ describe Rack::CommonLogger do
|
|
21
21
|
[200,
|
22
22
|
{"Content-Type" => "text/html", "Content-Length" => "0"},
|
23
23
|
[]]}
|
24
|
+
app_without_lint = lambda { |env|
|
25
|
+
[200,
|
26
|
+
{ "content-type" => "text/html", "content-length" => length.to_s },
|
27
|
+
[obj]]}
|
24
28
|
|
25
29
|
it "log to rack.errors by default" do
|
26
30
|
res = Rack::MockRequest.new(Rack::CommonLogger.new(app)).get("/")
|
@@ -85,6 +89,14 @@ describe Rack::CommonLogger do
|
|
85
89
|
(0..1).must_include duration.to_f
|
86
90
|
end
|
87
91
|
|
92
|
+
it "escapes non printable characters except newline" do
|
93
|
+
logdev = StringIO.new
|
94
|
+
log = Logger.new(logdev)
|
95
|
+
Rack::MockRequest.new(Rack::CommonLogger.new(app_without_lint, log)).request("GET\b", "/hello")
|
96
|
+
|
97
|
+
logdev.string.must_match(/GET\\x8 \/hello/)
|
98
|
+
end
|
99
|
+
|
88
100
|
def length
|
89
101
|
123
|
90
102
|
end
|
data/test/spec_lint.rb
CHANGED
@@ -96,6 +96,11 @@ describe Rack::Lint do
|
|
96
96
|
}.must_raise(Rack::Lint::LintError).
|
97
97
|
message.must_match(/REQUEST_METHOD/)
|
98
98
|
|
99
|
+
lambda {
|
100
|
+
Rack::Lint.new(nil).call(env("REQUEST_METHOD" => "OOPS?\b!"))
|
101
|
+
}.must_raise(Rack::Lint::LintError).
|
102
|
+
message.must_match(/OOPS\?\\/)
|
103
|
+
|
99
104
|
lambda {
|
100
105
|
Rack::Lint.new(nil).call(env("SCRIPT_NAME" => "howdy"))
|
101
106
|
}.must_raise(Rack::Lint::LintError).
|
data/test/spec_multipart.rb
CHANGED
@@ -381,19 +381,6 @@ describe Rack::Multipart do
|
|
381
381
|
params["files"][:tempfile].read.must_equal "contents"
|
382
382
|
end
|
383
383
|
|
384
|
-
it "parse filename with unescaped quotes" do
|
385
|
-
env = Rack::MockRequest.env_for("/", multipart_fixture(:filename_with_unescaped_quotes))
|
386
|
-
params = Rack::Multipart.parse_multipart(env)
|
387
|
-
params["files"][:type].must_equal "application/octet-stream"
|
388
|
-
params["files"][:filename].must_equal "escape \"quotes"
|
389
|
-
params["files"][:head].must_equal "Content-Disposition: form-data; " +
|
390
|
-
"name=\"files\"; " +
|
391
|
-
"filename=\"escape \"quotes\"\r\n" +
|
392
|
-
"Content-Type: application/octet-stream\r\n"
|
393
|
-
params["files"][:name].must_equal "files"
|
394
|
-
params["files"][:tempfile].read.must_equal "contents"
|
395
|
-
end
|
396
|
-
|
397
384
|
it "parse filename with escaped quotes and modification param" do
|
398
385
|
env = Rack::MockRequest.env_for("/", multipart_fixture(:filename_with_escaped_quotes_and_modification_param))
|
399
386
|
params = Rack::Multipart.parse_multipart(env)
|
@@ -402,7 +389,7 @@ describe Rack::Multipart do
|
|
402
389
|
params["files"][:head].must_equal "Content-Type: image/jpeg\r\n" +
|
403
390
|
"Content-Disposition: attachment; " +
|
404
391
|
"name=\"files\"; " +
|
405
|
-
"filename=\"
|
392
|
+
"filename=\"\\\"human\\\" genome.jpeg\"; " +
|
406
393
|
"modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\";\r\n" +
|
407
394
|
"Content-Description: a complete map of the human genome\r\n"
|
408
395
|
params["files"][:name].must_equal "files"
|
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.0.9
|
4
|
+
version: 2.0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -260,7 +260,7 @@ homepage: https://rack.github.io/
|
|
260
260
|
licenses:
|
261
261
|
- MIT
|
262
262
|
metadata: {}
|
263
|
-
post_install_message:
|
263
|
+
post_install_message:
|
264
264
|
rdoc_options: []
|
265
265
|
require_paths:
|
266
266
|
- lib
|
@@ -275,8 +275,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
275
|
- !ruby/object:Gem::Version
|
276
276
|
version: '0'
|
277
277
|
requirements: []
|
278
|
-
rubygems_version: 3.1.
|
279
|
-
signing_key:
|
278
|
+
rubygems_version: 3.1.6
|
279
|
+
signing_key:
|
280
280
|
specification_version: 4
|
281
281
|
summary: a modular Ruby webserver interface
|
282
282
|
test_files:
|