Bug 1651826 (CVE-2019-3881) - CVE-2019-3881 rubygem-bundler: Insecure permissions on directory in /tmp/ allows for execution of malicious code
Summary: CVE-2019-3881 rubygem-bundler: Insecure permissions on directory in /tmp/ all...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2019-3881
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1734213 1734214 1734215 1734216 1931264 1953046 1954969
Blocks: 1651827 1997390
TreeView+ depends on / blocked
 
Reported: 2018-11-21 00:38 UTC by Sam Fowler
Modified: 2022-10-02 21:48 UTC (History)
25 users (show)

Fixed In Version: bundler 2.1.0
Doc Type: If docs needed, set a value
Doc Text:
Bundler prior to 2.1.0 uses a predictable path in /tmp/, created with insecure permissions as a storage location for gems, if locations under the user's home directory are not available. If Bundler is used in a scenario where the user does not have a writable home directory, an attacker could place malicious code in this directory that would be later loaded and executed.
Clone Of:
Environment:
Last Closed: 2021-06-03 11:32:04 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2021:2588 0 None None None 2021-06-29 16:03:57 UTC

Description Sam Fowler 2018-11-21 00:38:38 UTC
Bundler through version 1.17.1 creates a directory with insecure permissions in /tmp/ that, in certain circumstances, is used by Bundler to load rubygems, allowing attackers to write malicious libraries to this location and be later executed.

Bundler contains some helper code which creates a temporary directory in case a user's home directory is not present or writeable, however it creates it via non-randomized path, `/tmp/bundler/home/username`. Permissions for this directory are 0777 which allows an attacker to create subdirectory with an arbitrary username. Bundler processes started under an effective user without a home directory will load rubygems from this attacker-writable location, allowing for code execution.

Comment 1 Sam Fowler 2018-11-21 00:38:49 UTC
Acknowledgments:

Name: Lukáš Zapletal (Red Hat)

Comment 4 Doran Moppert 2018-12-14 04:41:43 UTC
Introduced by:

https://github.com/bundler/bundler/commit/2dfb263b0f

It seems the first upstream release including this vuln was 1.14.

Comment 6 Cedric Buissart 2019-01-08 12:37:37 UTC
Doran, isn't https://github.com/bundler/bundler/commit/02e7f67727b45 (predating 2dfb263b0f) also vulnerable ? Even if the home is created without 0777, the attacker should still be able to create the path before-hand so that they own it

Comment 7 Hardik Vyas 2019-01-31 11:59:35 UTC
Statement:

The version of rubygem-bundler provided in 'Red Hat Gluster Storage 3' does not contain the vulnerable functionality and is not affected by this vulnerability.

Comment 8 Doran Moppert 2019-03-26 00:04:15 UTC
In reply to comment #6:
> Doran, isn't https://github.com/bundler/bundler/commit/02e7f67727b45
> (predating 2dfb263b0f) also vulnerable ? Even if the home is created without
> 0777, the attacker should still be able to create the path before-hand so
> that they own it

You are correct - mkdir_p() will succeed if the directory already exists.

Comment 12 Doran Moppert 2019-07-30 01:50:57 UTC
Created rubygem-bundler tracking bugs for this issue:

Affects: epel-6 [bug 1734214]
Affects: fedora-all [bug 1734213]

Comment 14 Lukas Zapletal 2020-04-29 07:24:08 UTC
Upstream has fixed the issue: https://github.com/rubygems/bundler/pull/7416/files

Comment 20 errata-xmlrpc 2021-06-03 11:25:47 UTC
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7
  Red Hat Software Collections for Red Hat Enterprise Linux 7.7 EUS

Via RHSA-2021:2230 https://access.redhat.com/errata/RHSA-2021:2230

Comment 21 Product Security DevOps Team 2021-06-03 11:32:04 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2019-3881

Comment 22 errata-xmlrpc 2021-06-29 16:03:53 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2021:2588 https://access.redhat.com/errata/RHSA-2021:2588


Note You need to log in before you can comment on or make changes to this bug.