ruby-proxy-headers 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30f82103fa860333b7df81d1b90271b048a8dd4e334bcb74caf5c762c2c7d695
4
- data.tar.gz: 296932a159549772f64c66a305a794800f54a70f08b08f2e6e31cf5270d84c63
3
+ metadata.gz: 227e0393d4ab8a6f03fa72d69541f07a20c73cec9eb3458266dbaa0b74fee36d
4
+ data.tar.gz: 299ef710e77b061929ce18159f37e82f002c7a8522b5f0c5ed4319f3d2ab517f
5
5
  SHA512:
6
- metadata.gz: 92f5f07379e76973c41159aadf9ff343dad72fd7df8ab14a6c090805b7af2c2f52af6ac048916de4a2f65f8e70efc4f11831d721ed16987b9859a14affc069bf
7
- data.tar.gz: 87c47f3acd8ed3d0741b3075999f632e6998f59cdfb86606de02227fdf3fc9a72c78355964e048c29e8dae02d340d19f18b3b77ea3a131b92ad123e345a41329
6
+ metadata.gz: deae95ea2297961bc962a5d9e476ec09b88c85a6a2ac741e1c5d1cb15972f1dc096f2b52e16a70aaca28a77ce04568f00a1109abd2edbdfee45a9727841bff61
7
+ data.tar.gz: 55096cb62498dc26f1c1695c8bc46213db91bea6be4c2d056af152cdbbabd07873bc646c2db07a2e36764f8cd8a78188942c77d15b784c3c71acc3e91e2f8a75
@@ -135,14 +135,7 @@ module RubyProxyHeaders
135
135
  end
136
136
 
137
137
  def validate_connect_target!(host, port)
138
- if RubyProxyHeaders::INVALID_HEADER_VALUE_RE.match?(host.to_s)
139
- raise ArgumentError,
140
- "CONNECT target host contains invalid characters (CR, LF, or NUL): #{host.inspect}"
141
- end
142
- if RubyProxyHeaders::INVALID_HEADER_VALUE_RE.match?(port.to_s)
143
- raise ArgumentError,
144
- "CONNECT target port contains invalid characters (CR, LF, or NUL): #{port.inspect}"
145
- end
138
+ RubyProxyHeaders.validate_connect_target!(host, port)
146
139
  end
147
140
 
148
141
  def raise_connect_error
@@ -48,6 +48,12 @@ module RubyProxyHeaders
48
48
  @ssl_context = OpenSSL::SSL::SSLContext.new
49
49
  end
50
50
 
51
+ if use_ssl? && proxy?
52
+ # Fail before any socket I/O: CONNECT interpolates these into a raw request line.
53
+ RubyProxyHeaders.validate_connect_target!(conn_address, @port)
54
+ RubyProxyHeaders.validate_connect_target!(@address, @port)
55
+ end
56
+
51
57
  if proxy?
52
58
  conn_addr = proxy_address
53
59
  conn_port = proxy_port
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyProxyHeaders
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
@@ -22,4 +22,17 @@ module RubyProxyHeaders
22
22
  raise ArgumentError, "proxy CONNECT header value contains invalid characters (CR, LF, or NUL): #{value.inspect}"
23
23
  end
24
24
  end
25
+
26
+ # Raises ArgumentError if +host+ or +port+ contain CR, LF, or NUL bytes that
27
+ # would allow HTTP request smuggling when interpolated into a CONNECT line.
28
+ def self.validate_connect_target!(host, port)
29
+ if INVALID_HEADER_VALUE_RE.match?(host.to_s)
30
+ raise ArgumentError,
31
+ "CONNECT target host contains invalid characters (CR, LF, or NUL): #{host.inspect}"
32
+ end
33
+ if INVALID_HEADER_VALUE_RE.match?(port.to_s)
34
+ raise ArgumentError,
35
+ "CONNECT target port contains invalid characters (CR, LF, or NUL): #{port.inspect}"
36
+ end
37
+ end
25
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-proxy-headers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ProxyMesh