HTTP/2ã¨TLSã®éã§apacheãããã£ãèå¼±æ§(CVE-2016-4979)
0. çãã¾ã¨ã
- æ¨æ©apache2.4ã§HTTP/2å©ç¨æã«TLSã¯ã©ã¤ã¢ã³ãèªè¨¼ããã¤ãã¹ããèå¼±æ§(CVE-2016-4979)ãå ¬è¡¨ããã対ççããªãªã¼ã¹ããã¾ããã
- å®éã«è©¦ã㨠Firefoxã§èªè¨¼ãã¤ãã¹ãã§ãããã¨ã確èªã§ãã¾ããã
- HTTP/2ã§TLSã®ã¯ã©ã¤ã¢ã³ãèªè¨¼ãå©ç¨ããã«ã¯ä»æ§ä¸å¤§ããªå¶éããããSPDYæ代ããé·å¹´ã®èª²é¡ã¨ãªã£ã¦ãã¾ãã
- ãã®èª²é¡ã解決ãããããSecondary Certificate Authentication in HTTP/2ã¨ããæ¡å¼µä»æ§ãç¾å¨IETFã§è°è«ä¸ã§ãã
1. ã¯ããã«
ã¡ããã©æ¨æ©ãapache2.4ã®httpdãµã¼ãã®èå¼±æ§(CVE-2016-4979)ãå ¬éãããã»ãã¥ãªãã£ãªãªã¼ã¹ãè¡ããã¾ããã
CVE-2016-4979: X509 Client certificate based authentication can be bypassed when HTTP/2 is used
ãªãªã¼ã¹æãèªãã§ã¿ãã¨ããªã«ããapache-2.4ã§HTTP/2ã®å©ç¨æã«TLSã¯ã©ã¤ã¢ã³ãèªè¨¼ããã¤ãã¹ãããèå¼±æ§ã¨ã®ãã¨ãCVSS3ã¹ã³ã¢ã7.5ã§HIGHã
ã¯ã¦ãã¦HTTP/2ä»æ§(RFC7540)ã§ã¯TLSã¯ã©ã¤ã¢ã³ãèªè¨¼ã®å©ç¨ã¯é常ã«éå®çã§ãã¾ãå®ç¨çã§ã¯ãªãã¨æã£ã¦ãã¾ããããå¾ã¦ãã¦èå¼±æ§ã¨ã¯ãã¾ãå©ç¨ãããªãã¨ããã§èµ·ãããã®ã§ããä¿®æ£ããããããã1è¡ã§ããã
å®ã¯ã¡ããã©ä»IETFã®httpbis WGã§ã¯ã©ã¤ã¢ã³ãèªè¨¼ãå¯è½ã«ããæ°ããæ¡å¼µä»æ§ãã©ãããè°è«ä¸ã§ãããã®åéã¯ã¾ãã«ããããªãããã¯ãHTTP/2 ãTLSã®ä»æ§ã¨ç §ããããããªãå®è£ ãè¦ã¦ã¿ãã¨ããã®èå¼±æ§ã¯æ°ããä»æ§ã®èæ¯ã®èª¬æãã¿ã¨ãã¦ã¯ããã¿ãªã§ãã
å®éã«è©¦ãã¨HTTP/2å©ç¨æã«ã¯ã©ã¤ã¢ã³ãèªè¨¼ããã¤ãã¹ããèå¼±æ§ãåç¾ã§ãã¾ãããã¨ãããã¨ã§ããã®èå¼±æ§éãã¦TLSã¨HTTP/2ã®ä»æ§ã¨èª²é¡ãç解ã§ããªãããæ°ããã¨ã³ããªã¼ãæ¸ãã¦ã¿ã¾ãã
2. TLSã¯ã©ã¤ã¢ã³ãèªè¨¼ããã¤ãã¹ããapache-2.4ã®èå¼±æ§(CVE-2016-4979)ã¨ã¯ï¼
ãã®èå¼±æ§ã®ä¸èº«ã¯ãå®éã«è¦ã¦ã¿ãã®ãä¸çªã§ããããèå¼±æ§ã®ããapache-2.4.20ã§HTTP/2ã®ãµã¼ãããã¦ã¦ã¿ã¾ãã
/client_auth ã«ã¢ã¯ã»ã¹ããã¨ã¯ã©ã¤ã¢ã³ãèªè¨¼ãå¿ è¦ãªããã«apacheã®configãè¨å®ããã¢ã¯ã»ã¹ãããã©ã¦ã¶ã¯ã¯ã©ã¤ã¢ã³ã証ææ¸ãä½ãå ¥ãã¦ãªãFirefox47ã使ãã¾ãããå¾è¿°ããããChromeã§ã¯ãã®èå¼±æ§ã¯åç¾ãã¾ããã
ã¾ãããããã¼ã¸ / ãè¦ã¦ã¿ã¾ããéãã¤ããºããåºã¦ã¡ããã¨HTTP/2ã§ãã¼ã¸ãè¦ãã¾ããã³ã³ãã³ãã¯ã/client_auth ã¸ã®ãªã³ã¯ãè²¼ã£ã¦ããã¾ã ã
ãªã³ã¯ã辿ã£ã¦ /client_auth ã«ã¢ã¯ã»ã¹ããã¨Firefoxã«ã¯ã©ã¤ã¢ã³ã証ææ¸ãå
¨ãå
¥ãã¦ãªãã®ã§ã¨ã©ã¼ã«ãªãã¾ããã¯ã©ã¤ã¢ã³ãèªè¨¼ã¯ã¡ããã¨å¹ãã¦ãã¾ãã
ãã£ããå試è¡ãã¿ã³ãè¦ãã¦ããã®ã§ãåèªã¿è¾¼ã¿ãã¦ã¿ã¾ãããã
ããã¼ã/client_auth ã®ãã¼ã¸ãè¦ãã¡ããã¾ããããããã¢ã«ã³ã§ããä¸åº¦èªè¨¼ã¨ã©ã¼ã«ãªã£ã¦ãåèªã¿è¾¼ã¿ãããã¨ã¢ã¯ã»ã¹ã§ãã¦ãã¾ããããããã®èå¼±æ§ã®æ£ä½ã§ãã
--- a/modules/ssl/ssl_engine_kernel.c +++ b/modules/ssl/ssl_engine_kernel.c @@ -727,6 +727,7 @@ int ssl_hook_Access(request_rec *r) * on this connection. */ apr_table_setn(r->notes, "ssl-renegotiate-forbidden", "verify-client"); + SSL_set_verify(ssl, verify_old, ssl_callback_SSLVerify); return HTTP_FORBIDDEN; } /* optimization */
ã®ãããä¸è¡ãmod_sslã®å¦çã«ããã¦ãµã¼ãã®SSLã¤ã³ã¹ã¿ã³ã¹ãã¯ã©ã¤ã¢ã³ãã®èªè¨¼ãå¿ è¦ãã©ããå¤æãããã©ã° verify_mode ã®å¦çã«ãã°ããã£ãããã§ãã
3. HTTP/2ã®TLSã¯ã©ã¤ã¢ã³ãèªè¨¼ã®èª²é¡
HTTP/2ã®å¤§ããªç¹å¾´ã¯ãä¸ã¤ã®TCP/TLSæ¥ç¶ã§è¤æ°ã®HTTPãªã¯ã¨ã¹ãã»ã¬ã¹ãã³ã¹ãå¤éåãã¦ããã¨ãã§ãããã¨ã§ããããã«ãã£ã¦ãHTTP/1.1ã§æ§è½ã®ããã«ããã¯ã«ãªãå¾ã HTTP Head of Line Blocking ã®è§£æ¶ãå®ç¾ãã¾ãã
ä¸æ¹ãTLSã¯ã©ã¤ã¢ã³ãèªè¨¼ã¯ããããªã½ã¼ã¹ã¸ã®ã¢ã¯ã»ã¹ããµã¼ããæå®ããã¯ã©ã¤ã¢ã³ã証ææ¸ãæã¤ç«¯æ«ã«å¶éããæ©è½ã§ããHTTPãµã¼ãã¯ãã¯ã©ã¤ã¢ã³ãèªè¨¼ãå¿ è¦ãªãªã¯ã¨ã¹ããæ¥ãã¨ã¯ã©ã¤ã¢ã³ãã«HelloRequestãéã£ã¦Renegotiation(TLSã®åãã³ãã·ã§ã¤ã¯)ãçºçããã¾ãããµã¼ãã¯ãRenegotiationãéãã¦ã¯ã©ã¤ã¢ã³ã証ææ¸ã¨ç½²åãã¼ã¿ãæ¤è¨¼ããæ£å½ã§ããã°ã¢ã¯ã»ã¹ã許å¯ãã¾ããTLSã¯ã©ã¤ã¢ã³ãèªè¨¼ã®è©³ãã解説ã¯ã「パンドラの箱?TLS鍵交換の落とし穴、KCI攻撃とは何か」ã«è¨è¼ãã¦ãã¾ãã®ã§ããã¾ã馴æã¿ã®ãªãæ¹ã¯ä¸åº¦ãèªã¿ãã ããã
HTTP/1.1æ代ã¯ãä¸ã¤ã®TCP/TLSæ¥ç¶ãä¸ã¤ã®ãªã¯ã¨ã¹ããå°æãã¦ããã®ã§ãã®ããæ¹ã§åé¡ãªãã£ãã®ã§ãããHTTP/2ã§ã¯è¤æ°ã®HTTPãªã¯ã¨ã¹ããä¸ã¤ã®TCP/TLSæ¥ç¶ãå
±æãã¦ããã®ã§å°ã£ã¦ãã¾ãã¾ãã
HTTP/2ä¸ã§HTTP/1.1ã¨åãããã« renegotiation ãè¡ãã¨ãã¯ã©ã¤ã¢ã³ãèªè¨¼ãå¿
è¦ã®ãªããªã¯ã¨ã¹ãã¾ã§å·»ãæ·»ããé£ãã£ã¦ãã¾ãã¾ãã
ãã®ããHTTP/2ä»æ§ã§ã¯ãHTTPãªã¯ã¨ã¹ããçºçããåã®åææ¥ç¶æã®ã¿ã¯ã©ã¤ã¢ã³ãèªè¨¼ã許å¯ãããã以éã§ã¯ç¦æ¢ãã¦ãã¾ããå¾ã£ã¦æ¥ç¶å§ãããHTTP/2æ¥ç¶å ¨ä½ã«èªè¨¼ãè¡ãã±ã¼ã¹ã§ããã¯ã©ã¤ã¢ã³ãèªè¨¼ãå©ç¨ã§ãã¾ããã§ããã
4. HTTP/2æ¥ç¶å¾ã®TLSã¯ã©ã¤ã¢ã³ãèªè¨¼
ãã®ã¾ã¾ã§ã¯HTTP/2ã使ãã¨Webã®ãªã½ã¼ã¹ã®ä¸é¨ãã¯ã©ã¤ã¢ã³ãèªè¨¼ãããã¨ãã§ããã«å°ã£ã¦ãã¾ãã¾ããããã§ããã¾ãã¹ãã¼ããªããæ¹ã§ã¯ããã¾ããããã¯ã©ã¤ã¢ã³ãèªè¨¼ãå¿
è¦ãªãªã¯ã¨ã¹ããHTTP/1.1ã«éãããã¨ã§ã¾ããªãã¨ã対å¿å¯è½ã«è½ã¨ãè¾¼ã¿ã¾ããã
HTTP/2ã®ãªã¯ã¨ã¹ããã¯ã©ã¤ã¢ã³ãèªè¨¼ã å¿
è¦ãªãªã½ã¼ã¹ã¸ã¢ã¯ã»ã¹ããããµã¼ãå´ã¯ããã®ã¹ããªã¼ã ãHTTP1.1 requiredã®ã¨ã©ã¼ã³ã¼ãã§ãªã»ãããã¾ããã¯ã©ã¤ã¢ã³ãã¯HTTP/1.1 requiredã®ãªã»ããéç¥ãåããã¨æ°ãã«HTTP/1.1ã®æ¥ç¶ãå¼µãããã®ãã³ãã·ã§ã¤ã¯ãéãã¦ãµã¼ãã¯ã¯ã©ã¤ã¢ã³ã証ææ¸ã®æ¤è¨¼ãè¡ã£ã¦ã¢ã¯ã»ã¹ãå¤æãã¾ãã ããã§ãªãã¨ãåé¿å¯è½ã§ãã
5. CVE-2016-4979ã®åå
CVE-2016-4979ã¯ããã®HTTP/1.1ã®æ¥ç¶ã«éããéã« verify_mode ãå ã«æ»ããã¨ãå¿ãã¦ãã¾ã£ãã®ãåå ã§ãã
ãµã¼ãã®SSLã¤ã³ã¹ã¿ã³ã¹ã«ä¿æããã¦ããverify_modeã¯ãã¯ã©ã¤ã¢ã³ãèªè¨¼ãããã©ããã®ç¶æ ãä¿æãã¦ãã¾ããæåã¯ãµã¼ãèªè¨¼ã ããªã®ã§ SSL_VERIFY_NONE ãå ¥ã£ã¦ãã¾ããmod_sslã§ã¯ä¸åº¦æ¢åã®æ¥ç¶ã® verify_mode ã verify_old ã«ããã¯ã¢ãããã¦ãããæ°ãããªã¯ã¨ã¹ãã verify_modeã®å¤æ´ãå ¥ããã©ããæ¤è¨¼ãã¾ã ãå¤æ´ãããã° verify_mode ãæ°ããå¤(SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT:ã¯ã©ã¤ã¢ã³ãã®è¨¼ææ¸ãæ¤è¨¼ãã¦ãã¡ãªãã¨ã©ã¼)ã«ç½®ãæã㦠renegotiation ãå¼·å¶ãããå¦çãè¡ãã¾ãã
ãããHTTP/2ã§ã¯éä¸ã§ã® renegotiation ã¯ç¦æ¢ããã¦ããã®ã§ã代ããã«RST_STREAMãéä¿¡ãã¦HTTP/2ã®TLSæ¥ç¶ãç¶æãã¾ããSSLã®ã¤ã³ã¹ã¿ã³ã¹ã¨verify_modeã¯ãæ°ããå¤ã«æ´æ°ãããã¾ã¾ã§ãããããèå¼±æ§ãå¼ãèµ·ããã¾ããã
å
ã®ä¿®æ£ãããã®ちょっと前の部分(下記)ã該å½ãã¾ãã
/* remember old state */ verify_old = SSL_get_verify_mode(ssl); /* configure new state */ verify = SSL_VERIFY_NONE; (ä¸ç¥) /* TODO: this seems premature since we do not know if there * are any changes required. */ SSL_set_verify(ssl, verify, ssl_callback_SSLVerify); SSL_set_verify_result(ssl, X509_V_OK); /* determine whether we've to force a renegotiation */ if (!renegotiate && verify != verify_old) { (ä¸ç¥) }
ã¾ãã« TODO ã«æ¸ãã¦ããéãããã®å¦çãä¸ååã«ãªã£ã¦ãã¾ãèå¼±æ§ãå¼ãèµ·ãããã®ã¯ç®èãªãã¨ã§ãã
Firefoxã¯HTTP/2ã¹ããªã¼ã ã®ãªã»ããéç¥ãåããæ°ãã«HTTP/1.1æ¥ç¶ã試ã¿ã¾ãããæ£å½ãªã¯ã©ã¤ã¢ã³ã証ææ¸ãæã£ã¦ãªããããæ¥ç¶ã¯ã¨ã©ã¼ã«ãªãã¾ãã
åç¾è©¦é¨ã®ããã«ç¶ãã¦åèªã¿è¾¼ã¿ãè¡ãã¨ãFirefoxã¯æ¢åã®ç¶æããã¦ããHTTP/2æ¥ç¶ã使ã£ã¦ /client_auth ã«ã¢ã¯ã»ã¹ãã¾ãããã®éãµã¼ãã®SSLã¤ã³ã¹ã¿ã³ã¹ã® verify_mode ãåãã§ããããããµã¼ãã¯æ¢ã«ã¯ã©ã¤ã¢ã³ãèªè¨¼æ¸ã¨å¤æã /client_auth ã¸ã®ã¢ã¯ã»ã¹ã許å¯ãã¦ãã¾ãã¾ãããèªè¨¼ãã¤ãã¹ã®æåã§ããå
ã®è©¦é¨ã§ãHTTP/2ã®éã稲妻ç¶æ
ã§ã¢ã¯ã»ã¹ã§ãã¦ãããã¨ããããããã¾ãã
å
ã®1è¡ä¿®æ£ãããã¯ãHTTP/2æ¥ç¶ã§ renegotiationãHTTP/1.1ã®æ°è¦æ¥ç¶ã«éããéã« verify_mode ã以åã®å¤SSL_VERIFY_NONEã«æ»ãå¦çãå ãããã®ã§ããããã«ãã£ã¦åèªã¿è¾¼ã¿æã§ãHTTP/1.1ã®æ°è¦æ¥ç¶ã¸ã®éé¿ãç¹°ãè¿ãè¡ããããã¨ã«ãªããèªè¨¼ãã¤ãã¹ã®èå¼±æ§ã¯åé¿ããã¾ããã
Chrome(51ã®Stable)ã§ã¯ãã®èå¼±æ§ã¯çºçãã¾ããã調ã¹ã¦ã¿ãã¨Chromeã¯ãhttp/1.1 requiredã®RST_STREAMãåãåãã¨æ¢åã®HTTP/2æ¥ç¶ãåæãã¦ãã¾ãããã§ãããã®ããèªè¨¼ã¨ã©ã¼å¾ã®åèªã¿è¾¼ã¿ã«æ°è¦ã®HTTP/1.1æ¥ç¶ãå¼µãããããã®èå¼±æ§ã®å½±é¿ãåããªããªã£ã¦ãã¾ããããã®è¾ºã®å¦çã¯å®è£ ä¾åãªã®ã§ã¾ãè¯ãã£ãã¨ãããã¨ã§ãããã
6. Secondary Certificate Authentication in HTTP/2
HTTP/2ä¸ã§ã®ã¯ã©ã¤ã¢ã³ãèªè¨¼ã®èª²é¡ã¯ãTLSã¨HTTP/2ã®ä¸¡æ¹ã®ä»çµã¿ã«é¢é£ããæ¬è³ªçãªãã®ã§ããå®ã¯SPDYæ代ãããã®ãã¨ã¯èª²é¡èªèããã¦ãããSPDY/3ã§ã¯ã¯ã©ã¤ã¢ã³ãèªè¨¼ã«å¯¾å¿ããããCREDENTIALã¨ããã¯ã©ã¤ã¢ã³ã証ææ¸ã¨ç½²åãã¼ã¿ãããåããããã¬ã¼ã ãè¦å®ããã¦ãã¾ããã
ãããGoogleã¯å®éã«ã¯ã©ã¤ã¢ã³ãèªè¨¼ãå©ç¨ãã¦ããªãã£ããããçµå±ä¸åº¦ãChromeã«CREDENTIALãå®è£ ããããã¨ã¯ããã¾ããã§ãããHTTP/2ã§ãå½åã¯ã¹ã³ã¼ãå¤ã¨ãã¦æ©ã ã«æ©è½åé¤ããã¾ããã
HTTP/2ã®ä»æ§å®äºå¾ãæ¬æ ¼çãªã¯ã©ã¤ã¢ã³ãèªè¨¼ã®æ©è½ã欲ããã¨ããã¦ã¼ã¶ã®å£°ãåããã¯ã©ã¤ã¢ã³ãèªè¨¼ã®æ¡å¼µä»æ§ã®æ¤è¨ãå§ã¾ãã¾ãããå½åMSã¨Mozillaã®ï¼ã¤ã®ãã©ãããæåºããã¦ãã¾ããããå ã®BAã®IETFã§ä¸æ¬åããæ¹éã決ã¾ããå æ¥Secondary Certificate Authentication in HTTP/2 ã¨ãããã©ãããæåºããã¾ãããä»æã®ãã«ãªã³ã®IETFã§ãè°è«ãããäºå®ã§ãã
話ãé·ããªãã®ã§æ°ãããã©ããã®è§£èª¬ã¯æ¢ãã¦ããã¾ãããã¯ã©ã¤ã¢ã³ãèªè¨¼ã«éããããã¾ã§TLSã®ã¬ã¤ã¤ã§è¡ã£ã¦ãã証ææ¸ã®ããåãã¨æ¤è¨¼ãHTTP/2ã®ã¬ã¤ã¤ã§ã追å ã§è¡ããããæ¡å¼µãããã®ã§ããªããªããã³ããæ©è½ã«ãªãããã§ãã
ãããã£ã¦ä¸ã¤ã®èå¼±æ§ããæè¡ãããã³ã«ã®ä»çµã¿ã¨èª²é¡ããã®è§£æ±ºã«åãã¦ã®æ¤è¨ç¶æ³ãè¦ãã¦ããã®ã¯é常ã«æ¥½ããã§ããã