CVE-2012-4522: Medium severity ruby-lang Ruby vulnerability

Published Oct 12, 2012
·
Updated

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

Other sources

The rbgetpathcheck function in file.c in Ruby 1.9.3 before patchlevel 286 and Ruby 2.0.0 before r37163 allows context-dependent attackers to create files in unexpected locations or with unexpected names via a NUL byte in a file path.

— MITRE

Affected Software

3 affected componentsFixes available
ruby-lang Ruby=1.9.3
ruby-lang Ruby=2.0.0
redhat/ruby<1.9.3
1.9.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/ruby to a version that resolves this vulnerability.

    Fixed in 1.9.3
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Patch r37163

Event History

Oct 12, 2012
Data Sourced
via Red Hat·09:02 PM
DescriptionSeverityAffected Software
Nov 24, 2012
CVE Published
via MITRE·08:00 PM
Data Sourced
via MITRE·08:00 PM
Description
Data Sourced
08:55 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2012-4522?

CVE-2012-4522 has a medium severity rating, allowing attackers to exploit file creation vulnerabilities.

2

How do I fix CVE-2012-4522?

To fix CVE-2012-4522, update Ruby to version 1.9.3 patchlevel 286 or later, or 2.0.0 revision r37163 or later.

3

What are the implications of CVE-2012-4522?

Exploitation of CVE-2012-4522 can lead to the creation of files in unexpected locations, potentially compromising system integrity.

4

Which versions of Ruby are affected by CVE-2012-4522?

CVE-2012-4522 affects Ruby versions 1.9.3 prior to patchlevel 286 and 2.0.0 prior to r37163.

5

Can CVE-2012-4522 be exploited remotely?

CVE-2012-4522 requires context-dependent access, meaning it cannot be exploited remotely without specific conditions.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203