actionpack 6.1.3.1 → 6.1.4.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fec2460bf8c4c27a3bdd3984ebbfa8eb14463adfc131a961ee4708034883ae7
4
- data.tar.gz: a242f25080d9c07818a21e7135dad264ad3e01fd353cdf9f5c130fcf588a8efc
3
+ metadata.gz: 5825f14a026c24d4ddea1860c90e32db978e31f6bec3fe2e986abb3fce8e946a
4
+ data.tar.gz: 2e02124fc9c555eac945ba0abd0db217281fdb5581adae592d656b43c65c7c48
5
5
  SHA512:
6
- metadata.gz: 5b3925db39ef6d34e3d2b3ae5732499892fcaf91deaedf24483f985bb80bb74c92a6d4e8707b5cd966dbf4466e6b177fee2964ef78006ec523d9243bf07eba47
7
- data.tar.gz: a14bbb566f5253a87f1cbbbb394d4f8dd546b136bf963a8ca98011b33ae85191b1cc611c3edbd31a26bfe36a9d098deb22214b7b19a3ffef3713c69b19a3f80d
6
+ metadata.gz: d0af835716768a29451414527cf754158c113216f76c22de30c30afeedf2efbfe3b2621af1a1ac9b2ddeff94c81682a85ad67e78538beb4ca576be5178791d01
7
+ data.tar.gz: f8e6917a5fd4dd3962ef44b538c321029094de33333942ba0b5dbca517ce637b31b27cee76c1281af69fd32c4449383834314e9e56e0021d43d51c2cf67524aa
data/CHANGELOG.md CHANGED
@@ -1,3 +1,74 @@
1
+ ## Rails 6.1.4.2 (December 14, 2021) ##
2
+
3
+ * Fix X_FORWARDED_HOST protection. [CVE-2021-44528]
4
+
5
+ ## Rails 6.1.4.1 (August 19, 2021) ##
6
+
7
+ * [CVE-2021-22942] Fix possible open redirect in Host Authorization middleware.
8
+
9
+ Specially crafted "X-Forwarded-Host" headers in combination with certain
10
+ "allowed host" formats can cause the Host Authorization middleware in Action
11
+ Pack to redirect users to a malicious website.
12
+
13
+ ## Rails 6.1.4 (June 24, 2021) ##
14
+
15
+ * Ignore file fixtures on `db:fixtures:load`
16
+
17
+ *Kevin Sjöberg*
18
+
19
+ * Fix ActionController::Live controller test deadlocks by removing the body buffer size limit for tests.
20
+
21
+ *Dylan Thacker-Smith*
22
+
23
+ * Correctly place optional path parameter booleans.
24
+
25
+ Previously, if you specify a url parameter that is part of the path as false it would include that part
26
+ of the path as parameter for example:
27
+
28
+ ```
29
+ get "(/optional/:optional_id)/things" => "foo#foo", as: :things
30
+ things_path(optional_id: false) # => /things?optional_id=false
31
+ ```
32
+
33
+ After this change, true and false will be treated the same when used as optional path parameters. Meaning now:
34
+
35
+ ```
36
+ get '(this/:my_bool)/that' as: :that
37
+
38
+ that_path(my_bool: true) # => `/this/true/that`
39
+ that_path(my_bool: false) # => `/this/false/that`
40
+ ```
41
+
42
+ *Adam Hess*
43
+
44
+ * Add support for 'private, no-store' Cache-Control headers.
45
+
46
+ Previously, 'no-store' was exclusive; no other directives could be specified.
47
+
48
+ *Alex Smith*
49
+
50
+
51
+ ## Rails 6.1.3.2 (May 05, 2021) ##
52
+
53
+ * Prevent open redirects by correctly escaping the host allow list
54
+ CVE-2021-22903
55
+
56
+ * Prevent catastrophic backtracking during mime parsing
57
+ CVE-2021-22902
58
+
59
+ * Prevent regex DoS in HTTP token authentication
60
+ CVE-2021-22904
61
+
62
+ * Prevent string polymorphic route arguments.
63
+
64
+ `url_for` supports building polymorphic URLs via an array
65
+ of arguments (usually symbols and records). If a developer passes a
66
+ user input array, strings can result in unwanted route helper calls.
67
+
68
+ CVE-2021-22885
69
+
70
+ *Gannon McGibbon*
71
+
1
72
  ## Rails 6.1.3.1 (March 26, 2021) ##
2
73
 
3
74
  * No changes.
@@ -44,7 +44,7 @@ module ActionController
44
44
  # template digest from the ETag.
45
45
  def pick_template_for_etag(options)
46
46
  unless options[:template] == false
47
- options[:template] || "#{controller_path}/#{action_name}"
47
+ options[:template] || lookup_context.find_all(action_name, _prefixes).first&.virtual_path
48
48
  end
49
49
  end
50
50
 
@@ -407,7 +407,7 @@ module ActionController
407
407
  module Token
408
408
  TOKEN_KEY = "token="
409
409
  TOKEN_REGEX = /^(Token|Bearer)\s+/
410
- AUTHN_PAIR_DELIMITERS = /(?:,|;|\t+)/
410
+ AUTHN_PAIR_DELIMITERS = /(?:,|;|\t)/
411
411
  extend self
412
412
 
413
413
  module ControllerMethods
@@ -127,6 +127,11 @@ module ActionController
127
127
  class Buffer < ActionDispatch::Response::Buffer #:nodoc:
128
128
  include MonitorMixin
129
129
 
130
+ class << self
131
+ attr_accessor :queue_size
132
+ end
133
+ @queue_size = 10
134
+
130
135
  # Ignore that the client has disconnected.
131
136
  #
132
137
  # If this value is `true`, calling `write` after the client
@@ -136,7 +141,7 @@ module ActionController
136
141
  attr_accessor :ignore_disconnect
137
142
 
138
143
  def initialize(response)
139
- super(response, SizedQueue.new(10))
144
+ super(response, build_queue(self.class.queue_size))
140
145
  @error_callback = lambda { true }
141
146
  @cv = new_cond
142
147
  @aborted = false
@@ -214,6 +219,10 @@ module ActionController
214
219
  yield str
215
220
  end
216
221
  end
222
+
223
+ def build_queue(queue_size)
224
+ queue_size ? SizedQueue.new(queue_size) : Queue.new
225
+ end
217
226
  end
218
227
 
219
228
  class Response < ActionDispatch::Response #:nodoc: all
@@ -281,7 +281,10 @@ module ActionController
281
281
  return false unless request.has_content_type?
282
282
 
283
283
  ref = request.content_mime_type.ref
284
+
284
285
  _wrapper_formats.include?(ref) && _wrapper_key && !request.parameters.key?(_wrapper_key)
286
+ rescue ActionDispatch::Http::Parameters::ParseError
287
+ false
285
288
  end
286
289
 
287
290
  def _perform_parameter_wrapping
@@ -295,8 +298,6 @@ module ActionController
295
298
 
296
299
  # This will display the wrapped hash in the log file.
297
300
  request.filtered_parameters.merge! wrapped_filtered_hash
298
- rescue ActionDispatch::Http::Parameters::ParseError
299
- # swallow parse error exception
300
301
  end
301
302
  end
302
303
  end
@@ -24,6 +24,9 @@ module ActionController
24
24
  def new_controller_thread # :nodoc:
25
25
  yield
26
26
  end
27
+
28
+ # Avoid a deadlock from the queue filling up
29
+ Buffer.queue_size = nil
27
30
  end
28
31
 
29
32
  # ActionController::TestCase will be deprecated and moved to a gem in the future.
@@ -195,31 +195,30 @@ module ActionDispatch
195
195
 
196
196
  control.merge! cache_control
197
197
 
198
+ options = []
199
+
198
200
  if control[:no_store]
199
- self._cache_control = NO_STORE
201
+ options << PRIVATE if control[:private]
202
+ options << NO_STORE
200
203
  elsif control[:no_cache]
201
- options = []
202
204
  options << PUBLIC if control[:public]
203
205
  options << NO_CACHE
204
206
  options.concat(control[:extras]) if control[:extras]
205
-
206
- self._cache_control = options.join(", ")
207
207
  else
208
208
  extras = control[:extras]
209
209
  max_age = control[:max_age]
210
210
  stale_while_revalidate = control[:stale_while_revalidate]
211
211
  stale_if_error = control[:stale_if_error]
212
212
 
213
- options = []
214
213
  options << "max-age=#{max_age.to_i}" if max_age
215
214
  options << (control[:public] ? PUBLIC : PRIVATE)
216
215
  options << MUST_REVALIDATE if control[:must_revalidate]
217
216
  options << "stale-while-revalidate=#{stale_while_revalidate.to_i}" if stale_while_revalidate
218
217
  options << "stale-if-error=#{stale_if_error.to_i}" if stale_if_error
219
218
  options.concat(extras) if extras
220
-
221
- self._cache_control = options.join(", ")
222
219
  end
220
+
221
+ self._cache_control = options.join(", ")
223
222
  end
224
223
  end
225
224
  end
@@ -229,7 +229,7 @@ module Mime
229
229
  MIME_PARAMETER_KEY = "[a-zA-Z0-9][a-zA-Z0-9#{Regexp.escape('!#$&-^_.+')}]{0,126}"
230
230
  MIME_PARAMETER_VALUE = "#{Regexp.escape('"')}?[a-zA-Z0-9][a-zA-Z0-9#{Regexp.escape('!#$&-^_.+')}]{0,126}#{Regexp.escape('"')}?"
231
231
  MIME_PARAMETER = "\s*\;\s*#{MIME_PARAMETER_KEY}(?:\=#{MIME_PARAMETER_VALUE})?"
232
- MIME_REGEXP = /\A(?:\*\/\*|#{MIME_NAME}\/(?:\*|#{MIME_NAME})(?:\s*#{MIME_PARAMETER}\s*)*)\z/
232
+ MIME_REGEXP = /\A(?:\*\/\*|#{MIME_NAME}\/(?:\*|#{MIME_NAME})(?>\s*#{MIME_PARAMETER}\s*)*)\z/
233
233
 
234
234
  class InvalidMimeType < StandardError; end
235
235
 
@@ -103,7 +103,7 @@ module ActionDispatch
103
103
  parameterized_parts = recall.merge(options)
104
104
 
105
105
  keys_to_keep = route.parts.reverse_each.drop_while { |part|
106
- !(options.key?(part) || route.scope_options.key?(part)) || (options[part] || recall[part]).nil?
106
+ !(options.key?(part) || route.scope_options.key?(part)) || (options[part].nil? && recall[part].nil?)
107
107
  } | route.required_parts
108
108
 
109
109
  parameterized_parts.delete_if do |bad_key, _|
@@ -118,7 +118,7 @@ module ActionDispatch
118
118
  end
119
119
  end
120
120
 
121
- parameterized_parts.keep_if { |_, v| v }
121
+ parameterized_parts.compact!
122
122
  parameterized_parts
123
123
  end
124
124
 
@@ -40,7 +40,7 @@ module ActionDispatch
40
40
  @parameters.each do |index|
41
41
  param = parts[index]
42
42
  value = hash[param.name]
43
- return "" unless value
43
+ return "" if value.nil?
44
44
  parts[index] = param.escape value
45
45
  end
46
46
 
@@ -51,9 +51,9 @@ module ActionDispatch
51
51
 
52
52
  def sanitize_string(host)
53
53
  if host.start_with?(".")
54
- /\A(.+\.)?#{Regexp.escape(host[1..-1])}\z/i
54
+ /\A([a-z0-9-]+\.)?#{Regexp.escape(host[1..-1])}\z/i
55
55
  else
56
- /\A#{host}\z/i
56
+ /\A#{Regexp.escape host}\z/i
57
57
  end
58
58
  end
59
59
  end
@@ -103,20 +103,10 @@ module ActionDispatch
103
103
 
104
104
  private
105
105
  def authorized?(request)
106
- valid_host = /
107
- \A
108
- (?<host>[a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])
109
- (:\d+)?
110
- \z
111
- /x
112
-
113
- origin_host = valid_host.match(
114
- request.get_header("HTTP_HOST").to_s.downcase)
115
- forwarded_host = valid_host.match(
116
- request.x_forwarded_host.to_s.split(/,\s?/).last)
117
-
118
- origin_host && @permissions.allows?(origin_host[:host]) && (
119
- forwarded_host.nil? || @permissions.allows?(forwarded_host[:host]))
106
+ origin_host = request.get_header("HTTP_HOST")
107
+ forwarded_host = request.x_forwarded_host&.split(/,\s?/)&.last
108
+
109
+ @permissions.allows?(origin_host) && (forwarded_host.blank? || @permissions.allows?(forwarded_host))
120
110
  end
121
111
 
122
112
  def excluded?(request)
@@ -6,6 +6,7 @@
6
6
  <%= @exception.message %>
7
7
  <% if defined?(ActiveStorage) && @exception.message.match?(%r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}}) %>
8
8
  To resolve this issue run: bin/rails active_storage:install
9
+ <% end %>
9
10
  <% if defined?(ActionMailbox) && @exception.message.match?(%r{#{ActionMailbox::InboundEmail.table_name}}) %>
10
11
  To resolve this issue run: bin/rails action_mailbox:install
11
12
  <% end %>
@@ -287,10 +287,12 @@ module ActionDispatch
287
287
 
288
288
  args = []
289
289
 
290
- route = record_list.map { |parent|
290
+ route = record_list.map do |parent|
291
291
  case parent
292
- when Symbol, String
292
+ when Symbol
293
293
  parent.to_s
294
+ when String
295
+ raise(ArgumentError, "Please use symbols for polymorphic route arguments.")
294
296
  when Class
295
297
  args << parent
296
298
  parent.model_name.singular_route_key
@@ -298,12 +300,14 @@ module ActionDispatch
298
300
  args << parent.to_model
299
301
  parent.to_model.model_name.singular_route_key
300
302
  end
301
- }
303
+ end
302
304
 
303
305
  route <<
304
306
  case record
305
- when Symbol, String
307
+ when Symbol
306
308
  record.to_s
309
+ when String
310
+ raise(ArgumentError, "Please use symbols for polymorphic route arguments.")
307
311
  when Class
308
312
  @key_strategy.call record.model_name
309
313
  else
@@ -9,8 +9,8 @@ module ActionPack
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
- TINY = 3
13
- PRE = "1"
12
+ TINY = 4
13
+ PRE = "2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.3.1
4
+ version: 6.1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.1.3.1
19
+ version: 6.1.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.1.3.1
26
+ version: 6.1.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 6.1.3.1
101
+ version: 6.1.4.2
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 6.1.3.1
108
+ version: 6.1.4.2
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 6.1.3.1
115
+ version: 6.1.4.2
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 6.1.3.1
122
+ version: 6.1.4.2
123
123
  description: Web apps on Rails. Simple, battle-tested conventions for building and
124
124
  testing MVC web applications. Works with any Rack-compatible server.
125
125
  email: david@loudthinking.com
@@ -309,11 +309,11 @@ licenses:
309
309
  - MIT
310
310
  metadata:
311
311
  bug_tracker_uri: https://github.com/rails/rails/issues
312
- changelog_uri: https://github.com/rails/rails/blob/v6.1.3.1/actionpack/CHANGELOG.md
313
- documentation_uri: https://api.rubyonrails.org/v6.1.3.1/
312
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.4.2/actionpack/CHANGELOG.md
313
+ documentation_uri: https://api.rubyonrails.org/v6.1.4.2/
314
314
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
315
- source_code_uri: https://github.com/rails/rails/tree/v6.1.3.1/actionpack
316
- post_install_message:
315
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.4.2/actionpack
316
+ post_install_message:
317
317
  rdoc_options: []
318
318
  require_paths:
319
319
  - lib
@@ -329,8 +329,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  version: '0'
330
330
  requirements:
331
331
  - none
332
- rubygems_version: 3.1.2
333
- signing_key:
332
+ rubygems_version: 3.2.15
333
+ signing_key:
334
334
  specification_version: 4
335
335
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).
336
336
  test_files: []