Cloudanix VulnDB

CVE-2017-17405

High · 8.8

CVSS

8.8

EPSS

73.8%

Published

Dec 15, 2017

CISA due date

—

Cloudanix analysis

Schedule a fix SSVC: Attend

A flaw in Ruby lets attackers run their own commands on computers that download or upload files from a malicious file server.

Exploit Available
Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Low
Impact
Remote Code Execution
Component
Library
Class
Command Injection
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

Net::FTP#get, getbinaryfile, gettextfile, put, putbinaryfile, and puttextfile pass the localfile argument (defaulting to File.basename(remotefile)) directly to Kernel#open; a leading pipe character causes arbitrary command execution instead of file access.

Why it matters to the business

Systems using affected Ruby versions for FTP file transfers can be fully compromised by a malicious server, resulting in remote code execution, data theft, or deployment of malware across the environment.

How an attack unfolds

An attacker hosts a malicious FTP server; when a vulnerable Ruby client performs any of the listed file operations, the server supplies a remotefile whose basename begins with a pipe followed by a command, which Kernel#open executes with the privileges of the Ruby process.

How to fix it

Upgrade Ruby to version 2.4.3 or later on all affected systems; replace direct use of Net::FTP#get/put family methods with safer file-handling libraries that do not invoke the shell; restrict connections to trusted FTP servers only.

How to confirm the fix worked

Confirm Ruby version is 2.4.3 or newer; attempt a test transfer with a localfile argument beginning with '|' and verify the command is not executed; scan application code for calls to the affected Net::FTP methods.

Typical attack path

  1. Attacker deploys malicious FTP server that returns crafted remotefile names
  2. Victim Ruby application initiates Net::FTP connection and file transfer
  3. Net::FTP derives localfile from File.basename(remotefile) containing leading pipe
  4. Kernel#open executes the command following the pipe
  5. Attacker gains arbitrary command execution on the victim host

How to detect it

Review Ruby process execution logs and system audit trails for child processes spawned unexpectedly during FTP operations; search application logs for FTP file names containing pipe characters; inspect network traffic for connections to unknown FTP endpoints.

What your security team should do

  • Prioritize upgrade of all Ruby installations to 2.4.3+ due to high EPSS and public exploit availability
  • Inventory and review all code paths that perform FTP file operations
  • Implement network controls to block outbound connections to untrusted FTP servers
  • Monitor for new Ruby releases and apply patches within standard change windows

The record

Ruby before 2.4.3 allows Net::FTP command injection. Net::FTP#get, getbinaryfile, gettextfile, put, putbinaryfile, and puttextfile use Kernel#open to open a local file. If the localfile argument starts with the "|" pipe character, the command following the pipe character is executed. The default value of localfile is File.basename(remotefile), so malicious FTP servers could cause arbitrary command execution.

Affected packages

Ecosystem Package Introduced Fixed
Alpine:v3.10 ruby 0 2.4.3-r0
Alpine:v3.11 ruby 0 2.4.3-r0
Alpine:v3.12 ruby 0 2.4.3-r0
Alpine:v3.13 ruby 0 2.4.3-r0
Alpine:v3.14 ruby 0 2.4.3-r0
Alpine:v3.15 ruby 0 2.4.3-r0
Alpine:v3.16 ruby 0 2.4.3-r0
Alpine:v3.17 ruby 0 2.4.3-r0
Alpine:v3.18 ruby 0 2.4.3-r0
Alpine:v3.19 ruby 0 2.4.3-r0
Alpine:v3.20 ruby 0 2.4.3-r0
Alpine:v3.21 ruby 0 2.4.3-r0
Alpine:v3.22 ruby 0 2.4.3-r0
Alpine:v3.3 ruby 0 2.2.9-r0
Alpine:v3.4 ruby 0 2.3.6-r0
Alpine:v3.5 ruby 0 2.3.6-r0
Alpine:v3.6 ruby 0 2.4.3-r0
Alpine:v3.7 ruby 0 2.4.3-r0
Alpine:v3.8 ruby 0 2.4.3-r0
Alpine:v3.9 ruby 0 2.4.3-r0
Debian:7 ruby1.8 0 1.8.7.358-7.1+deb7u5
Debian:7 ruby1.9.1 0 1.9.3.194-8.1+deb7u7
Debian:8 ruby2.1 0 2.1.5-2+deb8u4
Debian:9 ruby2.3 0 2.3.3-1+deb9u3
Mageia:5 ruby 0 2.0.0.p648-1.6.mga5
Mageia:6 ruby 0 2.2.8-1.1.mga6
Red Hat:enterprise_linux:7::client ruby 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client ruby-debuginfo 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client ruby-devel 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client ruby-doc 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client ruby-irb 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client ruby-libs 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client ruby-tcltk 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-bigdecimal 0 0:1.2.0-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-io-console 0 0:0.4.2-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-json 0 0:1.7.7-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-minitest 0 0:4.3.2-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-psych 0 0:2.0.0-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-rake 0 0:0.9.6-33.el7_4
Red Hat:enterprise_linux:7::client rubygem-rdoc 0 0:4.0.0-33.el7_4
Red Hat:enterprise_linux:7::client rubygems 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::client rubygems-devel 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby-debuginfo 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby-devel 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby-doc 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby-irb 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby-libs 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode ruby-tcltk 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-bigdecimal 0 0:1.2.0-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-io-console 0 0:0.4.2-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-json 0 0:1.7.7-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-minitest 0 0:4.3.2-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-psych 0 0:2.0.0-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-rake 0 0:0.9.6-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygem-rdoc 0 0:4.0.0-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygems 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::computenode rubygems-devel 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::server ruby 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server ruby-debuginfo 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server ruby-devel 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server ruby-doc 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server ruby-irb 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server ruby-libs 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server ruby-tcltk 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-bigdecimal 0 0:1.2.0-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-io-console 0 0:0.4.2-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-json 0 0:1.7.7-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-minitest 0 0:4.3.2-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-psych 0 0:2.0.0-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-rake 0 0:0.9.6-33.el7_4
Red Hat:enterprise_linux:7::server rubygem-rdoc 0 0:4.0.0-33.el7_4
Red Hat:enterprise_linux:7::server rubygems 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::server rubygems-devel 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby-debuginfo 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby-devel 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby-doc 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby-irb 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby-libs 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation ruby-tcltk 0 0:2.0.0.648-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-bigdecimal 0 0:1.2.0-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-io-console 0 0:0.4.2-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-json 0 0:1.7.7-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-minitest 0 0:4.3.2-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-psych 0 0:2.0.0-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-rake 0 0:0.9.6-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygem-rdoc 0 0:4.0.0-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygems 0 0:2.0.14.1-33.el7_4
Red Hat:enterprise_linux:7::workstation rubygems-devel 0 0:2.0.14.1-33.el7_4
Red Hat:rhel_aus:7.3::server ruby 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server ruby-debuginfo 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server ruby-devel 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server ruby-doc 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server ruby-irb 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server ruby-libs 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server ruby-tcltk 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-bigdecimal 0 0:1.2.0-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-io-console 0 0:0.4.2-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-json 0 0:1.7.7-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-minitest 0 0:4.3.2-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-psych 0 0:2.0.0-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-rake 0 0:0.9.6-30.el7_3
Red Hat:rhel_aus:7.3::server rubygem-rdoc 0 0:4.0.0-30.el7_3
Red Hat:rhel_aus:7.3::server rubygems 0 0:2.0.14.1-30.el7_3
Red Hat:rhel_aus:7.3::server rubygems-devel 0 0:2.0.14.1-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby-debuginfo 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby-devel 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby-doc 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby-irb 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby-libs 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server ruby-tcltk 0 0:2.0.0.648-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-bigdecimal 0 0:1.2.0-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-io-console 0 0:0.4.2-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-json 0 0:1.7.7-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-minitest 0 0:4.3.2-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-psych 0 0:2.0.0-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-rake 0 0:0.9.6-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygem-rdoc 0 0:4.0.0-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygems 0 0:2.0.14.1-30.el7_3
Red Hat:rhel_e4s:7.3::server rubygems-devel 0 0:2.0.14.1-30.el7_3
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby-debuginfo 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby-devel 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby-doc 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby-irb 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby-libs 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-ruby-tcltk 0 0:2.2.9-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-bigdecimal 0 0:1.2.6-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-io-console 0 0:0.4.3-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-json 0 0:1.8.1.1-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-minitest 0 0:5.4.3-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-power_assert 0 0:0.2.2-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-psych 0 0:2.0.8.1-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-rake 0 0:10.4.2-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-rdoc 0 0:4.2.0-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygem-test-unit 0 0:3.0.8-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygems 0 0:2.4.5.4-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby22-rubygems-devel 0 0:2.4.5.4-19.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby-debuginfo 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby-devel 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby-doc 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby-irb 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby-libs 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-ruby-tcltk 0 0:2.3.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-bigdecimal 0 0:1.2.8-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-did_you_mean 0 0:1.0.0-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-io-console 0 0:0.4.5-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-json 0 0:1.8.3.1-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-minitest 0 0:5.8.5-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-net-telnet 0 0:0.1.1-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-power_assert 0 0:0.2.6-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-psych 0 0:2.1.0.1-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-rake 0 0:10.4.2-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-rdoc 0 0:4.2.1-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygem-test-unit 0 0:3.1.5-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygems 0 0:2.5.2.2-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby23-rubygems-devel 0 0:2.5.2.2-67.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-ruby 0 0:2.4.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-ruby-debuginfo 0 0:2.4.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-ruby-devel 0 0:2.4.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-ruby-doc 0 0:2.4.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-ruby-irb 0 0:2.4.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-ruby-libs 0 0:2.4.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-bigdecimal 0 0:1.3.0-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-did_you_mean 0 0:1.1.0-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-io-console 0 0:0.4.6-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-json 0 0:2.0.4-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-minitest 0 0:5.10.1-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-net-telnet 0 0:0.1.1-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-openssl 0 0:2.0.5-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-power_assert 0 0:0.4.1-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-psych 0 0:2.2.2-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-rake 0 0:12.0.0-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-rdoc 0 0:5.0.0-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-test-unit 0 0:3.2.3-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygem-xmlrpc 0 0:0.2.1-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygems 0 0:2.6.14-90.el6
Red Hat:rhel_software_collections:3::el6 rh-ruby24-rubygems-devel 0 0:2.6.14-90.el6
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby-debuginfo 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby-devel 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby-doc 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby-irb 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby-libs 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-ruby-tcltk 0 0:2.2.9-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-bigdecimal 0 0:1.2.6-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-io-console 0 0:0.4.3-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-json 0 0:1.8.1.1-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-minitest 0 0:5.4.3-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-power_assert 0 0:0.2.2-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-psych 0 0:2.0.8.1-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-rake 0 0:10.4.2-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-rdoc 0 0:4.2.0-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygem-test-unit 0 0:3.0.8-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygems 0 0:2.4.5.4-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby22-rubygems-devel 0 0:2.4.5.4-19.el7
Red Hat:rhel_software_collections:3::el7 rh-ruby23-ruby 0 0:2.3.6-67.el7

Related vulnerabilities