¿ªÔ´Ñ¹Ëõ¿âlibarchive´úÂëÖ´ÐÐÎó²î£¨CVE-2019-18408£©ÆÊÎö
Ðû²¼Ê±¼ä 2019-11-25Ç° ÑÔ
2019Äê2Ô£¬Check PointÇå¾²Ñо¿ÍŶӼì²â·¢Ã÷WinRAR½âѹËõÈí¼þ±£´æÈô¸ÉÖØ´óÎó²î¡£¹¥»÷Õß¿ÉʹÓÃÉÏÊöÎó²î£¬Í¨¹ýÓÕʹÓû§Ê¹ÓÃWinRARÈí¼þ·¿ª¶ñÒâ½á¹¹µÄѹËõ°üÎļþ£¬Ö´ÐжñÒâ´úÂ룬ʵÏÖ¶ÔÓû§Ö÷»úÈëÇÖµÄÄ¿µÄ¡£
ͬÑù£¬ÔÚ²»¾ÃÇ°¹È¸èµÄÇå¾²Ñо¿Ô±·¢Ã÷libarchive¿âÖб£´æÎó²îCVE-2019-18408¡£¹¥»÷Õß¿ÉʹÓÃÈ«ÐĽṹµÄѹËõÎļþ£¬¶ÔÊÜÓ°ÏìÓû§Ôì³ÉѹËõ³ÌÐò¾Ü¾ø·þÎñ»òÖ´ÐжñÒâ´úÂë¡£
Îó²îΣº¦
libarchiveÊÇÒ»¸ö¿ªÔ´µÄѹËõºÍ¹éµµ¿â¡£ËüÖ§³Öʵʱ»á¼û¶àÖÖѹËõÎļþÃûÌ㬺ñÈ7z¡¢zip¡¢cpio¡¢pax¡¢rar¡¢cab¡¢uuencodeµÈ£¬Òò´ËÓ¦ÓÃÊ®·ÖÆձ顣
Õâ´Î±»ÆسöµÄÇå¾²Îó²î¼ä½ÓÓ°Ïìµ½ÁË´ó×ÚÏîÄ¿ºÍ²úÆ·¡£ÏÖʵÉϲ»µ«ÊÇѹËõ/½âѹ¹¤¾ß¿ÉÄÜ»á½ÓÄÉlibarchive£¬libarchive»¹Ó¦ÓÃÓŲ́ʽ»úºÍ·þÎñÆ÷²Ù×÷ϵͳ£¨¸÷´óLinux¿¯Ðа桢MacOS¡¢Windows£©¡¢ÖÖÖÖ°ü¹ÜÀíÆ÷£¨Pacman¡¢XBPS¡¢NetBSD¡¯s¡¢CMakeµÈ£©¡¢Îļþä¯ÀÀÆ÷£¨Springy¡¢Nautilus£¬GVFsµÈ£©ÖУ¬ÉõÖÁijЩÓʼþ·´²¡¶¾Èí¼þ¶¼»áÓõ½Ëü£¬ÄÇô¹¥»÷ÕßÍêÈ«¿ÉÒÔʹÓÃlibarchiveµÄÎó²î£¬·¢ËÍ°üÀ¨¶ñÒâѹËõ°üµÄÓʼþ£¬Ê¹ÓÃÎó²îÖ´ÐÐí§Òâ´úÂëÉõÖÁ¿ØÖÆ×°±¸¡£
ÊÜÓ°Ïì°æ±¾£ºlibarchive version < 3.4.0
Îó²îÔÀí
µ±½âѹRARÃûÌõÄѹËõÎļþʧ°Üʱ£¬³ÌÐò»á¼ÌÐøÑ°ÕÒÏÂÒ»¸öÎļþ¿éµÄHeader²¢¾ÙÐнâÂ룬¶ø֮ǰ½âѹʧ°Ü²¢ÊͷŵĶѿռ䱻ÖØÓã¬Ôì³ÉUAF(Use After Free)Îó²î¡£
ͨ³£RAR¹éµµÎļþÃûÌÃÈçÏÂͼËùʾ£¬µÚÒ»¸ö±ØÐèÊDZê¼Ç¿é£¬ÆäËü¿éÖ®¼äûÓÐÏȺó˳Ðò¡£
ÒÔÊÇ£¬¿ÉÆÊÎöÈçÏÂijÕý³£RARÎļþ½á¹¹£º
Ç°7¸ö×Ö½ÚΪRARÃûÌÃÊðÃû£¨v5°æ±¾ÒÔÏ£©£¬0x6152Ϊ¿éCRC£¬0x72Ϊ¿éÀàÐÍ£¬0x1A21Ϊ¿é±ê¼Ç£¬0x0007Ϊ¿é¾Þϸ£¬ÓÉ´Ë׼ȷÅжÏΪrarÎļþ¡£
µ±³ÌÐò´¦Öóͷ£µÚÒ»¸öÎļþ¿éHeaderʱ£¬ÒòÌØÊâ½á¹¹µ¼Ö½âÂëʧ°Ü£¬ÒÔÊÇread_data_compressed()º¯Êý»á·µ»ØARCHIVE_FAILED¡£Ö®ºó£¬ÔÚarchive_read_format_rar_read_data()º¯ÊýÖУ¬rar->ppmd7_context±»ÊÍ·Å£¬¼´CPpmd7½á¹¹ÌåÖ¸Õë±äÁ¿p¡£
µ±*buff²»ÎªNULLʱ£¬Ò²¾ÍÊÇunp_buffer£¨Î´½âѹÊý¾Ý£©ÒÀÈ»±£´æʱ£¬³ÌÐò»á½Ó×Å´¦Öóͷ£rarÎļþ£¬Ö®ºó»áÑ°ÕÒÏÂÒ»¸öÎļþ¿éµÄHeader²¢Ñ»·Ö®Ç°µÄ½âÂë°ì·¨¡£
³ÌÐòÔÚ½âÂëÏÂÒ»¸öÎļþ¿éµÄʱ¼äÔÙ´ÎŲÓÃread_data_compressed()º¯ÊýÖеÄPpmd7_DecodeSymbol()º¯Êý¾ÙÐнâÂ룬ÔÙ´ÎʹÓñ»ÊͷŵŤ¾ßp£¬Òò´ËÔì³ÉUAF¡£
Îó²îÐÞ²¹
libarchive ÍŶÓÒÑÔÚGithubÉÏÌá½»×îеÄÐÞ¸´°æ±¾£¬½¨ÒéÊÜÓ°ÏìÓû§¾¡¿ìÏÂÔز¢¸üУº
https://github.com/libarchive/libarchive/releases/tag/v3.4.0
¸÷´óLinux¿¯ÐаæÇå¾²¸üÐÂÐÅÏ¢ÈçÏ£º
Debian£ºhttps://security-tracker.debian.org/tracker/CVE-2019-18408
Ubuntu£ºhttps://usn.ubuntu.com/4169-1/
Gentoo£ºhttps://bugs.gentoo.org/show_bug.cgi?id=CVE-2019-18408
Arch Linux£ºhttps://www.archlinux.org/packages/?sort=&q=libarchive&maintainer=&flagged=
²¹¶¡ÆÊÎö
ÔÚ×îаæv3.4.0ÖУ¬ÊÍ·Årar->ppmd7_conextÖ®ºó£¬¿ª·¢Õß½«rar->start_new_tableÖÃΪ1£¬rar->ppmd_validÖÃΪ0£¬Òò´ËPpmd7_DecodeSymbol()º¯ÊýÔÚread_data_compressed()Öв»ÔÙŲÓá£
ÔÚparse_code()º¯ÊýÖУ¬¶ÔµÚ¶þ¸öÎļþ¿é¾ÙÐнâÂ룬µ«ÎÞ·¨½¨ÉèеĹþ·òÂü±àÂë±í£¬Òò´Ë×îÖÕ·µ»Ø-30£¬ÆäÖµÊÇARCHIVE_FATALµÄºê½ç˵£¬¶øARCHIVE_FATALÒâζ×ųÌÐò²»ÔÙ¾ÙÐÐÈκβÙ×÷²¢¾ÙÐÐÍËÀ´ÓÉÖá£
¹ØÓÚrar>ppmd_validµÄÉèÖ㬿ÉÒÔÈ·±£ÔÚrar_br_bitsΪ0µÄÇéÐÎÏ£¬ÀàËƽṹµÄRARÎļþÔÚparse_code½×¶ÎʼÖÕ¿ÉÒÔ·µ»ØARCHIVE_FATAL¡£
²Î¿¼ÎÄÏ×£º
1.https://www.zdnet.com/article/libarchive-vulnerability-can-lead-to-code-execution-on-linux-freebsd-netbsd/#ftag=RSSbaffb68/
2.https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-18408
3.https://github.com/libarchive/libarchive/compare/v3.3.3...v3.4.0
4.https://lists.debian.org/debian-lts-announce/2019/10/msg00034.html