CVE-2021-31799: A command injection vulnerability in RDoc

Posted by aycabta on 2 May 2021

There is a vulnerability about Command Injection in RDoc which is bundled in Ruby. It is recommended that all Ruby users update RDoc to the latest version that fixes this issue.

Details

The following vulnerability has been reported.

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.

Ruby users whose version of RDoc is affected by this issue should update to the latest version of RDoc.

Affected Versions

  • All releases of RDoc from 3.11 to 6.3.0
  • Ruby 3.0.2 (bundles RDoc 6.3.1), Ruby 2.7.4 (bundles RDoc 6.2.1.1) and Ruby 2.6.8 (bundles RDoc 6.1.2.1) include fixes and not affected

How to Update

Run the following command to update RDoc to the latest version (6.3.1 or later) to fix the vulnerability.

gem install rdoc

If you are using bundler, please add gem "rdoc", ">= 6.3.1" to your Gemfile.

Credits

Thanks to Alexandr Savca for reporting the issue.

History

  • Originally published at 2021-05-02 09:00:00 UTC
  • Mention about Ruby 3.0.2, Ruby 2.7.4 and Ruby 2.6.8 at 2021-07-16 00:02:00 UTC

Recent News

A New Look for Ruby's Documentation

Following the ruby-lang.org redesign, we have more news to celebrate Ruby’s 30th anniversary: docs.ruby-lang.org has a completely new look with Aliki—RDoc’s new default theme.

Posted by Stan Lo on 23 Dec 2025

Redesign our Site Identity

We are excited to announce a comprehensive redesign of our site. The design for this update was created by Taeko Akatsuka.

Posted by Hiroshi SHIBATA on 22 Dec 2025

Ruby 4.0.0 preview3 Released

We are pleased to announce the release of Ruby 4.0.0-preview3. Ruby 4.0 introduces Ruby::Box and “ZJIT”, and adds many improvements.

Posted by naruse on 18 Dec 2025

More News...