CVE-2021-31799: Rdoc Arbitrary Code Execution Vulnerability
HIGHCVE-2021-31799 is a HIGH (CVSS 7.0) arbitrary code execution vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Rdoc libraries in the RubyGems ecosystem. The issue involves arbitrary code execution in rdoc. Remediation is available by upgrading affected packages to version 6.1.2.1, 6.2.1.1, 6.3.1.
CVE-2021-31799 at a Glance
Security Impact
CVSS: 7.0
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2021-31799
To remediate this vulnerability, upgrade all affected Rdoc dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade rdoc to 6.1.2.1
Upgrade rdoc to 6.2.1.1
Upgrade rdoc to 6.3.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for rdoc
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-31799, inspect your project dependencies for Rdoc:
inspect dependencies for rdoc
Analyze the terminal output to locate any version of Rdoc in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.1.2.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Rdoc, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-31799 Affected Rdoc Versions
3 component(s)References
Frequently Asked Questions
What is CVE-2021-31799?
Which Rdoc versions are affected?
What version fixes CVE-2021-31799?
Is rdoc affected?
What is the CVSS score of CVE-2021-31799?
What CWE is associated with CVE-2021-31799?
How can I check RubyGems dependencies for CVE-2021-31799?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-ggxm-pgc9-g7fp",
"modified" : "2024-11-14T01:01:40Z",
"published" : "2021-09-01T18:53:15Z",
"aliases" : [ "CVE-2021-31799" ],
"summary" : "Arbitrary Code Execution in Rdoc",
"details" : "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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "rdoc"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.11"
}, {
"fixed" : "6.1.2.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "rdoc"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.2.0"
}, {
"fixed" : "6.2.1.1"
} ]
} ]
}, {
"package" : {
"ecosystem" : "RubyGems",
"name" : "rdoc"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "6.3.0"
}, {
"fixed" : "6.3.1"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-31799"
}, {
"type" : "WEB",
"url" : "https://github.com/ruby/rdoc/commit/a7f5d6ab88632b3b482fe10611382ff73d14eed7"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/ruby/rdoc"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/rdoc/CVE-2021-31799.yml"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2021/10/msg00009.html"
}, {
"type" : "WEB",
"url" : "https://security-tracker.debian.org/tracker/CVE-2021-31799"
}, {
"type" : "WEB",
"url" : "https://security.gentoo.org/glsa/202401-05"
}, {
"type" : "WEB",
"url" : "https://security.netapp.com/advisory/ntap-20210902-0004"
}, {
"type" : "WEB",
"url" : "https://www.oracle.com/security-alerts/cpuapr2022.html"
}, {
"type" : "WEB",
"url" : "https://www.ruby-lang.org/en/news/2021/05/02/os-command-injection-in-rdoc"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-74", "CWE-77", "CWE-78" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-08-02T18:08:41Z",
"nvd_published_at" : "2021-07-30T14:15:00Z"
}
}