OpenSSLã®èå¼±æ§(CVE-2014-3511)ã§TLSãããã³ã«ã®åºç¤ãå¦ã¶
1. ã¯ããã«ã
æ¨æ¥ OpenSSLã®ãã¼ã¸ã§ã³ã¢ãããã¢ãã¦ã³ã¹ãããï¼ã¤ã®èå¼±æ§ãå
¬éããã¾ããããã¼ã¸ã§ã³ã¢ããã®æ°æ¥åã«OpenSSLã®æ¬¡æãªãªã¼ã¹äºåãã¢ãã¦ã³ã¹ããã¦ãã¾ããããã¡ããã© BlackHat éå¬åæ¥ã«ããããã¨ãããããªããã¾ãé大ãªèå¼±æ§ã®ä¿®æ£ãå
¥ãããããªããã¨ãããããã¦ãã¾ãããèãéãã¦ã¿ãã¨HeatBleedç¨ã®å¤§äºã§ã¯ãªããããã²ã¨å®å¿ã§ãã
æ¨æ¥å
¬éãããOpenSSLã®ï¼ã¤ã®èå¼±æ§ã®ãã¡ãTLS ãããã³ã«ãã¦ã³ã°ã¬ã¼ãæ»æ (CVE-2014-3511)ã®ä¿®æ£ãè¦ã¦ããã¨ãããããã¯TLSãããã³ã«ãå¦ã¶ããé¡æã«ãªããªãã¨ãµã¨æãã¤ãã試ãã«ãã®Opensslã®èå¼±æ§ã®è©³ç´°ãTLSãããã³ã«ã®åºç¤ã«åããã¦æ¸ãã¦ã¿ã¾ããã
ã¡ãã£ã¨é·ãã§ãããTLSãããã³ã«ã®ä»çµã¿ï¼ã®ä¸é¨ï¼ãç¥ãããæ¹ã¯ãèªã¿ãã ããã
2. OpenSSLã®èå¼±æ§ CVE-2014-3511ã¨ã¯ã
ãã®èå¼±æ§(CVE-2014-3511)ã¯ã©ããªãã®ã§ããããï¼
本家 OpenSSLのアナウンスãã該å½é¨åã翻訳ããã¨ã
OpenSSL TLS ãããã³ã«ãã¦ã³ã°ã¬ã¼ãæ»æ (CVE-2014-3511)
=====================================================
OpenSSLã®SSL/TLSãµã¼ãã³ã¼ãã®ä¸å ·åã«ãã£ã¦ãClientHelloã¡ãã»ã¼ã¸ãä¸æ£ã«åå²ãããã¨TLS1.0ããé«ããã¼ã¸ã§ã³ã使ããã®ã«TLS1.0ã§ãã´ã·ã¨ã¼ã·ã§ã³ãã¦ãã¾ãã¾ãã
ããã«ãã£ã¦Man In the Middle ã®æ»æè ãã¯ã©ã¤ã¢ã³ãã®TLSã¬ã³ã¼ããå¤æ´ããã¨ãµã¼ãã¨ã¯ã©ã¤ã¢ã³ãã®ä¸¡è ãTLS1.0以ä¸ãå©ç¨ã§ããã«ãé¢ãããå¼·å¶çã«TLS1.0ã«ãã¦ã³ã°ã¬ã¼ãããããã¨ãã§ãã¾ãã
OpenSSL 1.0.1 SSL/TLSãµã¼ãå©ç¨è 㯠1.0.1i ã¸ã¢ããã°ã¬ã¼ããã¹ãã§ãã
ã¨è¨è¼ããã¦ãã¾ãããã£ã¨çµµã§æãã¨ä¸å³ãªæãã§ãããã
ä¸è¬çã«ãã¦ã³ã°ã¬ã¼ãæ»æãå¯è½ã«ãªãã¨ãæªæã®ãã第ä¸è
ã«ãã£ã¦æå³ããèå¼±æ§ãæã¤ãããã³ã«ãã¼ã¸ã§ã³ã¸å¼·å¶çã«æ¥ç¶ããããã¨ã«ãªãããããã¨ã£ãããã«ãã¦æ§ã
ãªæ»æãéä¿¡ä¸ã§åãããã¨ã«ãªãã¾ãã TLSv1.0ã«é¢ãã¦ã¯ãCBCã¢ã¼ãã®å©ç¨ã«èå¼±æ§ãåå¨ããããæ°ãä»ãããã¨ãå¿
è¦ã§ãã
3. TLSãããã³ã«ã®åºç¤
ãã®èå¼±æ§ãã¡ããã¨ç解ããã«ã¯ãTLSãããã³ã«ãã¼ã¿ã®ãã©ã¼ããããåæãã³ãã·ã§ã¤ã¯ã®ä»çµã¿ãç解ãããã¨ãå¿ è¦ã§ãã
3.1 TLSãããã³ã«ãã¼ã¿ãã©ã¼ããã
TLSãããã³ã«ãã¼ã¿ãã©ã¼ãããã®æ¦è¦ãä¸å³ã«ç¤ºãã¾ãã
TLSã®ãã¼ã¿ã¯å¿
ãå
é ã« TLS Record Layer ã¨ããï¼ãã¤ãã®ããããä»ä¸ããã¾ãããã®å¾ã«ï¼ç¨®é¡ã®ã¡ãã»ã¼ã¸ãç¶ãã¾ããä»åã®ä¸»å½¹ã¯ãHandshakeã¡ãã»ã¼ã¸ã§ããHandshakeã¡ãã»ã¼ã¸ã¯ãæå·ã証ææ¸ãªã©ã®TLSéä¿¡ã«å¿
è¦ãªæ
å ±ããµã¼ãã»ã¯ã©ã¤ã¢ã³ãéã§å
±æããããã«ç¨ãã¾ããHandshakeã¯10種é¡è¦å®ãããä»ååé¡ã¨ãªã ClientHello 㯠0x01 çªã§ç»é²ããã¦ãã¾ãã
Record Layer ã¯æ大14bité·(16kãã¤ã)ã®ã¡ãã»ã¼ã¸ãã¼ã¿ãæ±ãã¾ãããããè¤æ°ã®ãã³ãã·ã§ã¤ã¯ã¡ãã»ã¼ã¸ãï¼ã¤ã®Recordã«ã¾ã¨ãããã1ã¤ã®ãã³ãã·ã§ã¤ã¯ã¡ãã»ã¼ã¸ãè¤æ°ã®Recordã«åå²ãããã¨ãã§ãã¾ããä»åã®èå¼±æ§ã¯ãåå²ãè¡ããã¨ã«ãã£ã¦çºçãããã®ã§ããã
3.2 TLSåæãã³ãã·ã§ã¤ã¯
ä¸çªæåã«ãµã¼ãã¯ã©ã¤ã¢ã³ãéã§TLSæ¥ç¶ãéå§ããéã«ãä¸å³ã®éãè¤æ°ã® Handshake ã®ã¡ãã»ã¼ã¸ããµã¼ãã»ã¯ã©ã¤ã¢ã³ãéã§äº¤æãåãã¾ãã
ããããã® Handshake ã¡ãã»ã¼ã¸ã«ã¯å½¹å²ãããã¾ãããä¸çªæåã® ClientHello 㨠ServerHello ã®ããåãã§ã¯åæ¹ãå©ç¨ããTLSã®ãã¼ã¸ã§ã³ãæå·ã¢ã«ã´ãªãºã ãªã©ã決å®ãã¾ããä»åã®ãã¦ã³ã°ã¬ã¼ãæ»æã¯ãæåã®ClientHelloãæä½ããææ³ã§ãã
3.3 ClientHelloã®ãã¼ã¿ãã©ã¼ããã
ä»åã®æ³¨ç®ãã¼ã¿ãClientHelloã®ãã¼ã¿ãã©ã¼ããããè¦ã¦ã¿ã¾ãã
1ãã¤ãã®ClientHelloã®ã¡ãã»ã¼ã¸ã¿ã¤ã(0x01)ã¨3ãã¤ãåã®ClientHelloã®ã¡ãã»ã¼ã¸é·ããã£ã¼ã«ãã®æ¬¡ã«ã¯ã©ã¤ã¢ã³ãã®ãããã³ã«ãã¼ã¸ã§ã³ã表ã2ãã¤ãã®ãã£ã¼ã«ãï¼ã¡ã¸ã£ã¼ã¨ãã¤ãã¼ï¼ãç¾ãã¾ããããã«ã¯ã©ã¤ã¢ã³ããå©ç¨ã§ããTLSã®æé«ãã¼ã¸ã§ã³ãæå®ããã¾ãã
ãµã¼ããClientHelloè¦ã¦ã©ã®ãã¼ã¸ã§ã³ã使ããé¸æããServerHelloã使ã£ã¦ã¯ã©ã¤ã¢ã³ãã«è¿ãã¾ããé常ã¯ã¯ã©ã¤ã¢ã³ãã対å¿ãã¦ããTLSãã¼ã¸ã§ã³ã®ä¸ã§ãµã¼ããæãåªå
度ãé«ããããã³ã«ãã¼ã¸ã§ã³ãé¸æãã¾ãã
OpenSSL㧠SSLv23äºæã¡ã½ããã§ãµã¼ããå©ç¨ããå ´åãå é ã®11ãã¤ããè¦ã¦ClientHelloã®å¦çãè¡ãã¾ããä»åãã®é¨åã«åé¡ãããã¾ããã
ãªããTLSã®ãããã³ã«ãã¼ã¸ã§ã³ã¯ãSSLæ代ããç¶ãã¦ãããã®ã§ TLS1.0 㯠SSL3.1æç®ã¨ãªãã¾ããéå»ãæ¨æºåã®éç¨ã«ããã¦è«¸æã®äºæ ããSSLããTLSã¸ã®å称å¤æ´ãè¡ããã¾ãããããããã³ã«ä¸ã§ã¯ã¾ã SSLãç¶ãã¦ãããã¨ã«ãªãã¾ãã
以ä¸ã§TLSãããã³ã«ã®åºç¤ç·¨ã¯çµããã§ãã
4. CVE-2014-3511èå¼±æ§ã®ä¸èº«
ClientHelloãã©ããããã®ã§ãã©ãããå½¹å²ãæã¤ã®ãç解ããã¨ããã§ãä»åã®èå¼±æ§ãè¦ã¦ã¿ã¾ãã
ä¿®æ£åæã® diff ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ããFix protocol downgrade bug in case of fragmented packets
* Client Hello message, this would be difficult, and we'd have * to read more records to find out. * No known SSL 3.0 client fragments ClientHello like this, - * so we simply assume TLS 1.0 to avoid protocol version downgrade - * attacks. */ + * so we simply reject such connections to avoid + * protocol version downgrade attacks. */ if (p[3] == 0 && p[4] < 6) { -#if 0 SSLerr(SSL_F_SSL23_GET_CLIENT_HELLO,SSL_R_RECORD_TOO_SMALL); goto err; -#else - v[1] = TLS1_VERSION_MINOR; -#endif }
p[3],p[4]ã¯ãTLS Record Layer ã®é·ããã£ã¼ã«ãã§ããä¿®æ£åã§ã¯ ClientHello ã® TLS Record Layer ã®é·ãã6ãã¤ãããå°ãããã°ãTLSã®ãã¤ãã¼ãã¼ã¸ã§ã³ã1(=TLS1.0)ã«ããã¨ãããã¨ã§ããï¼ãã以åã«ã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ãï¼ã§ãããã¨ã®ãã§ãã¯ã¯æ¸ãã§ãã¾ãï¼
ã¨ãããã¨ã¯ãã¯ã©ã¤ã¢ã³ããæé«ã§TLS.1.2ãå©ç¨å¯è½ã§ ClientHello ãéããã¨ãClientHello ã6ãã¤ãããå°ããåå²ããã¦ããã°åçç¡ç¨ã§å¼·å¶çã«TLS1.0 ã«ãªã£ã¦ãã¾ãã¾ããTLSã¬ã³ã¼ãã®åå²ã¯ãçµè·¯ã®éä¸ã§å®¹æã«è¡ãã¾ãã®ã§ Man-in-the-Middle ã«ãããã¦ã³ã°ã¬ã¼ãæ»æã¯å¯è½ã§ãã
ã§ãã©ããã¦ãããªã£ãã®ã§ããããï¼ ãã®ç®æå¦çãå
¥ã£ãéå»ã®ã³ãããã追ã£ããã¦ã¿ã¾ããChangeLogã«ã¯ããè¨è¼ããã¦ãã¾ãã
Assume TLS 1.0 when ClientHello fragment is too short
Instead of aborting with an error,simply choose the highest available protocol version (i.e.,TLS 1.0 unless it is disabled).
ã¨ã©ã¼ã§çµäºãã代ããã«ãå©ç¨ã§ããä¸çªé«ããããã³ã«ãã¼ã¸ã§ã³ãåã«é¸ã¶ããã«ããã(ç¹ã« TLS1.0ãç¡å¹ããã¦ãªããã°ï¼
ããããã¨ãã¨6ãã¤ãããå°ããClientHelloã¯ã¨ã©ã¼ã«ãã¦ããã®ã§ããã2001å¹´å½ææããã¼ã¸ã§ã³ã®é«ãTLS1.0ã決ãæã¡ã§å®ç¾©ãã¦ãã¾ã£ãããã§ããTLS1.1ã1.2ãã§ãããã¨ãæ³å®ãã¦ãªãã£ãã®ã§ãããã
SSLv3ã¸ã®ãã¦ã³ã°ã¬ã¼ã対çã§ä¿®æ£ãããã¨ããä»åº¦ã¯13å¹´å¾ã«ãã¦ã³ã°ã¬ã¼ãèå¼±æ§ãå¼ãèµ·ãããã¨ã«ãªãã¨ã¯â¦ ãªãã¨ãç®èãªãã¨ã§ãã
5. CVE-2014-3511ã®èå¼±æ§ã試ã
èå¼±æ§ã®è©³ç´°ãåãã£ãã¨ããã§ãå®éã«è©¦ãã¦ã¿ã¾ããClientHelloã5ãã¤ã以ä¸ã«åå²ãã¦éãã°ããã ãã§ããã¾ãã¯ãã¹ãç¨ã®æå°ClientHelloãä½ã£ã¦ã¿ã¾ãããã
ããã47ãã¤ãã§åºæ¥ã¾ãããã®Hexæååããããã ä¸è¨ã®Nodeã®ã³ã¼ãã使ã£ã¦ OpenSSL(1.0.1h)ã®ãµã¼ãã«éã£ã¦ã¿ã¾ãã
var net = require('net'); // TLSã¬ã³ã¼ãåå²ã®ãã©ã° var frag = process.argv[2] === 'frag' ? true : false; // HexæååãBufferã«å¤æããé¢æ° function HexStrToBuf(str) { var buf = new Buffer(str.length/2); for(var i = 0; i < str.length; i += 2) { buf.writeUInt8(parseInt(str.substr(i,2), 16), i/2); } return buf; } var client_hello = "160301002f0100002b03030000000000000000000000000000000000000000000000000000000000000000000004009c00350100"; var client_hello_frag1 = "16030100050100002b03"; var client_hello_frag2 = "160301002a030000000000000000000000000000000000000000000000000000000000000000000004009c00350100"; var handshake = HexStrToBuf(client_hello); var handshake_frag1 = HexStrToBuf(client_hello_frag1); var handshake_frag2 = HexStrToBuf(client_hello_frag2); var s = net.connect({port: 443}, function() { if (frag) { s.write(handshake_frag1); s.write(handshake_frag2); } else { s.write(handshake); } }); s.on('data', function(b) { console.log(b); });
ã¾ãã¯åå²ããã«Handshakeãè¦ã¦ã¿ã¾ããåä¿¡ãã¼ãµãæ¸ãã¦ãããã®ã§ããã客観æ§ãä¿ã¤ããWiresharkã®çµæãè¼ãã¾ãã
ClientHelloã¯ã¡ããã¨æå³ãããã£ã¼ã«ãã§éä¿¡ã§ãã¦ãã¾ããOpenSSLã®ãµã¼ãããã¯ãç¡äº ServerHelloãè¿ã£ã¦ãã¾ããã
ãã£ã¼ã«ãã確èªããã¨ãã¼ã¸ã§ã³ã¯ TLS1.2ãæå·ã¢ã«ã´ãªãºã ã GCM ãé¸æããã¦ãã¾ããããããã
次ã«ããããClientHelloãåå²ãã¦éãã¾ããWiresharkã§ã¯åå²ãæ£ãããã³ã¼ãã§ããªãã®ã§ ServerHello ã ããè¼ãã¾ãã
çµæ
ãã£ã¨ãèå¼±æ§çºçï¼ ServerHello ãããµã¼ã㯠TLS1.0 ãé¸æããæå·ã¢ã«ã´ãªãºã ã® CBCã®æ¹ã«ãªã£ã¦ãã¾ãããã¦ã³ã°ã¬ã¼ãæ»æã®æåã§ãã
ä»åº¦ã¯ãèå¼±æ§ãä¿®æ£ãã OpenSSL 1.0.1i ã®ãµã¼ãã§è©¦ãã¾ãã以ä¸ã®éãæ¥ç¶ãåæãããã¨ã©ã¼ã¡ãã»ã¼ã¸ããµã¼ãå´ã«ç¡äºåºåããã¾ãããããããã
$ ./apps/openssl version OpenSSL 1.0.1i 6 Aug 2014 $ sudo ./apps/openssl s_server -cert ~/tmp/cert/bundle.crt -key ~/tmp/cert/server.key -port 443Using default temp DH parameters Using default temp ECDH parameters ACCEPT ERROR 140379538994848:error:1407612A:SSL routines:SSL23_GET_CLIENT_HELLO:record too small:s23_srvr.c:355: shutting down SSL CONNECTION CLOSED ACCEPT
ã»ãã¥ãªãã£ã«é¢é£ããæè¡ã¯å³å¯ã«å®ç¾©ãããã®ã§ä¸è¬çã«ç解ãé£ãããã¨ãå¤ãã§ãããããããèå¼±æ§ã®é¡æãè¦ã¤ãã¦å°ãã§ãç解ãé²ãã¨æ¥½ãããªãããããªããã¨æãã¾ãã