Bug 865940 (CVE-2012-4522)

Summary: CVE-2012-4522 ruby: unintentional file creation caused by inserting an illegal NUL character
Product: [Other] Security Response Reporter: Vincent Danen <vdanen>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: bkabrda, isenfeld, jrusnack, mfisher, mmcgrath, mmorsi, mtasaka, tagoh, vanmeeuwen+fedora, vondruch
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=moderate,public=20121012,reported=20121012,source=internet,cvss2=4.3/AV:N/AC:M/Au:N/C:N/I:P/A:N,rhel-5/ruby=affected,rhel-6/ruby=notaffected,fedora-all/ruby=affected,openshift-1/ruby=affected,openshift-enterprise-1/ruby193=affected,cwe=CWE-626
Fixed In Version: ruby 1.9.3p286 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-19 01:09:58 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On: 988686, 866567, 867750, 904022    
Bug Blocks: 816611, 865943    

Description Vincent Danen 2012-10-12 17:02:29 EDT
An upstream Ruby security notice [1] indicated that ruby suffered from a flaw where unintended files could be created if they contained a NUL characer in the file path or name.  Certain methods like IO#open did not check the filename passed to them, and just passed those strings to lower layer routines, which could lead to unintentional files being created, as demonstrated:

  p File.exists?("foo")      #=> false
  open("foo\0bar", "w") { |f| f.puts "hai" }
  p File.exists?("foo")      #=> true
  p File.exists?("foo\0bar") #=> raises ArgumentError

Upstream indicates that ruby 1.9.3 prior to patchlevel 286 is vulnerable.  An upstream patch is available [2].

[1] http://preview.ruby-lang.org/en/news/2012/10/12/poisoned-NUL-byte-vulnerability/
[2] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=37163
Comment 2 Vincent Danen 2012-10-15 11:56:35 EDT
This was assigned the name CVE-2012-4522:

http://seclists.org/oss-sec/2012/q4/72
Comment 3 Vincent Danen 2012-10-15 11:58:10 EDT
Created ruby tracking bugs for this issue

Affects: fedora-all [bug 866567]
Comment 5 Fedora Update System 2012-10-17 23:50:15 EDT
ruby-1.9.3.286-19.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 12 Huzaifa S. Sidhpurwala 2012-10-19 03:37:13 EDT
This issue did not affect the version of ruby as shipped with Fedora-16.

This issue was fixed in Fedora-17, via the following security advisory:

https://admin.fedoraproject.org/updates/FEDORA-2012-16086/ruby-1.9.3.286-18.fc17
Comment 13 Fedora Update System 2012-10-21 21:59:23 EDT
ruby-1.9.3.286-18.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 14 errata-xmlrpc 2013-01-08 00:08:59 EST
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2013:0129 https://rhn.redhat.com/errata/RHSA-2013-0129.html
Comment 16 Huzaifa S. Sidhpurwala 2013-01-08 04:21:45 EST
Statement:

This issue did not affect the versions of ruby as shipped with Red Hat Enterprise Linux 6.
Comment 18 errata-xmlrpc 2013-02-28 14:08:24 EST
This issue has been addressed in following products:

  RHEL 6 Version of OpenShift Enterprise

Via RHSA-2013:0582 https://rhn.redhat.com/errata/RHSA-2013-0582.html