puma 6.4.2 → 6.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4eec1c88853ffbaadba238d829879c8a47f6a553ed6ce97fcfdc20f70e9cb16
4
- data.tar.gz: 4ecd30023954ae7bc18d89e28875371687b54c41a3bd3e62b396039614089e38
3
+ metadata.gz: e3cedcd91a2366db019124505992d71ff47717760e4c3f37d9e7ae681c45bbdb
4
+ data.tar.gz: 6ad4999caa3542103c8bb2d3a1bd49202e1c8cf71d409ee96e13d23c169f0d32
5
5
  SHA512:
6
- metadata.gz: 98451682f4e6bc79dc1336f7ee4d7b702b13b0c9cd0f99e4a3aeca37c96ea096401c43cda5402ec9a4af25fc4f5d7d15da8d6157ad957f3128586e022cabc263
7
- data.tar.gz: c5e6aaf5d405e57a6b47df3be3c52c5b006c1160b5c90d2a549d25e731ea44b6ad1828ceffb1e4791ceea66eef0f07718dbee76b17a1db272a4ed79a6ff3ff53
6
+ metadata.gz: a69d8cec268d2e35444609f2e69e737e47eb1dc30dd2b3a387e5f3e84bc4905d8241ae3b158f39259a9930ca093fff17db927039aaef54583e6c1a30d8b12a61
7
+ data.tar.gz: f03e924b53e70ac876c786031b23775e4b91aa5d009d5f40fb9a0c241093a238c4b78a99fc062c8495e634b2cfc8561626e9aaf0888c203d40cf84f9d14c539b
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 6.4.3 / 2024-09-19
2
+
3
+ * Security
4
+ * Discards any headers using underscores if the non-underscore version also exists. Without this, an attacker could overwrite values set by intermediate proxies (e.g. X-Forwarded-For). ([CVE-2024-45614](https://github.com/puma/puma/security/advisories/GHSA-9hf4-67fc-4vf4)/GHSA-9hf4-67fc-4vf4)
5
+
1
6
  ## 6.4.2 / 2024-01-08
2
7
 
3
8
  * Security
@@ -173,6 +178,11 @@
173
178
  * Ruby 3.2 will have native IO#wait_* methods, don't require io/wait ([#2903])
174
179
  * Various internal API refactorings ([#2942], [#2921], [#2922], [#2955])
175
180
 
181
+ ## 5.6.9 / 2024-09-19
182
+
183
+ * Security
184
+ * Discards any headers using underscores if the non-underscore version also exists. Without this, an attacker could overwrite values set by intermediate proxies (e.g. X-Forwarded-For). ([CVE-2024-45614](https://github.com/puma/puma/security/advisories/GHSA-9hf4-67fc-4vf4)/GHSA-9hf4-67fc-4vf4)
185
+
176
186
  ## 5.6.8 / 2024-01-08
177
187
 
178
188
  * Security
@@ -99,6 +99,8 @@ public class Http11 extends RubyObject {
99
99
  int bite = b.get(i) & 0xFF;
100
100
  if(bite == '-') {
101
101
  b.set(i, (byte)'_');
102
+ } else if(bite == '_') {
103
+ b.set(i, (byte)',');
102
104
  } else {
103
105
  b.set(i, (byte)Character.toUpperCase(bite));
104
106
  }
data/lib/puma/const.rb CHANGED
@@ -100,7 +100,7 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "6.4.2"
103
+ PUMA_VERSION = VERSION = "6.4.3"
104
104
  CODE_NAME = "The Eagle of Durango"
105
105
 
106
106
  PUMA_SERVER_STRING = ["puma", PUMA_VERSION, CODE_NAME].join(" ").freeze
@@ -281,6 +281,14 @@ module Puma
281
281
  # header values can contain HTAB?
282
282
  ILLEGAL_HEADER_VALUE_REGEX = /[\x00-\x08\x0A-\x1F]/.freeze
283
283
 
284
+ # The keys of headers that should not be convert to underscore
285
+ # normalized versions. These headers are ignored at the request reading layer,
286
+ # but if we normalize them after reading, it's just confusing for the application.
287
+ UNMASKABLE_HEADERS = {
288
+ "HTTP_TRANSFER,ENCODING" => true,
289
+ "HTTP_CONTENT,LENGTH" => true,
290
+ }
291
+
284
292
  # Banned keys of response header
285
293
  BANNED_HEADER_KEY = /\A(rack\.|status\z)/.freeze
286
294
 
data/lib/puma/request.rb CHANGED
@@ -495,6 +495,11 @@ module Puma
495
495
  # compatibility, we'll convert them back. This code is written to
496
496
  # avoid allocation in the common case (ie there are no headers
497
497
  # with `,` in their names), that's why it has the extra conditionals.
498
+ #
499
+ # @note If a normalized version of a `,` header already exists, we ignore
500
+ # the `,` version. This prevents clobbering headers managed by proxies
501
+ # but not by clients (Like X-Forwarded-For).
502
+ #
498
503
  # @param env [Hash] see Puma::Client#env, from request, modifies in place
499
504
  # @version 5.0.3
500
505
  #
@@ -503,23 +508,31 @@ module Puma
503
508
  to_add = nil
504
509
 
505
510
  env.each do |k,v|
506
- if k.start_with?("HTTP_") && k.include?(",") && k != "HTTP_TRANSFER,ENCODING"
511
+ if k.start_with?("HTTP_") && k.include?(",") && !UNMASKABLE_HEADERS.key?(k)
507
512
  if to_delete
508
513
  to_delete << k
509
514
  else
510
515
  to_delete = [k]
511
516
  end
512
517
 
518
+ new_k = k.tr(",", "_")
519
+ if env.key?(new_k)
520
+ next
521
+ end
522
+
513
523
  unless to_add
514
524
  to_add = {}
515
525
  end
516
526
 
517
- to_add[k.tr(",", "_")] = v
527
+ to_add[new_k] = v
518
528
  end
519
529
  end
520
530
 
521
- if to_delete
531
+ if to_delete # rubocop:disable Style/SafeNavigation
522
532
  to_delete.each { |k| env.delete(k) }
533
+ end
534
+
535
+ if to_add
523
536
  env.merge! to_add
524
537
  end
525
538
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.2
4
+ version: 6.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0'
147
147
  requirements: []
148
- rubygems_version: 3.5.3
148
+ rubygems_version: 3.5.16
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server for