UnixͨÓôòӡϵͳcups-browsedÔ¶³Ì´úÂëÖ´ÐЩ¶´·ÖÎö

Ðû²¼Ê±¼ä 2024-12-13

Ò»¡¢Â©¶´ÃèÊö


2024Äê9Ô£¬Äþ¾²Ñо¿Ô±Simone MargaritelliÅû¶ÁËUnixͨÓôòӡϵͳCUPS(Common UNIX Printing System)´æÔÚһϵÁÐÄþ¾²Â©¶´£¬ÀûÓöà¸ö©¶´×éºÏ¿ÉÔÚÊÜÓ°ÏìµÄϵͳÉÏÖ´ÐÐÔ¶³ÌÃüÁî¡£¶«É­Æ½Ì¨ADLabÑо¿ÈËÔ±¶Ô¸Ã©¶´µÄÔ­Àí½øÐÐÉîÈë·ÖÎö£¬Í¬Ê±Ìá³öÐÞ¸´½¨ÒéºÍ»º½â´ëÊ©¡£


±í1.png


¶þ¡¢Ïà¹Ø½éÉÜ


CUPSÊÇÒ»¸ö¿ªÔ´µÄ´òӡϵͳ£¬ÓÃÓÚLinuxºÍÆäËûÀàUNIX²Ù×÷ϵͳ¡£CUPS Ìṩ Web½çÃæºÍBerkeleyÃüÁîÐнçÃæµÈ¶àÖÖ·½Ê½À´¹ÜÀí´òÓ¡»úºÍ´òÓ¡ÈÎÎñ¡£ÀýÈç·ÃÎÊhttp://localhost:631¿É¹ÜÀí´òÓ¡»ú¡£


ͼ1.png


CUPSÖ÷ҪʹÓÃInternet Printing Protocol(IPP)À´ÊµÏÖµ±µØºÍÍøÂç´òÓ¡»úµÄ´òÓ¡¹¦Ð§¡£IPPÊÇÒ»¸öÔÚ»¥ÁªÍøÉÏ´òÓ¡µÄ³ß¶ÈÍøÂçЭÒ飬ËüÈÝÐíÓû§¿ÉÒÔͨ¹ý»¥ÁªÍø×÷Ô¶¾àÀë´òÓ¡¼°¹ÜÀí´òÓ¡ÊÂÇéµÈ¡£IPP½ÓÄɵij¬Îı¾´«ÊäЭÒéHTTPµÄPOSTÒªÁìÔÚ¿Í»§¶ËºÍ´òÓ¡·þÎñÆ÷Ö®¼ä½øÐлỰ¡£


ͼ2.png


cups-browsedÊÇÒ»¸ö¿ªÔ´µÄ´òÓ¡·þÎñ×é¼þ£¬ËüÊÇCommon UNIX Printing System(CUPS)µÄÒ»²¿ÃÅ¡£cups-browsedÂôÁ¦ÔÚµ±µØÍøÂçÉÏ×Ô¶¯·¢ÏÖºÍÌí¼Ó´òÓ¡»ú£¬Ê¹ÓÃmDNS£¨¶à²¥DNS£©»òDNS-SD£¨DNS·þÎñ·¢ÏÖ£©Ð­ÒéÀ´Õì²âÍøÂçÉϵĴòÓ¡É豸¡£ËüʹµÃÓû§Äܹ»ÎÞÐèÊÖ¶¯ÅäÖü´¿ÉʹÓÃÍøÂç´òÓ¡»ú¡£


Èý¡¢Ô­Àí·ÖÎö


¸Ã©¶´Ô´ÓÚcups-browsed·þÎñ£¬¸Ã·þÎñ°ó¶¨ÔÚUDP INADDR_ANY:631¶Ë¿ÚÉÏ£¬½ÓÊÜÈκÎip·¢Ë͹ýÀ´Êý¾Ý¡£Í¬Ê±¸Ã·þÎñÊÊÅä´ó¶àÊýUNIXϵͳ£¬ÇÒ´ó¶àÊýÉ豸ĬÈÏ¿ªÆô¸Ã·þÎñ¡£


¸Ã·þÎñµÄ¹¦Ð§ÊÇ·¢ÏÖ»¥ÁªÍøÉϵĴòÓ¡»ú£¬È»ºó½«´òÓ¡»úÌí¼Óµ½ÏµÍ³·þÎñÉÏ£¬Ïà¹Ø¹¦Ð§µÄʵÏÖ´úÂëÔÚcups-browsed.cÎļþÖС£´úÂëÖд´½¨Ò»¸öÃûΪBrowseSocketµÄÌ×½Ó×Ö£¬È»ºó°ó¶¨ÔÚ631¶Ë¿Ú¡£


ͼ3.png


µ±¼ì²éµ½ÏµÍ³Ö§³ÖBrowseRemoteProtocolsʱ£¬´´½¨Ò»¸ö UNIX Ì×½Ó×ÖͨµÀ£¬²¢ÉèÖüàÊÓ¸ÃͨµÀÉϵÄÊäÈëʼþ¡£Ò»µ©ÓÐÊý¾Ý¿É¶Á£¬½«µ÷ÓÃprocess_browse_dataº¯ÊýÀ´´¦ÖÃÕâЩÊý¾Ý¡£


ͼ4.png


BrowseRemoteProtocols²ÎÊý¿Éͨ¹ý/etc/cups/cups-browsed.confÎļþ½øÐÐÅäÖ㬴˴¦Ò»°ãĬÈÏ¿ªÆô¡£


ͼ5.png


process_browse_dataÊÇÒªº¦µÄÊý¾Ý´¦Öú¯Êý£¬¸Ãº¯Êýµ÷ÓÃrecvfrom´ÓBrowseSocketÌ×½Ó×Ö¶ÁÈ¡Êý¾Ý°üpacket¡£Êý¾Ý°ü¸ñʽ×ñ´ÓHEX_NUMBER HEX_NUMBER TEXT_DATA£¬Ê¹ÓøøñʽµÄÊý¾ÝµÄÔ­ÒòʱÊÇ·¨Ê½ÔÚ´¦ÖÃpacketʱʹÓÃÁËÏÂÃæµÄº¯Êý¶ÔÊý¾Ý½øÐд¦Öá£


sscanf (packet, "%x%x%1023s",&type, &state, uri)


½ÓÊÕµ½Êý¾Ý°üºó»áµ÷ÓÃallowedº¯Êý¶Ôip½øÐкÏÀíÐÔ¼ì²é£¬¸Ã¼ì²é¹æÔò¿Éͨ¹ý/etc/cups/cups-browsed.confÎļþ½øÐÐÅäÖá£


ͼ6.png


allowed¼ì²éͨ¹ýºó»á½«Êý¾Ý°ü´«Èëfound_cups_printerº¯Êý½øÐнøÒ»²½´¦Öá£


found_cups_printerº¯ÊýÖе÷ÓÃhttpSeparateURIº¯Êý½âÎö´«ÈëµÄuri²ÎÊý²¢½«Æä²ð·ÖΪЭÒé¡¢Óû§Ãû¡¢Ö÷»úÃû¡¢¶Ë¿Ú¡¢×ÊԴ·¾¶µÈ²¿ÃÅ¡£È»ºóƾ¾Ý½âÎöµÃµ½µÄ¸÷²¿ÃÅÐÅÏ¢£¬¶ÔuriÊÇ·ñ¼´ÊÇ¡±/printers/¡±ºÍ¡±/calsses/¡±×Ö·û´®½øÐмì²é¡£¼ì²éͨ¹ýºóµ÷ÓÃexamine_discovered_printer_recordº¯ÊýÀ´´¦Ö÷¢ÏֵĴòÓ¡»ú¼Ç¼¡£


ͼ7.png


´¦ÖÃÍêÊý¾Ýºóµ÷ÓÃcfGetPrinterAttributesº¯Êý½øÐлØÁ¬£¬ÆäÖÐÏÈʹÓÃhttpConnectº¯ÊýÏȽ¨Á¢httpÁ¬½Ó£¬È»ºóµ÷ÓÃippNewRequest½¨Á¢IPPÁ¬½Ó£¬×îºóÏòIPP Server·¢ËÍ»ñÈ¡´òÓ¡»úÊôÐÔµÄÇëÇó¡£


ͼ8.png


·¢ËÍÍêÇëÇóºócups-browsed·¨Ê½»áµ÷ÓÃppdCreatePPDFromIPP2º¯Êý´´½¨PPDÎļþÈ»ºó½«½ÓÊյĴòÓ¡»úÊôÐÔÒÀ´ÎÉú´æµ½ÎļþÀïÃæ¡£


ͼ9.png


ÖÁ´Ë£¬ÒѾ­¿ÉÒÔÀÖ³ÉÉèÖÃPPDµÄÊôÐÔ£¬½ÓÏÂÀ´¾ÍÊÇÏë´ëÊ©Ö´ÐÐдÈëµÄÊý¾Ý¡£ÕâÐèҪʹÓÃCUPSµÄÒ»¸ö¹ýÂËÆ÷Ö¸ÁîcupsFilter2£¬¸ÃÖ¸ÁîÓÃÓÚ´¦ÖôòÓ¡×÷ÒµÖеÄɸѡºÍת»»²Ù×÷¡£

ÀýÈçÏÂÃæµÄÖ¸ÁîÒªÇócups½«ÇкϴòÓ¡»úÊôÐÔµÄpostscript¸ñʽµÄÊý¾Ýͨ±¨¸øprogram¹ýÂËÆ÷½øÐд¦Öã¬ÓÅÏȼ¶Îª0¡£


*cupsFilter2:"application/pdf application/vnd.cups-postscript 0 program


CUPS¹æ¶¨Ö»ÄÜʹÓÃ/usr/lib/cups/filter·¾¶ÏÂÃæµÄ¿ÉÖ´ÐÐÎļþ£¬×îÖÕÒÔfoomatic-rip¹ýÂËÆ÷×÷ΪÀûÓõÄÄ¿±ê¡£¸Ã¹ýÂËÆ÷½ÓÊÜPPDÎļþÖеÄFoomaticRIPCommandLineÖ¸Áͨ¹ýËü¿ÉÒÔÖ´ÐÐÈÎÒâÃüÁî¡£


ËÄ¡¢Â©¶´ÐÞ¸´

½ØÖÁÄ¿Ç°£¬Ubuntu£¬Debian£¬FedoraµÈ¶à¸öϵͳÖÐÉ漰©¶´µÄ¶à¸ö°æ±¾ÒÑ»ù±¾ÐÞ¸´¡£


ͼ10.png


ÔÚUbuntu×îаæµÄÐÞ¸´·½°¸ÖÐÍêȫɾ³ý¶Ô¾É°æ CUPS ЭÒéºÍ LDAP µÄÖ§³Ö¡£


ͼ11.png


Îå¡¢»º½â´ëÊ©


©¶´ÐÞ¸´°æ±¾ÒѾ­ÉÏ´«£¬UbuntuϵͳÖÐÔËÐÐÏÂÃæÁ½ÌõÃüÁî¼´¿É½øÐÐÉý¼¶¡£


sudo apt update

sudo apt upgrade


Èç¹ûÉÏÃæµÄÉý¼¶²»Àֳɣ¬Ê¹ÓÃÏÂÃæÁ½ÖÖ´ëÊ©»º½â¸Ã©¶´£º


£¨1£©Ö±½Ó½ûÓÃcups-browsed·þÎñ

sudo systemctl stop cups-browsed

sudo systemctl disable cups-browsed


£¨2£©Èç¹û¸Ã¹¦Ð§ÐèҪʹÓ㬽¨Ò齫/etc/cups/cups-browsed.confÖÐBrowseRemoteProtocolsÖ¸ÁîÖµ´ÓĬÈϵġ°dnssd cups¡±¸ü¸ÄΪ¡°none¡±¡£


²Î¿¼Á´½Ó£º


[1]https://www.evilsocket.net/2024/09/26/Attacking-UNIX-systems-via-CUPS-Part-I/

[2]https://gist.github.com/stong/c8847ef27910ae344a7b5408d9840ee1

[3]https://censys.com/common-unix-printing-service-vulnerabilities/

[4]https://blog.ostorlab.co/cups-vulnerabilities.html

[5]https://github.com/OpenPrinting/cups-browsed/security/advisories/GHSA-rj88-6mr5-rcw8

[6]https://ubuntu.com/security/notices/USN-7043-4

[7]https://ubuntu.com/security/notices/USN-7042-3

[8]https://launchpad.net/ubuntu/+source/cups-browsed/2.0.1-0ubuntu2.1

[9]https://www.upwind.io/feed/analyzing-the-latest-cups-rce-vulnerability-threats-and-mitigations


¶«É­Æ½Ì¨»ý¼«·ÀÓùʵÑéÊÒ£¨ADLab£©


ADLab½¨Á¢ÓÚ1999Ä꣬ÊÇÖйúÄþ¾²ÐÐÒµ×îÔ罨Á¢µÄ¹¥·À¼¼ÊõÑо¿ÊµÑéÊÒÖ®Ò»£¬Î¢ÈíMAPP¼Æ»®ºËÐijÉÔ±£¬¡°ºÚȸ¹¥»÷¡±¿´·¨Ê×ÍÆÕß¡£½ØÖÁÄ¿Ç°£¬ADLabÒÑͨ¹ý CNVD/CNNVD/NVDB/CVEÀÛ¼ÆÐû²¼Äþ¾²Â©¶´5000Óà¸ö£¬Á¬Ðø±£³Ö¹ú¼ÊÍøÂçÄþ¾²ÁìÓòÒ»Á÷Ë®×¼¡£ÊµÑéÊÒÑо¿Æ«Ïòº­¸Ç»ù´¡Äþ¾²Ñо¿¡¢Êý¾ÝÄþ¾²Ñо¿¡¢5GÄþ¾²Ñо¿¡¢È˹¤ÖÇÄÜÄþ¾²Ñо¿¡¢Òƶ¯Äþ¾²Ñо¿¡¢ÎïÁªÍøÄþ¾²Ñо¿¡¢³µÁªÍøÄþ¾²Ñо¿¡¢¹¤¿ØÄþ¾²Ñо¿¡¢ÐÅ´´Äþ¾²Ñо¿¡¢ÔÆÄþ¾²Ñо¿¡¢ÎÞÏßÄþ¾²Ñо¿¡¢¸ß¼¶ÍþвÑо¿¡¢¹¥·ÀÌåϵ½¨Éè¡£Ñо¿½á¹ûÓ¦ÓÃÓÚ²úÎïºËÐļ¼ÊõÑо¿¡¢¹ú¼ÒÖصã¿Æ¼¼ÏîÄ¿¹¥¹Ø¡¢×¨ÒµÄþ¾²·þÎñµÈ¡£


adlab.jpg