Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 278566

Summary: dev-ruby/rubygems: gem install overwrites arbitrary files in /usr/bin
Product: Gentoo Security Reporter: Alex Legler (RETIRED) <a3li>
Component: VulnerabilitiesAssignee: Gentoo Security <security>
Status: RESOLVED FIXED    
Severity: minor CC: kfm, m.debruijne, ruby
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://redmine.ruby-lang.org/issues/show/1800
Whiteboard: B3 [noglsa]
Package list:
Runtime testing required: ---
Attachments:
Description Flags
Reproducer, overwrites /usr/bin/less none

Description Alex Legler (RETIRED) archtester gentoo-dev Security 2009-07-21 11:18:51 UTC
If a gem includes an executable, gem install will merge them into /usr/bin/ without checking if the executable already exists, leading to arbitrary file overwriting.

I'll attach a reproducer.

References:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/24472
http://translate.google.com/translate?prev=hp&hl=en&js=y&u=http%3A%2F%2Fwota.jp%2Fac%2F%3Fdate%3D20090604%23p01&sl=ja&tl=en&history_state0=
Comment 1 Alex Legler (RETIRED) archtester gentoo-dev Security 2009-07-21 11:20:48 UTC
Created attachment 198688 [details]
Reproducer, overwrites /usr/bin/less

Reproduce with "sudo gem install testgem-0.0.1.gem"
Comment 2 Gordon Malm (RETIRED) gentoo-dev 2009-07-21 21:24:33 UTC
gem will also install executables and libraries world-writeable if they are distributed that way in the prepared gem. :p
Comment 4 Diego Elio Pettenò (RETIRED) gentoo-dev 2009-07-30 11:27:58 UTC
This is a references loop since my post was actually inspired once Alex told me of the issue ^^
Comment 5 Alex Legler (RETIRED) archtester gentoo-dev Security 2010-05-23 09:26:58 UTC
Still not fixed. We'll likely do this in Gentoo by not installing gem binaries to /usr/bin
Comment 6 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-08-03 16:14:02 UTC
1.3.7-r2 no longer installs in /usr/bin, feel free to consider closing this or releasing a GLSA.
Comment 7 Chris Reffett (RETIRED) gentoo-dev Security 2013-09-03 02:01:58 UTC
Fixed for several years. Closing noglsa.