æ¬è¨äºã¯
ã®cross-post entryã§ããã¾ããDark Depths of SMTP ã®Extra Chapterã§ãããã¾ãã
ãã¦ãã¡ã¼ã« Advent Calendar 2018ã§ã¯1æ¥ç®ã®è¨äºã§ã¡ã¼ã«ã®éä¿¡ã®ç§å¯ã«ã¤ãã¦æ³çãªé¢ããã¢ããã¼ããã¦ãã¾ãããæ¬è¨äºã§ã¯ ã¡ã¼ã«ã«ããã¦éä¿¡ã®ç§å¯ãæè¡çã«æ»ãã§ããå¯è½æ§ ã«ã¤ãã¦ç´¹ä»ãããã¨ã«ãªãã¾ãã
Dark Depths of SMTP ã®ç¬¬4ç« ã«ã¦ã¡ã¼ã«ã®æå·åã«ã¤ãã¦è§¦ãã¦ãã¾ããããã®ãããåã¿ç ãã¦èª¬æããã¨ã
- é常ã¡ã¼ã«ã¯æå·åãããªã
- ã¡ã¼ã«ã«ãããTLSã¨ã¯hopéã®TLSãã¤ã¾ãæªæã®ãããµã¼ãã¼ãééããå ´åããã§å¾©å·ãããã¡ã¼ã«ãèªããã¨ãã§ãã
- ãã®ã¸ãã§æ³çãªæå³ã§ã®éä¿¡ã®ç§å¯ã®é¨åãå¹ãã¦ããããã§ããâ¦
- éä¿¡è·¯ã§æå·åããã¦ããã¨ããã§æå¾ã«ã¯å¾©å·ããã¦ä¿åãããã®ã§IMAPã®ã¹ãã¬ã¼ã¸èªä½ãæ»æããããèªã¾ãããã¨ããããã
- ã¡ã¼ã«ãã®ãã®ã®æå·åã®æ¹æ³ã¨ãã¦ã¯S/MIMEã¨PGPã®2ã¤ããã
â¦ã¨ããæãã«ãªãã¾ãããã®Eã¡ã¼ã«æå·åã®æå¾ã®ç ¦ã§ããã¨ããã®S/MIMEã¨PGPã«å¯¾ãã¦ãMUAã§HTMLã¡ã¼ã«ãã¬ã³ããªã³ã°ããããã¨ãå©ç¨ãã¦æå·åãç¡å¹åã§ãããã¨ããèå¼±æ§ãä»å¹´ã®5æã«å ±åããã¾ãããMUAã®èå¼±æ§ã¨ãããã³ã«ãã®ãã®ã®èå¼±æ§ãããããä¸é£ã®èå¼±æ§ã«ã¯EFAILã¨ããååãä¸ããããè«æã¯ã»ãã¥ãªãã£åéã®ãããã«ã³ãã¡ã¬ã³ã¹ã®ä¸ã¤ã§ããUSENIX Securityã§çºè¡¨ããã¾ããã
TL;DR
imgã¿ã°ã®ãããªãªã¯ã¨ã¹ããçºçããã¿ã°ã¨ãã¦å¾©å·ããããããªãã®ãæ¿å ¥ããã¨ãURLã®ä¸é¨ã¨ãã¦å¾©å·å¾ã®ã¡ãã»ã¼ã¸ãå«ããªã¯ã¨ã¹ããè¡ããããããæ»æè ã®ãµã¼ãã¼ã«å¾©å·å¾ã®æååãéä¿¡ããããã¨ã«ãªããã¨ããã®ãçµæã1è¡ã§èª¬æãããã®ã§ãã
å½±é¿ã¯ããã®ï¼
ãã®èå¼±æ§ã¯æ»æè ãã¡ã¼ã«èªä½ã¸ã®èªã¿æ¸ããã§ããå ´åã«å¯è½ãªæ»æã§ããéä¿¡è·¯ä¸ã§ãå¯è½ã§ãããIMAPã®ã¹ãã¬ã¼ã¸èªä½ã¸ã®æ»æãæ³å®ãã¦ããã¨èããã¨ããã§ããããããèªä½ãããªãæ»æã®æ¡ä»¶ã¨ãã¦éå®çãªã®ã§ä¸è¬ã«å½±é¿ã¯å°ãªãã¨ããã¾ãï¼ãªã®ã§ã¿ã¤ãã«ã¯é大åºåï¼ããPGPãS/MIMEã§ã®æå·åã®ç®çãéä¿¡è·¯ä¸ãããã¯IMAPã¹ãã¬ã¼ã¸ä¸ã§ã®å®å ¨æ§ã®ä¿è¨¼ãªã®ã§ãããã¯PGPãS/MIMEã¸ã®æ»æãæåããã¨ãã£ã¦ãééãã§ã¯ãªãã§ãããã
Direct Exfiltration Attack
EFAILã®ãµã¤ãã«ã¦ç´¹ä»ããã¦ãã第ä¸ã®æ»æã§ããããã¯Apple Mail, iOS Mail, Thunderbirdã«åå¨ããèå¼±æ§ã使ã£ã¦PGPãS/MIMEã®å¾©å·çµæããªã¯ã¨ã¹ããããã¨ãç®æãã¾ããæ»æè ã¯3ã¤ã®partãå«ãmultipartã¡ã¼ã«ãéä¿¡ãã¾ã:
- 第1ã®partã¯
text/html
ã®ã¡ã¼ã«ã§ãimg
ã¿ã°ãå«ã¿ã¾ãããããã®src
è¦ç´ ã®double quoteã¯éãããã¦ãã¾ããã - 第2ã®partã«æ»æ対象è ã®MUAã«è§£èªãã¦ã»ããPGPã»S/MIMEã®ã¡ã¼ã«æ¬ä½ãå«ã¿ã¾ãã
- 第3ã®partã§æåã®partã§éãã¦ããªãã£ã
src
è¦ç´ ã®double quoteãéããã¿ã°ãéãã¦å®æããã¾ãã
ããããã¨ãèå¼±æ§ãæã¤MUA㯠æåã«ç¬¬2ã®PGPãããã¯S/MIMEã®partã復å·ããå
¨é¨ãã²ã¨ã¾ã¨ãã«ãã£ã¤ããHTMLã¡ã¼ã«ã¨ãã¦ã¬ã³ããªã³ã°ãã¦ãã¾ãã¾ããããããã¨æ»æè
ã®æå®ããsrc
è¦ç´ ã®URLã«æå·åããã¦ããã¯ãã®ã¡ãã»ã¼ã¸ãå«ã¾ãããã¨ã«ãªãããªã¯ã¨ã¹ããçºçãã¦ãã¾ãã¾ããæ»æè
ã¯ã¢ã¯ã»ã¹ãã°ãªã©ãããªã¯ã¨ã¹ããæ¢ãã¦ãçµæã¡ã¼ã«ã解èªããããã¨ãå¯è½ã«ãªãã¾ããã
CBC/CFB Gadget Attack
ç¶ãã¦ç¬¬äºã®æ»æã¨ãã¦æãããã¦ããCBC/CFB Gadget Attackã§ã¯ããããã³ã«ãã®ãã®ã«åå¨ããæå·ã®èå¼±æ§ã使ã£ã¦Direct Exfiltration Attackãæç«ããªãMUAã«å¯¾ãã¦ããªã¯ã¨ã¹ããèµ°ã£ã¦ãã¾ãããã«ã¡ã¼ã«ãæ¸ãæãããã¨ãç®æããæ»æã§ãã
S/MIMEã§ã¯ã¡ã¼ã«æ¬ä½ã®æå·åã«ãããã¯æå·ã®CBC modeã¨ããæå·å©ç¨ã¢ã¼ããç¨ãã¾ããCBCã¢ã¼ãã§ã¯ç¹å®ã®ãããã¯ã®å¾©å·ãè¡ãããã«ãã¾ãã¯è©²å½ã®æå·æãããã¯ã復å·é¢æ°ã«ããããã®ããã§ãã®çµæãåã®ãããã¯ã®æå·æã¨XORãã¨ããã¨ã§æçµçãªãããã¯ã®å¾©å·çµæãå¾ã¾ãï¼åã®ãããã¯ã®ciphertextã使ãã®ã§cipher block chainingãã§CBCï¼ã
ããã§ãIVï¼åæåãã¯ã¿: ããã¯é常平æã§ä¸ããããï¼ã¨P_0ï¼å¹³æã®ç¬¬1ãããã¯ï¼ãç¥ã£ã¦ããã¨ãã¦ãæ¬æ¥ã®åæåãã¯ã¿ã®ã¨ããã« IV xor P_0
ãçªã£è¾¼ãã ã¨ãã¾ãããã
ããããã¨ãæåã®ãããã¯ã¯0ã§åãããããã¨ã«ãªãã¾ãï¼ãããEFAILãµã¤ãã«ãããç»åã®(b)ã®é¨åã®èª¬æï¼ãIV xor P_0 xor M
ã¨ãããã®ãçªã£è¾¼ãã°ã第1ãããã¯ãM
ã«ãããã¨ãã§ãã¾ããã§ã第1ãããã¯ã®å¹³æããªãã§ããããã¨ããã¨ãS/MIMEã§ã¯ã¡ã¼ã«æ¬ä½ã Content-type: multipart/signedã§å§ã¾ã ãã¨ã決ã¾ã£ã¦ããããã§ãããããå®éã«æ»æã«å¿ç¨ããã«ã¯ï¼ãµã¤ãã®å³ã®(c)ï¼ãåæåãã¯ã¿ã«<img ignore="
ã«å±éããããããªæååããã¾ã第2ãããã¯ã«" src=efail.de/
ï¼URLã¯ååçãæååã§ããã°ããï¼ã«å±éããããããªæååãããããã IV xor P_0 xor M
ã§ä½ãé
ç½®ãã¾ãã2ãããã¯å¾ã§ããå¿
è¦ãããã®ã¯ã第1ãããã¯ã®æå·æã¯ç¬¬2ãããã¯ã«chainingãããããã§ãããã«ãã£ã¦çæãããã©ã³ãã ãª*1æååãimgã¿ã°ã®ignoreè¦ç´ ã§æã¡æ¶ãã¾ãããã®ããã«ããã¨ã第3ãããã¯ã«ã¯åæ§ã®åçã«ããã©ã³ãã ãªæååãç¾ãã第4ãããã¯ä»¥éã«ã¯æ¬æ¥ã®ã¡ãã»ã¼ã¸ã«å«ã¾ããå¹³æãç¾ãã¾ãããããã®å¹³æã¡ãã»ã¼ã¸ã¯imgã¿ã°ã®srcè¦ç´ ã®URLã®ä¸é¨ã«ç¾ãããããMUAããªã¯ã¨ã¹ããè¡ã£ã¦ãã¾ãã°ãã¨ã¯å
ã»ã©ã¨åæ§ã«æ»æè
ã¯å¹³æã®å
容ãåãåºããã¨ãã§ãã¾ãã
PGPï¼ããã§ã¯ç¹ã«OpenPGPãããã³ã«ãæãï¼ã§ã¯å°ã äºæ ãå¤ãã£ã¦ãã¾ãã
- æå·å©ç¨ã¢ã¼ãã¨ãã¦CFBã¢ã¼ããç¨ãã: ããã¯CBCã¢ã¼ãã¨å°ã ããæ¹ãéããåããããªããæ¹ã§æç« ã®æ¹ãããå¯è½
- æ¹ããæ¤ç¥ãåå¨ãã: ããã¯ä»¥ä¸ã®2ã¤ã®æ¹æ³ã®ã©ã¡ããã§çªç ´å¯è½ã
- OpenPGPã®ãã±ããã®ãã¡SEIP(Symmetrically Encrypted and Integrity Protected Packet)ã¨è¨ããããã±ãããSE(Symmetrically Encrypted)ãã±ããã«æ¿ãæ¿ãã¦ãã¦ã³ã°ã¬ã¼ãããã
- æå·æããæå¾ã®22ãã¤ããåã£æããã¨ã§Modification Detection Code(MDC)èªä½ããªããã¦ãã¾ããMDCããªãã£ãå ´åã¯ã¯ã©ã¤ã¢ã³ãããã§ãã¯èªä½ãã§ããªãã
- ããã©ã«ãã§å§ç¸®ãè¡ããã: 詳細ã®èª¬æã¯çç¥ãã¾ãããè«æã®9ãã¼ã¸ç®ï¼ãã¼ã¸çªå·556ï¼ã®å³ãè¦ãã¨ã以ä¸ã®ããã«å§ç¸®ãå©ç¨ãã¦ã»ããæååã«å±éããããã¨ãå¯è½ã
- CFBã¢ã¼ãã®å¼±ç¹ãå©ç¨ãã¦ãOpenPGPã®æ§é ã示ãé¨åããimgã¿ã°ç¸å½ã®ãããã¯2ã¤ãã«å±éããããã®ãä½ãã
- ããããLZ77å§ç¸®ã®backreferenceã§æãããã«ãã
- ããããã¨å±éå¾ã®çµæã¯ãOpenPGPã®æ§é ããimgã¿ã°ããæ»æ対象ã®å¹³æãã®é ã«ä¸¦ã¶
ãã¤ã³ã
æ¬è¨äºã§ã¯ã¡ã¼ã«æå·åã®ä¸»è¦ãªãªãã·ã§ã³ã§ãã£ãPGPã¨S/MIMEãæ¹ããã«å¯¾ãã¦èå¼±ã§ããã®çµæã¨ãã¦ç§å¯æ§ãæ»æããã¦ãã¾ã£ããã¨ãããã¨ãç´¹ä»ãã¾ããã
ä»ã§ã¯CBCã¢ã¼ããCFBã¢ã¼ãã¯åä½ã§ç¨ããã¨ããã§èª¬æããã¦ãããããªæ¹æ³ã§æç« ã®æ¹ãããå¯è½ã§å®å ¨æ§ãä¿ã¤ãã¨ãã§ããªããã¨ãç¥ããã¦ãã¾ããããããã®ãããã³ã«ãå®è£ ãããæç¹ã§ã¯MAC(Message Authentication Code)ã使ã£ã¦å®å ¨æ§ãæ ä¿ãããã¨ããèãæ¹ã浸éãã¦ããªãã£ããããç§å¯æ§ãå®ããã¨ã¯ã§ãã¦ãå®å ¨æ§ãå®ããã¨ã«ã¤ãã¦ã¾ã§çºæ³ãè³ã£ã¦ãã¾ããã§ããããã®æ»æã¯ãæå·æã®æ¹ããã«ãã£ã¦å®å ¨æ§ãæ»æãããçµæãMUAãHTTPãªã¯ã¨ã¹ãããã¦ãã¾ããã¨ã§ç§å¯æ§ãæ»æããããã¨ãããã»ãã¥ãªãã£ã®2ã¤ã®è¦ç´ ã«æ¸¡ãæ»æã«ãªã£ã¦ãã¾ãã
ãããåãã¦ãIETFã®lamps WGã§ã¯S/MIME 4.0ã¨ãããããã³ã«èªä½ã®ã¢ããã°ã¬ã¼ããææ¡ããã¦ãã¾ããChanges for S/MIME v4.0ã¨ããç¯ã§ã¯æå·åæ¹å¼ãAES-256 GCMãããã¯ChaCha20-Poly1305ã¨ããèªè¨¼ä»ãæå·ãç¨ããããã«æ´æ°ãããã¨æ¸ããã¦ãã¦ãããã«ãã£ã¦EFAILèå¼±æ§ã§å¯è½ã§ãã£ãæå·æã®æ¸ãæãã«ããã¡ã¼ã«æ¬ä½ã®æ¹ãããã§ããªããªãã¾ãã
宣ä¼
Dark Depths of SMTPã®é»åçã®é å¸ãéå§ãã¾ããã (12/13 update)
*1:æ£ç¢ºã«ã¯ãä»åçæããæååã復å·åé¢æ°ã«ããã第1ãããã¯ã®æå·æã¨XORãã¨ã£ããã®ãã復å·åé¢æ°ã®åºåçµæãæ®éæ»æè ã«ã¯ããããªãããå®è³ªã©ã³ãã ã