puma 4.3.0 → 4.3.3

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2ba02cb19976145aa1824079a79d468fad878ca58bdb902f60a58b184049714
4
- data.tar.gz: fcfa744db7db86e4acfbfb3d14659ec4aefa86ec249f6105ea7c54d97e361e97
3
+ metadata.gz: bd20b1ca1b6236f1b1677f9bc40f4ea8f980ae678e1f57e6b20987d2322f7f4a
4
+ data.tar.gz: bb416036092bb4657a4f30dda5c72dc6a9ff8dda391e41950f7ece18230a4a5f
5
5
  SHA512:
6
- metadata.gz: 875da8dd65d1c85f3912988c0b8b371fcfe1ef2cc99dbb9d4108c2141c2a0427a3db2cca684e82f5b955c564785d3e49f3723aeb64264d76cc4395ec7da2815c
7
- data.tar.gz: 7460c59d0ec3d2c1733fafd35a33c434385da60b70e325f6c85aeeb2ccdea25e07c2b16f7f08f7cc14cccdf44780d5d5f98b1581fb3565e3557dbfb844e4a332
6
+ metadata.gz: d6ce2871efeed834b717174a744ac45db359efd9969efb51b13a83f260d01def32d25fe3ac91a9a0f99483c054c89f4c40aaef988e2a7b46cb9cb54201200abc
7
+ data.tar.gz: c55618f49982d8c1a9161a4b8bce15878b75b960c9a28fb49c81d8934336c22023608082ba649414767d67a59436d580a12719660fa8710174dcb59823bb935d
data/History.md CHANGED
@@ -6,6 +6,23 @@
6
6
  * Bugfixes
7
7
  * Your bugfix goes here (#Github Number)
8
8
 
9
+
10
+ ## 4.3.3 and 3.12.4 / 2020-02-28
11
+ * Bugfixes
12
+ * Fix: Fixes a problem where we weren't splitting headers correctly on newlines (#2132)
13
+ * Security
14
+ * Fix: Prevent HTTP Response splitting via CR in early hints.
15
+
16
+ ## 4.3.2 and 3.12.3 / 2020-02-27
17
+
18
+ * Security
19
+ * Fix: Prevent HTTP Response splitting via CR/LF in header values. CVE-2020-5247.
20
+
21
+ ## 4.3.1 and 3.12.2 / 2019-12-05
22
+
23
+ * Security
24
+ * Fix: a poorly-behaved client could use keepalive requests to monopolize Puma's reactor and create a denial of service attack. CVE-2019-16770.
25
+
9
26
  ## 4.3.0 / 2019-11-07
10
27
 
11
28
  * Features
@@ -100,7 +100,7 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "4.3.0".freeze
103
+ PUMA_VERSION = VERSION = "4.3.3".freeze
104
104
  CODE_NAME = "Mysterious Traveller".freeze
105
105
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
106
106
 
@@ -118,6 +118,13 @@ module Puma
118
118
  # sending data back
119
119
  WRITE_TIMEOUT = 10
120
120
 
121
+ # How many requests to attempt inline before sending a client back to
122
+ # the reactor to be subject to normal ordering. The idea here is that
123
+ # we amortize the cost of going back to the reactor for a well behaved
124
+ # but very "greedy" client across 10 requests. This prevents a not
125
+ # well behaved client from monopolizing the thread forever.
126
+ MAX_FAST_INLINE = 10
127
+
121
128
  # The original URI requested by the client.
122
129
  REQUEST_URI= 'REQUEST_URI'.freeze
123
130
  REQUEST_PATH = 'REQUEST_PATH'.freeze
@@ -221,6 +228,7 @@ module Puma
221
228
  COLON = ": ".freeze
222
229
 
223
230
  NEWLINE = "\n".freeze
231
+ HTTP_INJECTION_REGEX = /[\r\n]/.freeze
224
232
 
225
233
  HIJACK_P = "rack.hijack?".freeze
226
234
  HIJACK = "rack.hijack".freeze
@@ -466,6 +466,8 @@ module Puma
466
466
  clean_thread_locals = @options[:clean_thread_locals]
467
467
  close_socket = true
468
468
 
469
+ requests = 0
470
+
469
471
  while true
470
472
  case handle_request(client, buffer)
471
473
  when false
@@ -479,7 +481,19 @@ module Puma
479
481
 
480
482
  ThreadPool.clean_thread_locals if clean_thread_locals
481
483
 
482
- unless client.reset(@status == :run)
484
+ requests += 1
485
+
486
+ check_for_more_data = @status == :run
487
+
488
+ if requests >= MAX_FAST_INLINE
489
+ # This will mean that reset will only try to use the data it already
490
+ # has buffered and won't try to read more data. What this means is that
491
+ # every client, independent of their request speed, gets treated like a slow
492
+ # one once every MAX_FAST_INLINE requests.
493
+ check_for_more_data = false
494
+ end
495
+
496
+ unless client.reset(check_for_more_data)
483
497
  close_socket = false
484
498
  client.set_timeout @persistent_timeout
485
499
  @reactor.add client
@@ -643,6 +657,7 @@ module Puma
643
657
  headers.each_pair do |k, vs|
644
658
  if vs.respond_to?(:to_s) && !vs.to_s.empty?
645
659
  vs.to_s.split(NEWLINE).each do |v|
660
+ next if possible_header_injection?(v)
646
661
  fast_write client, "#{k}: #{v}\r\n"
647
662
  end
648
663
  else
@@ -744,6 +759,7 @@ module Puma
744
759
  headers.each do |k, vs|
745
760
  case k.downcase
746
761
  when CONTENT_LENGTH2
762
+ next if possible_header_injection?(vs)
747
763
  content_length = vs
748
764
  next
749
765
  when TRANSFER_ENCODING
@@ -756,6 +772,7 @@ module Puma
756
772
 
757
773
  if vs.respond_to?(:to_s) && !vs.to_s.empty?
758
774
  vs.to_s.split(NEWLINE).each do |v|
775
+ next if possible_header_injection?(v)
759
776
  lines.append k, colon, v, line_ending
760
777
  end
761
778
  else
@@ -1026,5 +1043,10 @@ module Puma
1026
1043
  def shutting_down?
1027
1044
  @status == :stop || @status == :restart
1028
1045
  end
1046
+
1047
+ def possible_header_injection?(header_value)
1048
+ HTTP_INJECTION_REGEX =~ header_value.to_s
1049
+ end
1050
+ private :possible_header_injection?
1029
1051
  end
1030
1052
  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: 4.3.0
4
+ version: 4.3.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: 2019-11-07 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.0.3
139
+ rubygems_version: 3.1.2
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for