Ruby’s SSL client implements hostname identity check but it does not properly handle hostnames in the certificate that contain null bytes.
OpenSSL::SSL.verifycertificateidentity implements RFC2818 Server Identity check for Ruby’s SSL client but it does not properly handle hostnames in the subjectAltName X509 extension that contain null bytes.
Existing code in lib/openssl/ssl.rb uses OpenSSL::X509::Extension#value for extracting identity from subjectAltName. Extension#value depends OpenSSL function X509V3EXTprint() and for dNSName of subjectAltName it utilizes sprintf() that is known as null byte unsafe. As the result Extension#value returns ‘www.ruby-lang.org’ if the subjectAltName is ‘www.ruby-lang.org\0.example.com’ and OpenSSL::SSL.verifycertificateidentity wrongly identifies the certificate is for ‘www.ruby-lang.org’.
When a CA a SSL client trusts allows to issue the server certificate that has null byte in subjectAltName, remote attackers can obtain the certificate for ‘www.ruby-lang.org\0.example.com’ from the CA to spoof ‘www.ruby-lang.org’ and do man-in-the-middle between Ruby’s SSL client and SSL servers.
External References:
http://www.ruby-lang.org/en/news/2013/06/27/hostname-check-bypassing-vulnerability-in-openssl-client-cve-2013-4073/
Originally, Common Vulnerabilities and Exposures assigned an identifier of CVE-2011-1005 to the following vulnerability:
The safe-level feature in Ruby 1.8.6 through 1.8.6-420, 1.8.7 through 1.8.7-330, and 1.8.8dev allows context-dependent attackers to modify strings via the Exception#tos method, as demonstrated by changing an intended pathname.
with the following upstream patch: [1] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=30903&view=revision
Based on later upstream patch for different (CVE-2012-4464 and CVE-2012-4466) issues: [2] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=37068
it was found that original upstream 1.8.x ruby patch for CVE-2011-1005 issue was not complete, when the NameError#tos() method was used on / with Ruby objects (the test logic in 'testtostaintnesspropagation' test from [1] was actually reversed, so the test returned success also on still vulnerable instances).
Acknowledgements:
This issue was discovered by Vit Ondruch of Red Hat.
Originally, Common Vulnerabilities and Exposures assigned an identifier CVE-2011-1005 to the following vulnerability:
The safe-level feature in Ruby 1.8.6 through 1.8.6-420, 1.8.7 through 1.8.7-330, and 1.8.8dev allows context-dependent attackers to modify strings via the Exception#tos method, as demonstrated by changing an intended pathname.
Later it was reported: [1] http://www.openwall.com/lists/oss-security/2012/10/02/4
that the Ruby nameerrmesgtostr() method is vulnerable to the similar flaw.
Relevant upstream patch: [2] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=37068
A race condition was found in the way the secure implementation of Ruby fileutils' remove system entries method (removeentrysecure()), removed directory trees. A local attacker could use this flaw to conduct symbolic link attacks, leading to removal of arbitrary files or directories on the system.
References: [1] http://www.ruby-lang.org/en/news/2011/02/18/fileutils-is-vulnerable-to-symlink-race-attacks/
Upstream patch (against trunk): [2] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30896
A security flaw was found in the Ruby method, translating message of the exception into string representation. An attacker could use this flaw to modify arbitrary untainted strings into their tainted equivalents by tricking the safe level mechanism of this method.
References: [1] http://www.ruby-lang.org/en/news/2011/02/18/exception-methods-can-bypass-safe/
Upstream patch (against ruby18 branch): [2] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30903
A vulnerability was found on WEBrick, a part of Ruby's standard library. WEBrick lets attackers to inject malicious escape sequences to its logs, making it possible for dangerous control characters to be executed on a victim's terminal emulator.
We already have a fix for it. Releases for every active branches are to follow this announce. But for a meantime, we recommend you to avoid looking at your WEBrick logs, until you update your WEBrick process. Detailed description
Terminal escape sequences are used to allow various forms of interaction between a terminal and a inside process. The problem is that those sequences are not intended to be issued by untrusted sources; such as network inputs. So if a remote attacker could inject escape sequences into WEBrick logs, and a victim happen to consult them through his/her terminal, the attacker could take advantages of various weaknesses in terminal emulators.
http://www.ruby-lang.org/en/news/2010/01/10/webrick-escape-sequence-injection/
Common Vulnerabilities and Exposures assigned an identifier CVE-2008-3905 to the following vulnerability:
resolv.rb in Ruby 1.8.5 and earlier, 1.8.6 before 1.8.6-p287, 1.8.7 before 1.8.7-p72, and 1.9 r18423 and earlier uses sequential transaction IDs and constant source ports for DNS requests, which makes it easier for remote attackers to spoof DNS responses, a different vulnerability than CVE-2008-1447.
References: http://www.ruby-lang.org/en/news/2008/08/08/multiple-vulnerabilities-in-ruby/ http://www.openwall.com/lists/oss-security/2008/09/04/9
Upstream patch: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18424
Description of problem:
Ruby upstream has announced multiple security vulnerabilities related with not proper Ruby access restriction to critical variables and methods at various safe levels:
a, untracevar is permitted at safe level 4. Affects: rhel-2.1->rhel-5.3 Proposed patch: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=17692
b, $PROGRAMNAME may be modified at safe level 4. Doesn't Affect: rhel-2.1->rhel-4.8 Affects: rhel-5.2.z, rhel-5.3 Proposed patch: ? c, Insecure methods may be called at safe level 1-3 Affects: rhel-2.1->rhel-5.3 Proposed patch: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=17696
d, Syslog operations are permitted at safe level 4. Affects: rhel-2.1->rhel-5.3 Proposed patch: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=17809
Version-Release number of selected component (if applicable): All versions of the Ruby package as shipped with Red Hat Enterprise Linux 2.1, 3, 4 and 5.
How reproducible: Always
Steps to Reproduce: See reproducers.
Additional info -- public mention of this issue:
http://www.ruby-lang.org/en/news/2008/08/08/multiple-vulnerabilities-in-ruby/
Common Vulnerabilities and Exposures assigned an identifier CVE-2008-3657 to the following vulnerability:
The dl module in Ruby 1.8.5 and earlier, 1.8.5 through 1.8.6-p286, 1.8.7 through 1.8.7-p71, and 1.9 through r18423 does not check "taintness" of inputs, which allows context-dependent attackers to bypass safe levels and execute dangerous functions by accessing a library using DL.dlopen.
Refences: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=494401 http://www.ruby-lang.org/en/news/2008/08/08/multiple-vulnerabilities-in-ruby/
Algorithmic complexity vulnerability in the WEBrick::HTTPUtils.splitheadervalue function in WEBrick::HTTP::DefaultFileHandler in WEBrick in Ruby 1.8.5 and earlier, 1.8.6 through 1.8.6-p286, 1.8.7 through 1.8.7-p71, and 1.9 through r18423 allows context-dependent attackers to cause a denial of service (CPU consumption) via a crafted HTTP request that is processed by a backtracking regular expression.
Drew Yao of the Apple Product Security team reported an integer overflow leading to a memory mis-allocation and heap overflow in the rbarysplice() function used by ruby interpreter for handling arrays. Problematic reallocation is:
if (len >= RARRAY(ary)->aux.capa) { --> REALLOCN(RARRAY(ary)->ptr, VALUE, len); RARRAY(ary)->aux.capa = len; }
This flaw can be used to crash and possibly execute arbitrary code with the privileges of Ruby application which use untrusted input in array operations.
Acknowledgements:
Red Hat would like to thank Drew Yao of the Apple Product Security team for reporting this issue.
Drew Yao of the Apple Product Security team reported an integer overflow leading to a bypass of memory re-allocation causing a heap overflow in the rbarysplice() function used by ruby interpreter for handling arrays. Problematic addition that may overflow:
if (beg >= RARRAY(ary)->len) { --> len = beg + rlen; if (len >= RARRAY(ary)->aux.capa) { REALLOCN(RARRAY(ary)->ptr, VALUE, len);
The addition may overflow causing len to be negative and due to that, REALLOCN is not called. This flaw can be used to crash and possibly execute arbitrary code with the privileges of Ruby application which use untrusted input in array operations.
Acknowledgements:
Red Hat would like to thank Drew Yao of the Apple Product Security team for reporting this issue.
Drew Yao of the Apple Product Security team reported that the rbstrformat() function uses alloca() memory allocation function in insecure way, causing memory address returned by alloca() to be out of stack memory space. This can be used to crash and possibly execute arbitrary code with the privileges of Ruby application which use untrusted input in string operations.
Acknowledgements:
Red Hat would like to thank Drew Yao of the Apple Product Security team for reporting this issue.
Drew Yao of the Apple Product Security team reported an integer overflow leading to a memory mis-allocation and heap overflow in the rbarystore() function used by ruby interpreter for handling arrays. This can be used to crash and possibly execute arbitrary code with the privileges of Ruby application which use untrusted input in array operations.
Acknowledgements:
Red Hat would like to thank Drew Yao of the Apple Product Security team for reporting this issue.
Drew Yao of the Apple Product Security team reported an integer overflow leading to a memory mis-allocation and heap overflow in the rbstrbufappend() function used by ruby interpreter for handling strings. This can be used to crash and possibly execute arbitrary code with the privileges of Ruby application which use untrusted input in string operations.
Acknowledgements:
Red Hat would like to thank Drew Yao of the Apple Product Security team for reporting this issue.
The REXML module in Ruby 1.8.6 through 1.8.6-p287, 1.8.7 through 1.8.7-p72, and 1.9 allows context-dependent attackers to cause a denial of service (CPU consumption) via an XML document with recursively nested entities, aka an "XML entity explosion."
The regular expression engine (regex.c) in Ruby 1.8.5 and earlier, 1.8.6 through 1.8.6-p286, 1.8.7 through 1.8.7-p71, and 1.9 through r18423 allows remote attackers to cause a denial of service (infinite loop and crash) via multiple long requests to a Ruby socket, related to memory allocation failure, and as demonstrated against Webrick.
The BigDecimal library in Ruby 1.8.6 before p369 and 1.8.7 before p173 allows context-dependent attackers to cause a denial of service (application crash) via a string argument that represents a large number, as demonstrated by an attempted conversion to the Float data type.