CVE-2017-0901
high
CVSS v3
7.5
CVSS v4 NEW
โ
VIR risk
8.5
Description
RubyGems version 2.6.12 and earlier fails to validate specification names, allowing a maliciously crafted gem to potentially overwrite any file on the filesystem.
Predictions
Exploit likelihood
83%
Patch ETA
โ
Heuristic predictions, AS-IS, for prioritization only.
Mitigations
No mitigations published for this CVE yet.
The vendor-content worker queues fetches as references arrive (check back in a few minutes). Or โ if you've already worked around this in production โ publish your fix to the community-verified tier.
โ Propose a mitigation on Community โ Mitigations published via the community go through AI scoring + 2 human reviewers + 7-day silent objection window before landing here withsource_tier=community-verified.
Exploits
Public proof-of-concept code below. AS-IS, for defenders and authorised testing only.
Exploit-DB
RubyGems < 2.6.13 - Arbitrary File Overwrite
There is no check for name field in metadata.gz. By assigning a maliciously crafted string like ../../../../../any/where to the field, an attacker can create an arbitrary file out of the directory of the gem, or even replace an existing file with a malicious file.
Proof of Concept 1: Create a file anywhere
This PoC attempts to create a file /tmp/malicious-0/BOOOOM.
1) Download the attached file malicious.gem.
2) Run gem install malicious.gem --no-doc.
3) /tmp/malicious-0/BOOOOM should be created.
malicious.gem assigns ../../../../../../../../../../tmp/malicious as name field. This attack is relatively weak since the path must include a directory named <name>-<version>, such as malicious-0. Still, there are many chances that cause a catastrophe. For example, think of replacing a file in /etc/dbus-1/.
Proof of Concept 2: Replace rackup command
This PoC attempts to replace gems/rack-2.0.3/bin/rackup with a malicious file.
1) Download the attached file replace-rackup.gem.
2) Run gem install rack -v 2.0.3.
3) Run gem install replace-rackup.gem --no-doc.
4) Run rackup. It will emit just BOOOOM!.
replace-rackup.gem assigns ../gems/rack as name field, and contains a malicious file bin/rackup. This is really exploitable for attackers.
Note
For how to create the malicious gems, see the attached file src.tar.gz.
Proof of Concept:
https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/42611.zip
OS impact
Red Hat Affected 1 release
| Version | Status | Fixed in |
|---|---|---|
| 7.0 | Affected | โ |
SUSE Affected 1 release
| Version | Status | Fixed in |
|---|---|---|
| โ | Affected | โ |
Ubuntu Affected 3 releases
| Version | Status | Fixed in |
|---|---|---|
| 17.10 | Affected | โ |
| 16.04 | Affected | โ |
| 14.04 | Affected | โ |
Debian Mixed 7 releases
| Version | Status | Fixed in |
|---|---|---|
| trixie | Fixed | 3.2.0~rc.1-1 |
| sid | Fixed | 3.2.0~rc.1-1 |
| forky | Fixed | 3.2.0~rc.1-1 |
| bullseye | Fixed | 3.2.0~rc.1-1 |
| bookworm | Fixed | 3.2.0~rc.1-1 |
| 9.0 | Affected | โ |
| 8.0 | Affected | โ |
Package impact
| Ecosystem | Package | Vulnerable | Fixed |
|---|---|---|---|
| RubyGems | rubygems-update | <>= 2.4.5.3 | >= 2.4.5.3 |
| RubyGems | rubygems-update | <2.6.13 | 2.6.13 |
Application impact
| Vendor | Product | Versions | Fixed |
|---|---|---|---|
| rubygems | rubygems | {"endIncluding":"2.6.12"} | |
References
- https://blog.rubygems.org/2017/08/27/2.6.13-released.html
- http://blog.rubygems.org/2017/08/27/2.6.13-released.html
- http://www.securityfocus.com/bid/100580
- http://www.securitytracker.com/id/1039249
- https://access.redhat.com/errata/RHSA-2017:3485
- https://access.redhat.com/errata/RHSA-2018:0378
- https://access.redhat.com/errata/RHSA-2018:0583
- https://access.redhat.com/errata/RHSA-2018:0585
- https://github.com/rubygems/rubygems/commit/ad5c0a53a86ca5b218c7976765c0365b91d22cb2
- https://hackerone.com/reports/243156
- https://lists.debian.org/debian-lts-announce/2018/07/msg00012.html
- https://security.gentoo.org/glsa/201710-01
- https://usn.ubuntu.com/3553-1/
- https://usn.ubuntu.com/3685-1/
- https://www.debian.org/security/2017/dsa-3966
- https://www.exploit-db.com/exploits/42611/
- https://www.suse.com/security/cve/CVE-2017-0901.html
- https://nvd.nist.gov/vuln/detail/CVE-2017-0901
- https://github.com/rubygems/rubygems
- https://usn.ubuntu.com/3553-1
- https://usn.ubuntu.com/3685-1
- https://web.archive.org/web/20170907215801/http://www.securitytracker.com/id/1039249
- https://web.archive.org/web/20170915000000*/http://www.securityfocus.com/bid/100580#:~:text=1%20snapshot-,16%3A05%3A26,-Note
- https://www.exploit-db.com/exploits/42611
- https://security-tracker.debian.org/tracker/CVE-2017-0901
CWEs
CWE-22 CWE-20
Community-verified mitigations for this CVE will appear above when contributors publish them.
Verify integrity in audit chain (admin only). AS-IS.