# CVE-2024-27281: RCE vulnerability with .rdoc_options in RDoc

RDoc loaded .rdoc_options as unrestricted YAML, so a malicious repo's config file triggered Ruby object injection and RCE via Kernel.system when rdoc ran.

- Payout: $4,860
- Severity: high
- Program: Internet Bug Bounty
- Found by: ooooooo_q
- Disclosed: 2024-03-29
- CVE: CVE-2024-27281
- Write-up quality: 7/10
- Original: https://hackerone.com/reports/2438265
- Library page: https://bugbountylibrary.com/r/h1%3A2438265
- Tags: area:oss domain:oss impact:rce kind:bounty platform:hackerone sev:high tech:ruby technique:chained technique:source-review vuln:deserialization vuln:rce

**Target:** RDoc gem (Ruby) .rdoc_options YAML config loader
**Root cause:** RDoc.load_options calls YAML.load_file on .rdoc_options without safe_load/class restrictions, allowing deserialization of arbitrary Ruby objects (Gem::Requirement gadget chain) that invoke Kernel.system.
**Steps:**
1. Confirm vulnerable version: `rdoc -v` shows 6.3.1
2. Place malicious `.rdoc_options` in repo root containing YAML gadget chain: `!ruby/object:Gem::Requirement` with `requirements` -> `Gem::Package::TarReader` -> `Net::BufferedIO` -> `Net::WriteAdapter` with `socket: !ruby/module 'Kernel'`, `method_id: :system`, `git_set: date`
3. Run `rdoc` in that directory
4. Observe `date` output and `sh: reading: command not found`, confirming Kernel.system executed
**How found:** Code reading of rdoc.rb load_options spotted YAML.load_file on a repo-controlled file; recognized unrestricted YAML.load as object-injection sink and applied a known universal Ruby YAML RCE gadget chain.
**Exploitation:** Attacker ships a repo containing a crafted .rdoc_options; victim runs `rdoc` on it, YAML.load_file deserializes the Gem gadget chain and calls Kernel.system with attacker-controlled command. Limited to environments where rdoc is run on untrusted repos (gem rdoc does not read the file).
**Insight:** Any tool that auto-reads a config file from a cloned repo (e.g. .rdoc_options, .rubocop.yml) and passes it to YAML.load is a deserialization RCE sink; reuse the Gem::Requirement/Net::WriteAdapter gadget chain to prove it.

