WordPress Core SQL×¢ÈëÎó²î(CVE-2022¨C21661)ÆÊÎö
Ðû²¼Ê±¼ä 2022-01-25Îó²î¸ÅÊö
WordPressÊÇÏÖÔÚÈ«ÇòÊ¢ÐеÄÈý´óÄÚÈÝÖÎÀíϵͳ֮һ£¬Æä½¹µãÄ£¿é£¨Core£©·ºÆðÎó²îµÄÇéÐÎÏà¶Ô½ÏÉÙ¡£½üÆÚ£¬WordPress½¹µãÄ£¿é±»Åû¶±£´æÒ»´¦SQL×¢ÈëÎó²î(CVE-2022¨C21661)¡£Õë¶Ô¸Ã¸ßΣÎó²î£¬ÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøADLabÑо¿Ô±µÚһʱ¼ä¾ÙÐÐÁËÏêϸÆÊÎöºÍÑéÖ¤¡£
ÊÜÓ°Ïì°æ±¾
ÊÜÓ°Ïì°æ±¾£ºWordPress < 5.8.3
Îó²îÆÊÎö
ͨ¹ý½ÏÁ¿githubÉϵÄÔ´´úÂ룬¿ÉÒÔ·¢Ã÷Îó²îµÄλÖÃÊÇclean_queryº¯Êý¡£ÔÚ5.8.2¼°Ö®Ç°µÄÀÏ°æ±¾ÖУ¬¸Ãº¯ÊýµÄÒªº¦´úÂëÈçÏ¡£
ÔÚclean_queryº¯ÊýÖУ¬µ±×ª´ï½øÀ´µÄ$queryÖª×ãÒÔÏÂÁ½¸öÌõ¼þ£º
$query['taxonomy']Ϊ¿Õ£»
$query['filed']µÄÖµ¼´ÊÇterm_taxonomy_id¡£
WordPressµÄÖ´Ðоͻá½øÈë580ÐУ¬Å²ÓÃtransform_queryº¯Êý¡£¸ú½ø¸Ãº¯Êý£¬Öª×ã602ÐУ¬²»×öÈκβ½·¥Ö±½Óreturn£¬¼á³ÖÁËtermsµÄÖµ²»Êܸı䡣
È«¾ÖËÑË÷clean_query£¬Æä±»get_sql_for_clauseº¯ÊýŲÓá£ÔĶÁ¸ÃÒªÁìµÄ´úÂë¿ÉÖª£¬ËüµÄ¹¦Ð§ÊÇΪsqlÅÌÎÊÖеÄÌõ¼þ½¨Éè×Ӿ䡣ÏêϸÀ´Ëµ£¬ËüµÄÊÂÇéÊÇ´¦Öóͷ£ÎüÊÕµ½µÄÊý¾Ý£¬½«ÕâЩÊý¾Ý×éºÏ³ÉSQL ÅÌÎÊÖеÄÌõ¼þ£¬È»ºó½«Æä·µ»Ø¸ø¸¸º¯Êý¡£ÒÔÊÇ£¬ÈôÊÇ¿ÉÒÔ¿ØÖÆclean_queryµÄ·µ»ØÊý¾Ý£¬¾Í¿ÉÒÔ¿ØÖÆSQLÅÌÎʾÙÐÐ×¢Èë¡£
ÔÚget_sql_for_clauseÖпÉÒÔÕÒµ½$terms±äÁ¿±»Æ´½Óµ½sqlÓï¾äÖС£
´Óget_sql_for_clauseÒªÁì¼ÌÐø»ØËÝ£¬Å²ÓÃÕ»ÈçÏ£º
ÔÚget_posts()ÖпÉÒÔÕÒµ½¶ÔWQ_Tax_Query->get_sql()µÄŲÓá£
ͨ¹ý»ØËÝŲÓÃÕ»¿ÉÖª£¬Í¨¹ý¿ØÖÆWP_Query->__construct()ÖеÄÊôÐÔ£¬¾Í¿ÉÒÔÔì³Ésql×¢Èë¡£
Îó²î¸´ÏÖ
̫ͨ¹ýÎöWordPressµÄÔ´Âë·¢Ã÷£¬WordPress½¹µã´úÂëÖв»±£´æ¿ÉÒÔ´¥·¢¸ÃÎó²îµÄŲÓõ㡣ΪÁËÑéÖ¤¸ÃÎó²î£¬ÕâÀïʹÓÃÁËEle Custom Skin²å¼þ×öÎó²î¸´ÏÖ£¬ÕâÒ²ÊÇZDI¸ø³öµÄ±£´æ±¬·¢Îó²îŲÓõIJå¼þÑùÀý¡£
EleCustom Skin²å¼þ×°ÖÃÁ¿ÔÚ10ÍòÒÔÉÏ£¬ÇÒÆä±£´æµÄÎó²îŲÓÃÊÇÎÞÐèµÇ¼µÄ¡£¸Ã²å¼þ±£´æÒªÁìget_document_data()£¬Æä½¹µã´úÂëÈçÏ£º
È«¾ÖËÑË÷get_document_data£¬¸ÃÒªÁì±»×¢²áµÄactionÃû×ÖÈçÏ¡£
Òò´Ë£¬¸ÃÎó²îÔÚÕâ¸ö²å¼þÊDZ£´æ´¥·¢Â·¾¶µÄ¡£¿ªÆôdebug¹¦Ð§ºó£¬½á¹¹±¨Îļ´¿ÉÀÖ³É×¢Èë³öÊý¾Ý¿âuser¡£
Ê¢Ðвå¼þÆÊÎö
ΪÁËÆÊÎö¸ÃÎó²îµÄÏÖʵӰÏ죬ADLabÑо¿Ô±»¹¶ÔWordPressÇ°100¸öÊ¢Ðвå¼þ¾ÙÐÐÁËÆÊÎö£¬·¢Ã÷ÆäÖÐ2¸ö²å¼þÒ²±£´æ¸ÃÎó²î¡£
¿ªÆôdebug£¬½á¹¹±¨Îļ´¿ÉÀÖ³É×¢Èë³öÊý¾Ý¿âuser¡£
ÐÞ¸´¼Æ»®
ÏÖÔÚWordPressÒÑÐû²¼Éý¼¶²¹¶¡ÒÔÐÞ¸´Îó²î£¬²¹¶¡»ñÈ¡Á´½ÓÈçÏ£º
https://github.com/WordPress/wordpress-develop/security/advisories/GHSA-6676-cqfm-gw84
²Î¿¼Á´½Ó£º
https://www.zerodayinitiative.com/blog/2022/1/18/cve-2021-21661-exposing-database-info-via-wordpress-sql-injection