CVE-2017-0901

high
Published 2017-08-29 ยท Modified 2024-02-22
CVSS v3
7.5
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
CVSS v4 NEW
โ€”
not yet in upstream
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 with source_tier=community-verified.

Exploits

Public proof-of-concept code below. AS-IS, for defenders and authorised testing only.

Exploit-DB

EDB-42611 local linux verified text ยท 1 KB
mame ยท 2017-09-04

RubyGems < 2.6.13 - Arbitrary File Overwrite

text exploit Source: Exploit-DB
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

redhat Red Hat Affected 1 release
VersionStatusFixed in
7.0 Affected โ€”
suse SUSE Affected 1 release
VersionStatusFixed in
โ€” Affected โ€”
ubuntu Ubuntu Affected 3 releases
VersionStatusFixed in
17.10 Affected โ€”
16.04 Affected โ€”
14.04 Affected โ€”
debian Debian Mixed 7 releases
VersionStatusFixed 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

EcosystemPackageVulnerableFixed
ruby RubyGemsrubygems-update<>= 2.4.5.3>= 2.4.5.3
ruby RubyGemsrubygems-update<2.6.132.6.13

Application impact

VendorProductVersionsFixed
rubygemsrubygems{"endIncluding":"2.6.12"}

References

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.