[前][次][番号順一覧][スレッド一覧]

ruby-changes:29964

From: usa <ko1@a...>
Date: Wed, 17 Jul 2013 10:19:50 +0900 (JST)
Subject: [ruby-changes:29964] usa:r42016 (ruby_1_9_3): merge revision(s) 41805: [Backport #8575]

usa	2013-07-17 10:19:39 +0900 (Wed, 17 Jul 2013)

  New Revision: 42016

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42016

  Log:
    merge revision(s) 41805: [Backport #8575]
    
    * lib/openssl/ssl.rb: Fix SSL client connection crash for SAN marked
      critical.
      The patch for CVE-2013-4073 caused SSL crash when a SSL server returns
      the certificate that has critical SAN value.  X509 extension could
      include 2 or 3 elements in it:
      [id, criticality, octet_string] if critical,
      [id, octet_string] if not.
      Making sure to pick the last element of X509 extension and use it as
      SAN value.
      [ruby-core:55685] [Bug #8575]
      Thank you @nahi for providing the patch!

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/openssl/lib/openssl/ssl-internal.rb
    branches/ruby_1_9_3/test/openssl/test_ssl.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 42015)
+++ ruby_1_9_3/ChangeLog	(revision 42016)
@@ -1,3 +1,20 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Wed Jul 17 10:14:37 2013  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* lib/openssl/ssl-internal.rb: Fix SSL client connection crash for SAN
+	  marked critical.
+	  The patch for CVE-2013-4073 caused SSL crash when a SSL server returns
+	  the certificate that has critical SAN value.  X509 extension could
+	  include 2 or 3 elements in it:
+
+	  [id, criticality, octet_string] if critical,
+	  [id, octet_string] if not.
+
+	  Making sure to pick the last element of X509 extension and use it as
+	  SAN value.
+	  [ruby-core:55685] [Bug #8575]
+
+	  Thank you @nahi for providing the patch!
+
 Wed Jul 17 09:59:33 2013  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_core.c: fixed coding error [ruby-core:55337].
Index: ruby_1_9_3/ext/openssl/lib/openssl/ssl-internal.rb
===================================================================
--- ruby_1_9_3/ext/openssl/lib/openssl/ssl-internal.rb	(revision 42015)
+++ ruby_1_9_3/ext/openssl/lib/openssl/ssl-internal.rb	(revision 42016)
@@ -88,7 +88,7 @@ module OpenSSL https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ext/openssl/lib/openssl/ssl-internal.rb#L88
       should_verify_common_name = true
       cert.extensions.each{|ext|
         next if ext.oid != "subjectAltName"
-        id, ostr = OpenSSL::ASN1.decode(ext.to_der).value
+        ostr = OpenSSL::ASN1.decode(ext.to_der).value.last
         sequence = OpenSSL::ASN1.decode(ostr.value)
         sequence.value.each{|san|
           case san.tag
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 42015)
+++ ruby_1_9_3/version.h	(revision 42016)
@@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 453
+#define RUBY_PATCHLEVEL 454
 
 #define RUBY_RELEASE_DATE "2013-07-17"
 #define RUBY_RELEASE_YEAR 2013
Index: ruby_1_9_3/test/openssl/test_ssl.rb
===================================================================
--- ruby_1_9_3/test/openssl/test_ssl.rb	(revision 42015)
+++ ruby_1_9_3/test/openssl/test_ssl.rb	(revision 42016)
@@ -352,25 +352,32 @@ class OpenSSL::TestSSL < OpenSSL::SSLTes https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/openssl/test_ssl.rb#L352
   end
 
   def test_verify_certificate_identity
-    # creating NULL byte SAN certificate
+    [true, false].each do |criticality|
+      cert = create_null_byte_SAN_certificate(criticality)
+      assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com'))
+      assert_equal(true,  OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com\0.evil.com'))
+      assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.255'))
+      assert_equal(true,  OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.1'))
+      assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '13::17'))
+      assert_equal(true,  OpenSSL::SSL.verify_certificate_identity(cert, '13:0:0:0:0:0:0:17'))
+    end
+  end
+
+  # Create NULL byte SAN certificate
+  def create_null_byte_SAN_certificate(critical = false)
     ef = OpenSSL::X509::ExtensionFactory.new
     cert = OpenSSL::X509::Certificate.new
     cert.subject = OpenSSL::X509::Name.parse "/DC=some/DC=site/CN=Some Site"
-    ext = ef.create_ext('subjectAltName', 'DNS:placeholder,IP:192.168.7.1,IP:13::17')
+    ext = ef.create_ext('subjectAltName', 'DNS:placeholder,IP:192.168.7.1,IP:13::17', critical)
     ext_asn1 = OpenSSL::ASN1.decode(ext.to_der)
     san_list_der = ext_asn1.value.reduce(nil) { |memo,val| val.tag == 4 ? val.value : memo }
     san_list_asn1 = OpenSSL::ASN1.decode(san_list_der)
     san_list_asn1.value[0].value = 'www.example.com\0.evil.com'
-    ext_asn1.value[1].value = san_list_asn1.to_der
+    pos = critical ? 2 : 1
+    ext_asn1.value[pos].value = san_list_asn1.to_der
     real_ext = OpenSSL::X509::Extension.new ext_asn1
     cert.add_extension(real_ext)
-
-    assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com'))
-    assert_equal(true,  OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com\0.evil.com'))
-    assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.255'))
-    assert_equal(true,  OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.1'))
-    assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '13::17'))
-    assert_equal(true,  OpenSSL::SSL.verify_certificate_identity(cert, '13:0:0:0:0:0:0:17'))
+    cert
   end
 
   def test_tlsext_hostname

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r41805


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]