CVE-2021-31799: Command Injection

Published May 2, 2021
·
Updated

An operating system command injection flaw was found in RDoc. Using the rdoc command to generate documentation for a malicious Ruby source code could lead to execution of arbitrary commands with the privileges of the user running rdoc.

Other sources

In RDoc 3.11 through 6.x before 6.3.1, as distributed with Ruby through 3.0.1, it is possible to execute arbitrary code via | and tags in a filename.

RDoc used to call Kernel#open to open a local file. If a Ruby project has a file whose name starts with | and ends with tags, the command following the pipe character is executed. A malicious Ruby project could exploit it to run an arbitrary command execution against a user who attempts to run rdoc command.

References:

https://www.ruby-lang.org/en/news/2021/05/02/os-command-injection-in-rdoc/

Red Hat

Affected Software

18 affected componentsFixes available
redhat/rh-ruby27-ruby<0:2.7.4-130.el7
0:2.7.4-130.el7
redhat/rh-ruby30-ruby<0:3.0.2-148.el7
0:3.0.2-148.el7
redhat/rh-ruby26-ruby<0:2.6.9-120.el7
0:2.6.9-120.el7
rubygems/rdoc>=6.3.0<6.3.1
6.3.1
rubygems/rdoc>=6.2.0<6.2.1.1
6.2.1.1
rubygems/rdoc>=3.11<6.1.2.1
6.1.2.1
Debian Debian Linux=9.0
Debian Debian Linux=10.0
All of the following
ruby-lang Ruby<=3.0.1
ruby-lang Rdoc Ruby>=3.11<6.3.1
Oracle JD Edwards EnterpriseOne Tools<9.2.6.1
ruby-lang Rdoc Ruby>=3.11<6.3.1
ruby-lang Ruby<=3.0.1
redhat/rubygem-rdoc<6.3.1
6.3.1
redhat/ruby<3.0.2
3.0.2
redhat/ruby<2.7.4
2.7.4
redhat/ruby<2.6.8
2.6.8
debian/ruby2.7
2.7.4-1+deb11u12.7.4-1+deb11u5

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/rh-ruby27-ruby to a version that resolves this vulnerability.

    Fixed in 0:2.7.4-130.el7
  2. Upgrade

    Upgrade redhat/rh-ruby30-ruby to a version that resolves this vulnerability.

    Fixed in 0:3.0.2-148.el7
  3. Upgrade

    Upgrade redhat/rh-ruby26-ruby to a version that resolves this vulnerability.

    Fixed in 0:2.6.9-120.el7
  4. Upgrade

    Upgrade rubygems/rdoc to a version that resolves this vulnerability.

    Fixed in 6.3.1
  5. Upgrade

    Upgrade rubygems/rdoc to a version that resolves this vulnerability.

    Fixed in 6.2.1.1
  6. Upgrade

    Upgrade rubygems/rdoc to a version that resolves this vulnerability.

    Fixed in 6.1.2.1
  7. Upgrade

    Upgrade debian/ruby2.7 to a version that resolves this vulnerability.

    Fixed in 2.7.4-1+deb11u1Fixed in 2.7.4-1+deb11u5
  8. Upgrade

    Upgrade redhat/rubygem-rdoc to a version that resolves this vulnerability.

    Fixed in 6.3.1
  9. Upgrade

    Upgrade redhat/ruby to a version that resolves this vulnerability.

    Fixed in 3.0.2
  10. Upgrade

    Upgrade redhat/ruby to a version that resolves this vulnerability.

    Fixed in 2.7.4
  11. Upgrade

    Upgrade redhat/ruby to a version that resolves this vulnerability.

    Fixed in 2.6.8

Event History

May 2, 2021
CVE Published
12:00 AM
Jul 7, 2021
Data Sourced
via Red Hat·09:05 PM
DescriptionSeverityAffected Software
Jul 29, 2021
CVE Published
via MITRE·12:00 AM
Data Sourced
via MITRE·12:00 AM
Description
Sep 1, 2021
Advisory Published
via GitHub·06:53 PM
Feb 24, 2026
Data Sourced
via Debian·07:18 PM
DescriptionAffected Software

Frequently Asked Questions

1

What is CVE-2021-31799?

CVE-2021-31799 is an operating system command injection vulnerability found in RDoc.

2

How does CVE-2021-31799 impact Ruby?

CVE-2021-31799 allows an attacker to execute arbitrary commands with the privileges of the user running rdoc in Ruby through version 3.0.1.

3

What is the severity of CVE-2021-31799?

CVE-2021-31799 has a severity rating of 7, indicating a high severity vulnerability.

4

How do I fix CVE-2021-31799?

To fix CVE-2021-31799, update RDoc to version 6.3.1 or higher.

5

Where can I find more information about CVE-2021-31799?

You can find more information about CVE-2021-31799 in the references provided: [Link 1](https://www.ruby-lang.org/en/news/2021/05/02/os-command-injection-in-rdoc/), [Link 2](https://github.com/ruby/rdoc/commit/a7f5d6ab88632b3b482fe10611382ff73d14eed7), [Link 3](https://www.ruby-lang.org/en/news/2021/07/07/ruby-3-0-2-released/).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203