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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b0768103afcff14e04b93b0f4d359289b26b21d2ac7c80a42a31d74c0467e23
4
- data.tar.gz: 84164353b9192f85a1ee40813ce9402dfca3f4850704718c6b103a3f062bc813
3
+ metadata.gz: bc237005e0685c87558593892557c95cd2b19a69344a5e7730861c4737710068
4
+ data.tar.gz: c6f06fabfb75b648b39013635615bb0c234b46e06bb21ee0d34fa984bc8a4327
5
5
  SHA512:
6
- metadata.gz: fe9cdddbc606c1898db93ab17308de607d0ac9f93d6cf0554e444eea18901d144740718aedfe37b6a9353dae5169152315c00a2b971394fa2d6785ae0ad82203
7
- data.tar.gz: e06d452659054f852edd963fb9ec776e450526f7918dedb937298b4f0ca938eeb047901d3c48c463a5ce1291070221dda1602cf96b042603c4e531cc6873dcbd
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
- <a href="https://tools.ietf.org/html/rfc3875#section-4.1.18">
64
- RFC3875 section 4.1.18</a> for
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
- store(key, value) (aliased as []=);
105
- fetch(key, default = nil) (aliased as []);
106
- delete(key);
107
- clear;
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)
@@ -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 BROKEN_QUOTED, BROKEN_UNQUOTED
305
+ when BROKEN
306
306
  filename = $1
307
+ filename = $1 if filename =~ /^"(.*)"$/
307
308
  end
308
309
 
309
310
  return unless filename
@@ -14,13 +14,12 @@ module Rack
14
14
  TOKEN = /[^\s()<>,;:\\"\/\[\]?=]+/
15
15
  CONDISP = /Content-Disposition:\s*#{TOKEN}\s*/i
16
16
  VALUE = /"(?:\\"|[^"])*"|#{TOKEN}/
17
- BROKEN_QUOTED = /^#{CONDISP}.*;\sfilename="(.*?)"(?:\s*$|\s*;\s*#{TOKEN}=)/i
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:.*\s+name=(#{VALUE})/ni
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{[^ \t\v\n\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 unless range_spec =~ /(\d*)-(\d*)/
369
- r0,r1 = $1, $2
370
- if r0.empty?
371
- return nil if r1.empty?
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.empty?
379
+ if r1.nil?
379
380
  r1 = size - 1
380
381
  else
381
382
  r1 = r1.to_i
data/lib/rack.rb CHANGED
@@ -18,7 +18,7 @@ module Rack
18
18
  VERSION.join(".")
19
19
  end
20
20
 
21
- RELEASE = "2.0.9"
21
+ RELEASE = "2.0.9.2"
22
22
 
23
23
  # Return the Rack release as a dotted string.
24
24
  def self.release
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
@@ -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).
@@ -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=\"\"human\" genome.jpeg\"; " +
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: 2020-02-08 00:00:00.000000000 Z
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.2
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: