ClickHouse¶à¸öÎó²îÔÀíÆÊÎö
Ðû²¼Ê±¼ä 2022-03-21Ò»¡¢Îó²î¸ÅÊö
ClickHouseÊǶíÂÞ˹yandex¹«Ë¾ÓÚ2016Ä꿪ԴµÄÔÆÊý¾Ý¿âÖÎÀíϵͳ£¬ClickHouseÆÕ±éÓ¦ÓÃÓÚÔÆƽ̨µÄ´óÊý¾ÝÆÊÎöÓ¦ÓÃÖУ¬ÆäÓû§°üÀ¨uber¡¢ebay¡¢µÂÒâÖ¾ÒøÐС¢°¢Àï°Í°Í¡¢ÌÚѶµÈ¡£
Îó²îÓ°ÏìÁËClickHouse 21.10.2.15°æ±¾Ö®Ç°µÄËùÓа汾¡£ÏêϸÎó²îÐÎòÈçϱíËùʾ£º
¶þ¡¢´¦Öóͷ£½¨Òé
2021Äê10ÔÂ18ÈÕÐû²¼µÄClickHouse 21.10.2.15°æ±¾ÐÞ¸´ÁËÉÏÊöµÄ7¸öÎó²î£¬Ç뾡¿ìÉý¼¶µ½ClickHouse 21.10.2.15¼°ÒÔºóµÄ°æ±¾¡£
https://github.com/ClickHouse/ClickHouse/releases/
»º½â²½·¥£º
Èý¡¢Îó²îÆÊÎö
ÕâЩÎó²î¶¼±£´æClickHouse Server´¦Öóͷ£Ñ¹ËõÊý¾ÝµÄÇëÇó´¦Öóͷ£Àú³ÌÖУ¬ClickHouse ServerÖ§³Ö¶ÔÓû§ÇëÇóµÄ¸½´øÊý¾Ý¾ÙÐÐѹËõ¡£Óû§¿ÉÒÔÔÚÌᳫWEBÇëÇóʱ£¬½«decompress±ê¼ÇÉèΪ1¼´¿É£¬¾ÙÀýÈçÏ£º
ÅÌÎʵĸ½´øÊý¾Ý(query.bin)¿ÉÒÔ°´ÏÂÃæµÄ½á¹¹¾ÙÐÐ×éÖ¯£º
ClickHouseÖ§³Ö¶àÖÖѹËõÃûÌ㬰üÀ¨LZ4¡¢Gorilla¡¢DeltaµÈ¶àÖÖѹËõËã·¨¡£ClickHouse Serverƾ֤ÇëÇóÖи½´øÊý¾ÝµÄѹËõËã·¨±êʶ£¬Å²Óòî±ðµÄ½âѹËã·¨À´¶ÔÊý¾Ý¾ÙÐнâѹ¡£
3.1 LZ4Ëã·¨ÏÈÈÝ
LZ4ѹËõËã·¨ÊÇLZË㷨ϵÁÐÖеÄÒ»ÖÖ£¬Ò²ÊÇÏÖÔÚ×ÛºÏЧÂÊ×î¿ìµÄѹËõËã·¨Ö®Ò»¡£
Ò»¸öLZ4ѹËõ¿éÓɶà¸öLZ4ÐòÁÐ×é³É£¬LZ4ÐòÁÐÓÉÒÔÏÂÊý¾Ý×é³É£¬ÈçÏÂͼËùʾ£º
Token¾ÞϸΪ1×Ö½Ú£¬¸ß4¸öbitsΪ²»¿ÉѹËõÊý¾Ý(literal£©µÄ³¤¶È(literallength)£¬¶øµÍ4¸öbitsΪ¿ÉÒÔѹËõÊý¾Ý(match)³¤¶È(match length)¡£ÈôÊÇliterallengthµÄֵΪ0£¬ÔòÌåÏÖºóÐøÊý¾ÝÀïûÓÐliteral¡£ÓÉÓÚliteral lengthÖ»ÓÐ4±ÈÌØÀ´ÌåÏÖ£¬ËüµÄ×î´óֵΪ15¡£µ±literalÊý¾ÝµÄ¾Þϸ´óÓÚ¼´ÊÇ15ʱ£¬ÐèÒªÔÚToken×ֶκóÌí¼Ó¸ñÍâµÄ×Ö½ÚÀ´ÌåÏÖliteralµÄ³¤¶È£¨Literal length+£©¡£
MatchÖ¸Öظ´Ï¿ÉÒÔѹËõµÄ²¿·Ö¡£
src/Compression/LZ4_decompress_faster.cppµÄdecompressImplº¯ÊýÔÚ¿½±´LZ4ÐòÁÐÊý¾ÝµÄliteralʱ£¬Ã»ÓÐÅжϸ´ÖƵÄÊý¾ÝÊÇ·ñÁè¼ÝÄ¿µÄ»º³åÇøµÄÏÞÖÆ¡£µ±ÐèÒª¸´ÖƵÄÊý¾ÝÁè¼ÝÄ¿µÄ»º´æµÄ¾Þϸʱ£¬»áµ¼Ö¶ÑÒç³ö¡£
ÈçÉÏͼ´úÂëËùʾ£¬ipÊÇÖ¸ÏòѹËõ»º³åÇøµÄÖ¸Õë¡£opÊÇÖ¸Ïò·ÖÅɵÄÄ¿µÄ»º³åÇøµÄÖ¸Õ룬¸ÃÄ¿µÄ»º³åÇøµÄ¾ÞϸΪ±¨Í·Öиø¶¨µÄ½âѹ¾Þϸ¡£copy_endÊÇÖ¸Ïò¸´ÖÆÇøÓò×îºóµÄÖ¸Õë¡£
¹¥»÷Õß¿ÉÒԽṹ¶ñÒâµÄLZ4ÐòÁÐÊý¾Ý£¬ÆäÖÐliteraµÄ³¤¶È(length±äÁ¿)´óÓÚdest_size£¬½«µ¼Ö¶ÑÒç³ö¡£
3.4 CVE-2021-43305Îó²îÔÀí
3.5 CVE-2021-42388¼°CVE-2021-42387Îó²îÔÀí
Îó²î±£´æsrc/Compression/LZ4_decompress_faster.cppµÄdecompressImplº¯ÊýÖУ¬¸Ãº¯ÊýÖ±½Ó´ÓLZ4ѹËõÊý¾ÝÖжÁÈ¡16λÎÞ·ûºÅÆ«ÒÆÁ¿£¨offset¹¥»÷Õß¿ÉÒÔ¿ØÖÆ£©,¸ÃÆ«ÒÆÁ¿ÓÃÓÚÅÌËãwildCopy²Ù×÷µÄÔ´Êý¾ÝµØµã¡£µ±offsetµÄֵΪ´óÓÚcopy_amountʱ(Èçoffset = 0xffff£©£¬½«µ¼Ö³ÌÐò½«opµØµã֮ǰµÄÊý¾Ý¿½±´µ½opÖ¸ÏòµÄµØµãÖУ¬´Ó¶øµ¼ÖÂÔ½½ç¶Á¡£
CVE-2021-42387ÊÇCVE-2021-42388µÄÒ»¸öÀàËÆÎó²î£¬ÕâÀï¾Í²»ÔÙÏÈÈÝ¡£
ClickHouseÖ§³ÖµÄDoubleDelta±à½âÂëÆ÷¡¢Delta±à½âÂëÆ÷¡¢Gorilla±à½âÂëÆ÷Öж¼±£´æ±»Áã³ýµÄÎó²î¡£ËüÃÇ»ùÓÚ½«Ñ¹Ëõ»º³åÇøµÄµÚÒ»¸ö×Ö½ÚÉèÖÃΪÁã¡£½âѹ´úÂë¶ÁȡѹËõ»º³åÇøµÄµÚÒ»¸ö×Ö½Ú£¬²¢¶ÔÆäÖ´ÐÐÄ£ÔËËãÒÔ»ñµÃÊ£Óà×Ö½Ú£¬µ±source[0]Ϊ0ʱ£¬CPU¶Ô0¾ÙÐÐȡģʱ²Ù×÷½«±¬·¢³ý0Òì³£¡£
ËÄ¡¢¿¢ÊÂÓï
´óÊý¾Ýʱ´úÏ£¬´ó×ÚÊý¾ÝȺ¼¯¡¢ÅþÁ¬¼°ÍøÂç½çÏßµÄÑÓÉ춼ΪÊý¾Ý¿âµÄµÄÇå¾²Ìá³öÁ˸ü¸ßµÄÒªÇó¡£Êý¾Ý¿â×÷ΪÐÅÏ¢ÊÖÒÕϵͳµÄ½¹µãºÍ»ù´¡£¬³ÐÔØ×ÅÔ½À´Ô½¶àµÄÒªº¦ÓªÒµÏµÍ³£¬³ÉΪÆóÒµºÍ»ú¹¹×î¾ßÓÐÕ½ÂÔÐԵĽ¹µãÊý¾Ý×ʲú£¬Òò´ËÊý¾Ý¿â·½ÃæµÄÇå¾²ÖµµÃÎÒÃÇÒ»Á¬¹Ø×¢¡£
²Î¿¼Á´½Ó£º
[1]https://jfrog.com/blog/7-rce-and-dos-vulnerabilities-found-in-clickhouse-dbms/
[2]https://github.com/ClickHouse/ClickHouse
[3]https://thehackernews.com/2022/03/multiple-flaws-uncovered-in-clickhouse.html