net-ssh 8.0.3 → 8.0.4

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: db558d490e7fb5d8ca959a00ddd5a07d6c24bdc3957a8dcbb067848466928072
4
- data.tar.gz: 91a1983ea97a6c94cd542c8dd55cbc0c46f99f2926d7fd168f027a90a404b693
3
+ metadata.gz: 110d479784d8cc56b52a5a3e9b14e5f23dbf556873b64a8e1563df31b1205911
4
+ data.tar.gz: e0f0d31f6476b896ddc6354906cc1b861f99687365a0783527b738e69f4d4e15
5
5
  SHA512:
6
- metadata.gz: e154b5ec3ae2c1ac272e638ba3e7e51715f738ccb926a7dc2cf73ffea3819a6a39a1f08cd5b92ff6b403bd43383c400ff2b6817000f566240baedb2384419c70
7
- data.tar.gz: 064a69e61d1bc28b22116fd6c26efd3339404527aa6e3a796ddca85b8eaee4aeb8d9b76c2a80f3bad0c1289436f35aaad403cb55dee2d74cd3d104764a0af0bb
6
+ metadata.gz: 985c71acd2df6c9e5a287c8e64c6e960cd80bd47c5d18837e1381a7c38f09ee2bbad51e3946f8d26d5f467c4999fca322e3ce4b48aa16115c2d434f675cf52cd
7
+ data.tar.gz: 81a1286e7e73a6c6b17a4a64e5c5004844a734bfa0118d39041ff291eb0e364c9fa4d3777cd7c745fb0ba038bd1aed2cef191b9c001cfb47937b7154a0506813
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 8.0.4
2
+
3
+ * Security: validate every ProxyJump hop, not only the first, as [user@]host[:port] (refusing a path, query, fragment or password) and shell-escape the hops passed to ssh -J; a hop such as `evil/x&$(cmd)` ran `cmd` through the shell [GHSA-g2r2-x3p2-5677]
4
+
1
5
  === 8.0.3
2
6
 
3
7
  * Add `preopen_channels` option: keep a spare session channel open so each command saves a round trip [#1071]
@@ -54,20 +54,21 @@ module Net
54
54
  # We cannot build the ProxyCommand template until we know if the :config
55
55
  # option was specified during `Net::SSH.start`.
56
56
  def build_proxy_command_equivalent(connection_options = nil)
57
- extra_jumps = jump_proxies.split(",", 2)[1]
57
+ raise ArgumentError, "no jump host given" if jump_proxies.empty?
58
+
58
59
  config = connection_options && connection_options[:config]
59
- uri, = jump_proxies.split(",").map { |jump| validate_jump!(jump) }
60
+ uri, *extra_jumps = jump_proxies.split(",", -1).map { |jump| validate_jump!(jump) }
60
61
 
61
62
  template = "ssh".dup
62
- template << " -l #{uri.user}" if uri.user
63
- template << " -p #{uri.port}" if uri.port
64
- template << " -J #{extra_jumps}" if extra_jumps
63
+ template << " -l #{escape(uri.user)}" if uri.user
64
+ template << " -p #{uri.port}" if uri.port
65
+ template << " -J #{escape(extra_jumps.map { |jump| jump_spec(jump) }.join(','))}" unless extra_jumps.empty?
65
66
  template << " -F #{escape(config)}" if config != true && config
66
67
  @options.each do |key, values|
67
68
  Array(values).each { |value| template << " -o #{escape(key)}=#{escape(value)}" }
68
69
  end
69
70
  template << " -W %h:%p "
70
- template << uri.host
71
+ template << escape(uri.host)
71
72
 
72
73
  @command_line_template = template
73
74
  end
@@ -90,11 +91,25 @@ module Net
90
91
  Shellwords.escape(value).gsub("%", "%%")
91
92
  end
92
93
 
94
+ # Only [user@]host[:port] is checked, so anything else URI accepts (a path,
95
+ # query, fragment or password) must be refused before it reaches the shell.
93
96
  def validate_jump!(jump)
94
97
  uri = URI.parse("ssh://#{jump}")
98
+ raise URI::InvalidURIError if uri.host.to_s.empty? || jump_spec(uri) != jump
99
+
95
100
  validate_user_name!(uri.user) if uri.user
96
101
  validate_host_name!(uri.host)
102
+ validate_port!(uri.port) if uri.port
97
103
  uri
104
+ rescue URI::InvalidURIError
105
+ raise ArgumentError, "jump host is not [user@]host[:port]: #{jump.inspect}"
106
+ end
107
+
108
+ def jump_spec(uri)
109
+ spec = uri.host.dup
110
+ spec.prepend("#{uri.user}@") if uri.user
111
+ spec << ":#{uri.port}" if uri.port
112
+ spec
98
113
  end
99
114
  end
100
115
  end
@@ -52,7 +52,7 @@ module Net
52
52
  MINOR = 0
53
53
 
54
54
  # The tiny component of this version of the Net::SSH library
55
- TINY = 3
55
+ TINY = 4
56
56
 
57
57
  # The prerelease component of this version of the Net::SSH library
58
58
  # nil allowed
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.3
4
+ version: 8.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamis Buck
metadata.gz.sig CHANGED
Binary file