rack 2.2.9 → 2.2.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 +40 -1
- data/README.rdoc +27 -0
- data/lib/rack/auth/basic.rb +1 -2
- data/lib/rack/auth/digest/nonce.rb +2 -3
- data/lib/rack/common_logger.rb +3 -2
- data/lib/rack/mock.rb +32 -3
- data/lib/rack/query_parser.rb +53 -10
- data/lib/rack/sendfile.rb +1 -1
- data/lib/rack/session/cookie.rb +2 -3
- data/lib/rack/session/pool.rb +6 -1
- data/lib/rack/static.rb +2 -1
- data/lib/rack/utils.rb +4 -3
- data/lib/rack/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d9e23c788790ba55d06e8e582e3b500110f79196afad3aad88d2212d97a89bd
|
4
|
+
data.tar.gz: 34fb7a71dc5f3ac49e9057ae8859abaea7a519f1db660cf47a8b1bb18a302186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db69d179f624e29992d49360251a9693c24e2d5fa390db37b01fe2b33b9d200bcbb971434fda3e8c4b2e9920769330c89f16579f8bfe70f962ee299190925aa2
|
7
|
+
data.tar.gz: 5b5a6511914abc1eec5b5c7943ea3a7374fc6c7305258d2e62993b4b7217151eccd366bd38dba21082c12e2f4a288d353a53f50aa5b643d7bc8b7d580627b3e4
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,42 @@
|
|
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
|
-
##
|
5
|
+
## [2.2.16] - 2025-05-22
|
6
|
+
|
7
|
+
- Fix incorrect backport of optional `CGI::Cookie` support. ([#2335](https://github.com/rack/rack/pull/2335), [@jeremyevans])
|
8
|
+
|
9
|
+
## [2.2.15] - 2025-05-18
|
10
|
+
|
11
|
+
- Optional support for `CGI::Cookie` if not available. ([#2327](https://github.com/rack/rack/pull/2327), [#2333](https://github.com/rack/rack/pull/2333), [@earlopain])
|
12
|
+
|
13
|
+
## [2.2.14] - 2025-05-06
|
14
|
+
|
15
|
+
### Security
|
16
|
+
|
17
|
+
- [CVE-2025-32441](https://github.com/rack/rack/security/advisories/GHSA-vpfw-47h7-xj4g) Rack session can be restored after deletion.
|
18
|
+
- [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.
|
19
|
+
|
20
|
+
## [2.2.13] - 2025-03-11
|
21
|
+
|
22
|
+
### Security
|
23
|
+
|
24
|
+
- [CVE-2025-27610](https://github.com/rack/rack/security/advisories/GHSA-7wqh-767x-r66v) Local file inclusion in `Rack::Static`.
|
25
|
+
|
26
|
+
## [2.2.12] - 2025-03-04
|
27
|
+
|
28
|
+
### Security
|
29
|
+
|
30
|
+
- [CVE-2025-27111](https://github.com/rack/rack/security/advisories/GHSA-8cgq-6mh2-7j6v) Possible Log Injection in `Rack::Sendfile`.
|
31
|
+
|
32
|
+
## [2.2.11] - 2025-02-12
|
33
|
+
|
34
|
+
### Security
|
35
|
+
|
36
|
+
- [CVE-2025-25184](https://github.com/rack/rack/security/advisories/GHSA-7g2v-jj9q-g3rg) Possible Log Injection in `Rack::CommonLogger`.
|
37
|
+
|
38
|
+
## [2.2.10] - 2024-10-14
|
39
|
+
|
40
|
+
- Fix compatibility issues with Ruby v3.4.0. ([#2248](https://github.com/rack/rack/pull/2248), [@byroot](https://github.com/byroot))
|
6
41
|
|
7
42
|
## [2.2.9] - 2023-03-21
|
8
43
|
|
@@ -750,3 +785,7 @@ Items below this line are from the previously maintained HISTORY.md and NEWS.md
|
|
750
785
|
- Removed Rails adapter, was too alpha.
|
751
786
|
|
752
787
|
## [0.1] 2007-03-03
|
788
|
+
|
789
|
+
[@ioquatix]: https://github.com/ioquatix "Samuel Williams"
|
790
|
+
[@jeremyevans]: https://github.com/jeremyevans "Jeremy Evans"
|
791
|
+
[@earlopain]: https://github.com/earlopain "Earlopain"
|
data/README.rdoc
CHANGED
@@ -179,6 +179,33 @@ e.g:
|
|
179
179
|
|
180
180
|
Rack::Utils.key_space_limit = 128
|
181
181
|
|
182
|
+
=== `RACK_QUERY_PARSER_BYTESIZE_LIMIT`
|
183
|
+
|
184
|
+
This environment variable sets the default for the maximum query string bytesize
|
185
|
+
that `Rack::QueryParser` will attempt to parse. Attempts to use a query string
|
186
|
+
that exceeds this number of bytes will result in a
|
187
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
188
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
189
|
+
|
190
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
191
|
+
the `bytesize_limit` keyword argument when creating the `Rack::QueryParser`.
|
192
|
+
|
193
|
+
=== `RACK_QUERY_PARSER_PARAMS_LIMIT`
|
194
|
+
|
195
|
+
This environment variable sets the default for the maximum number of query
|
196
|
+
parameters that `Rack::QueryParser` will attempt to parse. Attempts to use a
|
197
|
+
query string with more than this many query parameters will result in a
|
198
|
+
`Rack::QueryParser::QueryLimitError` exception. If this enviroment variable is
|
199
|
+
provided, it must be an integer, or `Rack::QueryParser` will raise an exception.
|
200
|
+
|
201
|
+
The default limit can be overridden on a per-`Rack::QueryParser` basis using
|
202
|
+
the `params_limit` keyword argument when creating the `Rack::QueryParser`.
|
203
|
+
|
204
|
+
This is implemented by counting the number of parameter separators in the
|
205
|
+
query string, before attempting parsing, so if the same parameter key is
|
206
|
+
used multiple times in the query, each counts as a separate parameter for
|
207
|
+
this check.
|
208
|
+
|
182
209
|
=== key_space_limit
|
183
210
|
|
184
211
|
The default number of bytes to allow all parameters keys in a given parameter hash to take up.
|
data/lib/rack/auth/basic.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require_relative 'abstract/handler'
|
4
4
|
require_relative 'abstract/request'
|
5
|
-
require 'base64'
|
6
5
|
|
7
6
|
module Rack
|
8
7
|
module Auth
|
@@ -48,7 +47,7 @@ module Rack
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def credentials
|
51
|
-
@credentials ||=
|
50
|
+
@credentials ||= params.unpack("m").first.split(':', 2)
|
52
51
|
end
|
53
52
|
|
54
53
|
def username
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'digest/md5'
|
4
|
-
require 'base64'
|
5
4
|
|
6
5
|
module Rack
|
7
6
|
module Auth
|
@@ -21,7 +20,7 @@ module Rack
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def self.parse(string)
|
24
|
-
new(*
|
23
|
+
new(*string.unpack("m").first.split(' ', 2))
|
25
24
|
end
|
26
25
|
|
27
26
|
def initialize(timestamp = Time.now, given_digest = nil)
|
@@ -29,7 +28,7 @@ module Rack
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def to_s
|
32
|
-
|
31
|
+
["#{@timestamp} #{digest}"].pack("m").strip
|
33
32
|
end
|
34
33
|
|
35
34
|
def digest
|
data/lib/rack/common_logger.rb
CHANGED
@@ -15,7 +15,7 @@ module Rack
|
|
15
15
|
# The actual format is slightly different than the above due to the
|
16
16
|
# separation of SCRIPT_NAME and PATH_INFO, and because the elapsed
|
17
17
|
# time in seconds is included at the end.
|
18
|
-
FORMAT = %{%s - %s [%s] "%s %s%s%s %s" %d %s %0.4f
|
18
|
+
FORMAT = %{%s - %s [%s] "%s %s%s%s %s" %d %s %0.4f }
|
19
19
|
|
20
20
|
# +logger+ can be any object that supports the +write+ or +<<+ methods,
|
21
21
|
# which includes the standard library Logger. These methods are called
|
@@ -60,7 +60,8 @@ module Rack
|
|
60
60
|
length,
|
61
61
|
Utils.clock_time - began_at ]
|
62
62
|
|
63
|
-
msg.gsub!(/[^[:print:]
|
63
|
+
msg.gsub!(/[^[:print:]]/) { |c| sprintf("\\x%x", c.ord) }
|
64
|
+
msg[-1] = "\n"
|
64
65
|
|
65
66
|
logger = @logger || env[RACK_ERRORS]
|
66
67
|
|
data/lib/rack/mock.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'uri'
|
4
4
|
require 'stringio'
|
5
5
|
require_relative '../rack'
|
6
|
-
require 'cgi/cookie'
|
7
6
|
|
8
7
|
module Rack
|
9
8
|
# Rack::MockRequest helps testing your Rack application without
|
@@ -171,6 +170,36 @@ module Rack
|
|
171
170
|
# MockRequest.
|
172
171
|
|
173
172
|
class MockResponse < Rack::Response
|
173
|
+
begin
|
174
|
+
# Recent versions of the CGI gem may not provide `CGI::Cookie`.
|
175
|
+
require 'cgi/cookie'
|
176
|
+
Cookie = CGI::Cookie
|
177
|
+
rescue LoadError
|
178
|
+
class Cookie
|
179
|
+
attr_reader :name, :value, :path, :domain, :expires, :secure
|
180
|
+
|
181
|
+
def initialize(args)
|
182
|
+
@name = args["name"]
|
183
|
+
@value = args["value"]
|
184
|
+
@path = args["path"]
|
185
|
+
@domain = args["domain"]
|
186
|
+
@expires = args["expires"]
|
187
|
+
@secure = args["secure"]
|
188
|
+
end
|
189
|
+
|
190
|
+
def method_missing(method_name, *args, &block)
|
191
|
+
@value.send(method_name, *args, &block)
|
192
|
+
end
|
193
|
+
# :nocov:
|
194
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
195
|
+
# :nocov:
|
196
|
+
|
197
|
+
def respond_to_missing?(method_name, include_all = false)
|
198
|
+
@value.respond_to?(method_name, include_all) || super
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
174
203
|
class << self
|
175
204
|
alias [] new
|
176
205
|
end
|
@@ -236,7 +265,7 @@ module Rack
|
|
236
265
|
set_cookie_header.split("\n").each do |cookie|
|
237
266
|
cookie_name, cookie_filling = cookie.split('=', 2)
|
238
267
|
cookie_attributes = identify_cookie_attributes cookie_filling
|
239
|
-
parsed_cookie =
|
268
|
+
parsed_cookie = Cookie.new(
|
240
269
|
'name' => cookie_name.strip,
|
241
270
|
'value' => cookie_attributes.fetch('value'),
|
242
271
|
'path' => cookie_attributes.fetch('path', nil),
|
@@ -253,7 +282,7 @@ module Rack
|
|
253
282
|
def identify_cookie_attributes(cookie_filling)
|
254
283
|
cookie_bits = cookie_filling.split(';')
|
255
284
|
cookie_attributes = Hash.new
|
256
|
-
cookie_attributes.store('value', cookie_bits[0].strip)
|
285
|
+
cookie_attributes.store('value', Array(cookie_bits[0].strip))
|
257
286
|
cookie_bits.each do |bit|
|
258
287
|
if bit.include? '='
|
259
288
|
cookie_attribute, attribute_value = bit.split('=')
|
data/lib/rack/query_parser.rb
CHANGED
@@ -16,20 +16,47 @@ 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, param_depth_limit)
|
24
|
-
new
|
30
|
+
def self.make_default(key_space_limit, param_depth_limit, **options)
|
31
|
+
new(Params, key_space_limit, param_depth_limit, **options)
|
25
32
|
end
|
26
33
|
|
27
34
|
attr_reader :key_space_limit, :param_depth_limit
|
28
35
|
|
29
|
-
|
36
|
+
env_int = lambda do |key, val|
|
37
|
+
if str_val = ENV[key]
|
38
|
+
begin
|
39
|
+
val = Integer(str_val, 10)
|
40
|
+
rescue ArgumentError
|
41
|
+
raise ArgumentError, "non-integer value provided for environment variable #{key}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
val
|
46
|
+
end
|
47
|
+
|
48
|
+
BYTESIZE_LIMIT = env_int.call("RACK_QUERY_PARSER_BYTESIZE_LIMIT", 4194304)
|
49
|
+
private_constant :BYTESIZE_LIMIT
|
50
|
+
|
51
|
+
PARAMS_LIMIT = env_int.call("RACK_QUERY_PARSER_PARAMS_LIMIT", 4096)
|
52
|
+
private_constant :PARAMS_LIMIT
|
53
|
+
|
54
|
+
def initialize(params_class, key_space_limit, param_depth_limit, bytesize_limit: BYTESIZE_LIMIT, params_limit: PARAMS_LIMIT)
|
30
55
|
@params_class = params_class
|
31
56
|
@key_space_limit = key_space_limit
|
32
57
|
@param_depth_limit = param_depth_limit
|
58
|
+
@bytesize_limit = bytesize_limit
|
59
|
+
@params_limit = params_limit
|
33
60
|
end
|
34
61
|
|
35
62
|
# Stolen from Mongrel, with some small modifications:
|
@@ -42,7 +69,7 @@ module Rack
|
|
42
69
|
|
43
70
|
params = make_params
|
44
71
|
|
45
|
-
(qs
|
72
|
+
check_query_string(qs, d).split(d ? (COMMON_SEP[d] || /[#{d}] */n) : DEFAULT_SEP).each do |p|
|
46
73
|
next if p.empty?
|
47
74
|
k, v = p.split('=', 2).map!(&unescaper)
|
48
75
|
|
@@ -69,7 +96,7 @@ module Rack
|
|
69
96
|
params = make_params
|
70
97
|
|
71
98
|
unless qs.nil? || qs.empty?
|
72
|
-
(qs
|
99
|
+
check_query_string(qs, d).split(d ? (COMMON_SEP[d] || /[#{d}] */n) : DEFAULT_SEP).each do |p|
|
73
100
|
k, v = p.split('=', 2).map! { |s| unescape(s) }
|
74
101
|
|
75
102
|
normalize_params(params, k, v, param_depth_limit)
|
@@ -155,8 +182,24 @@ module Rack
|
|
155
182
|
true
|
156
183
|
end
|
157
184
|
|
158
|
-
def
|
159
|
-
|
185
|
+
def check_query_string(qs, sep)
|
186
|
+
if qs
|
187
|
+
if qs.bytesize > @bytesize_limit
|
188
|
+
raise QueryLimitError, "total query size (#{qs.bytesize}) exceeds limit (#{@bytesize_limit})"
|
189
|
+
end
|
190
|
+
|
191
|
+
if (param_count = qs.count(sep.is_a?(String) ? sep : '&')) >= @params_limit
|
192
|
+
raise QueryLimitError, "total number of query parameters (#{param_count+1}) exceeds limit (#{@params_limit})"
|
193
|
+
end
|
194
|
+
|
195
|
+
qs
|
196
|
+
else
|
197
|
+
''
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def unescape(string)
|
202
|
+
Utils.unescape(string)
|
160
203
|
end
|
161
204
|
|
162
205
|
class Params
|
data/lib/rack/sendfile.rb
CHANGED
data/lib/rack/session/cookie.rb
CHANGED
@@ -4,7 +4,6 @@ require 'openssl'
|
|
4
4
|
require 'zlib'
|
5
5
|
require_relative 'abstract/id'
|
6
6
|
require 'json'
|
7
|
-
require 'base64'
|
8
7
|
require 'delegate'
|
9
8
|
|
10
9
|
module Rack
|
@@ -51,11 +50,11 @@ module Rack
|
|
51
50
|
# Encode session cookies as Base64
|
52
51
|
class Base64
|
53
52
|
def encode(str)
|
54
|
-
|
53
|
+
[str].pack("m0")
|
55
54
|
end
|
56
55
|
|
57
56
|
def decode(str)
|
58
|
-
|
57
|
+
str.unpack("m").first
|
59
58
|
end
|
60
59
|
|
61
60
|
# Encode session cookies as Marshaled Base64 data
|
data/lib/rack/session/pool.rb
CHANGED
@@ -55,6 +55,7 @@ module Rack
|
|
55
55
|
|
56
56
|
def write_session(req, session_id, new_session, options)
|
57
57
|
with_lock(req) do
|
58
|
+
return false unless get_session_with_fallback(session_id)
|
58
59
|
@pool.store session_id.private_id, new_session
|
59
60
|
session_id
|
60
61
|
end
|
@@ -64,7 +65,11 @@ module Rack
|
|
64
65
|
with_lock(req) do
|
65
66
|
@pool.delete(session_id.public_id)
|
66
67
|
@pool.delete(session_id.private_id)
|
67
|
-
|
68
|
+
unless options[:drop]
|
69
|
+
sid = generate_sid
|
70
|
+
@pool.store(sid.private_id, {})
|
71
|
+
sid
|
72
|
+
end
|
68
73
|
end
|
69
74
|
end
|
70
75
|
|
data/lib/rack/static.rb
CHANGED
@@ -122,8 +122,9 @@ module Rack
|
|
122
122
|
|
123
123
|
def call(env)
|
124
124
|
path = env[PATH_INFO]
|
125
|
+
actual_path = Utils.clean_path_info(Utils.unescape_path(path))
|
125
126
|
|
126
|
-
if can_serve(
|
127
|
+
if can_serve(actual_path)
|
127
128
|
if overwrite_file_path(path)
|
128
129
|
env[PATH_INFO] = (add_index_root?(path) ? path + @index : @urls[path])
|
129
130
|
elsif @gzip && env['HTTP_ACCEPT_ENCODING'] && /\bgzip\b/.match?(env['HTTP_ACCEPT_ENCODING'])
|
data/lib/rack/utils.rb
CHANGED
@@ -24,6 +24,7 @@ module Rack
|
|
24
24
|
|
25
25
|
RFC2822_DAY_NAME = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]
|
26
26
|
RFC2822_MONTH_NAME = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
|
27
|
+
RFC2396_PARSER = defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::RFC2396_Parser.new
|
27
28
|
|
28
29
|
class << self
|
29
30
|
attr_accessor :default_query_parser
|
@@ -42,13 +43,13 @@ module Rack
|
|
42
43
|
# Like URI escaping, but with %20 instead of +. Strictly speaking this is
|
43
44
|
# true URI escaping.
|
44
45
|
def escape_path(s)
|
45
|
-
|
46
|
+
RFC2396_PARSER.escape s
|
46
47
|
end
|
47
48
|
|
48
49
|
# Unescapes the **path** component of a URI. See Rack::Utils.unescape for
|
49
50
|
# unescaping query parameters or form components.
|
50
51
|
def unescape_path(s)
|
51
|
-
|
52
|
+
RFC2396_PARSER.unescape s
|
52
53
|
end
|
53
54
|
|
54
55
|
# Unescapes a URI escaped string with +encoding+. +encoding+ will be the
|
@@ -381,7 +382,7 @@ module Rack
|
|
381
382
|
ranges << (r0..r1) if r0 <= r1
|
382
383
|
end
|
383
384
|
|
384
|
-
return [] if ranges.map(&:size).
|
385
|
+
return [] if ranges.map(&:size).inject(0, :+) > size
|
385
386
|
|
386
387
|
ranges
|
387
388
|
end
|
data/lib/rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leah Neukirchen
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: minitest
|
@@ -169,7 +168,6 @@ metadata:
|
|
169
168
|
changelog_uri: https://github.com/rack/rack/blob/master/CHANGELOG.md
|
170
169
|
documentation_uri: https://rubydoc.info/github/rack/rack
|
171
170
|
source_code_uri: https://github.com/rack/rack
|
172
|
-
post_install_message:
|
173
171
|
rdoc_options: []
|
174
172
|
require_paths:
|
175
173
|
- lib
|
@@ -184,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
182
|
- !ruby/object:Gem::Version
|
185
183
|
version: '0'
|
186
184
|
requirements: []
|
187
|
-
rubygems_version: 3.
|
188
|
-
signing_key:
|
185
|
+
rubygems_version: 3.6.2
|
189
186
|
specification_version: 4
|
190
187
|
summary: A modular Ruby webserver interface.
|
191
188
|
test_files: []
|