CVE-2021-31799 is a high-severity (CVSS 7) OS Command Injection vulnerability in rdoc. A fix is available for rdoc — see the affected versions and patch details below.
Arbitrary Code Execution in Rdoc
Exploitation Status
No confirmed exploitation observed yet
- A successful exploit gives an attacker total control of the affected component, not partial access.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for CVE-2021-31799.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
CVE-2021-31799 by exploitation likelihood (EPSS) against impact (CVSS). Outside the shaded patch-first corner.
Where this sits among everything scored
Of 385,386 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Counts from FIRST.org, log-scaled.
Real-World Exposure
rdoc💎rdoc💎rdocReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects RubyGems packages — download data is not available via public APIs for these ecosystems.
Description
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.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 💎RubyGems | rdoc | ≥ 3.11&&< 6.1.2.1 | 6.1.2.1bundle update rdoc --conservative |
| 💎RubyGems | rdoc | ≥ 6.2.0&&< 6.2.1.1 | 6.2.1.1bundle update rdoc --conservative |
| 💎RubyGems | rdoc | ≥ 6.3.0&&< 6.3.1 | 6.3.1bundle update rdoc --conservative |
Affected Products
debian linuxdebianjd edwards enterpriseone toolsoraclerdocruby-langDetection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for rdoc, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update rdoc to 6.1.2.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2021-31799 is resolved across your whole dependency graph.
Workarounds
Stop passing untrusted input into the interpreter or shell: call the affected binary with an argument array rather than a composed command string, reject anything outside a strict allowlist of expected values, and run the component under an account that cannot reach beyond the work it legitimately does.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
| Product | Fixed in | Advisory |
|---|---|---|
| Red Hat Enterprise Linux 8 | ruby:2.7-8040020210728141159.522a0ee4 | RHSA-2021:3020 |
| Red Hat Enterprise Linux 8 | ruby:2.6-8050020211215144356.c5368500 | RHSA-2022:0543 |
| Red Hat Enterprise Linux 8 | ruby:2.5-8050020220216195847.c5368500 | RHSA-2022:0672 |
| Red Hat Enterprise Linux 8.1 Update Services for SAP Solutions | ruby:2.6-8010020220201152941.c27ad7f8 | RHSA-2022:0581 |
| Red Hat Enterprise Linux 8.2 Extended Update Support | ruby:2.6-8020020220201131207.4cda2c84 | RHSA-2022:0582 |
| Red Hat Enterprise Linux 8.4 Extended Update Support | ruby:2.6-8040020220131135901.522a0ee4 | RHSA-2022:0544 |
| Red Hat Software Collections for Red Hat Enterprise Linux 7 | rh-ruby27-ruby-0:2.7.4-130.el7 | RHSA-2021:3559 |
| Red Hat Software Collections for Red Hat Enterprise Linux 7 | rh-ruby30-ruby-0:3.0.2-148.el7 | RHSA-2021:3982 |
Frequently Asked Questions
Is CVE-2021-31799 in your dependencies?
Find it across RubyGems, including transitive dependencies.