DNSpooqϵÁÐÎó²îÆÊÎöÓ븴ÏÖ
Ðû²¼Ê±¼ä 2021-02-01Ç°ÑÔ
½üÆÚ£¬ÒÔÉ«ÁÐÇå¾²×ÉѯÆóÒµJSOFÔÚ×îб¨¸æÖÐÅû¶ÁËÆ߸ö DNSmasq Îó²î£¨Í³³Æ DNSpooq£©£¬²¢Ö¸³ö¹¥»÷Õß½è´ËѬȾÁËÊýÒÔ°ÙÍò¼ÆµÄ×°±¸¡£DNSmasq ÊÇÒ»Ì×Ê¢ÐеĿªÔ´ DNS ת·¢Èí¼þ£¬Äܹ»ÎªÔËÐиÃÈí¼þµÄÍøÂç×°±¸Ìí¼Ó DNS »º´æºÍ DHCP ·þÎñÆ÷¹¦Ð§£¬ÆÕ±éÓÃÓÚÖÖÖÖСÐ;ÖÓòÍøÂç¡£ÊÜ DNSpooq Ó°ÏìµÄ×°±¸²»µ«¿ÉÄÜÔâÓö DNS »º´æÖж¾£¬»¹¿É±»ÓÃÓÚÔ¶³Ì´úÂëÖ´ÐС¢¾Ü¾ø·þÎñ£¨DoS£©¹¥»÷¡£ÏÖÔÚÊÜÓ°ÏìµÄ³§ÉÌ°üÀ¨µ«²»ÏÞÓÚ Android / Google¡¢¿µ¿¨Ë¹ÌØ¡¢Ë¼¿Æ¡¢ºìñ¡¢Netgear¡¢¸ßͨ¡¢Linksys¡¢IBM¡¢D-LinkÒÔ¼° Ubiquiti ¡£Æ¾Ö¤shodanÏÔʾ£¬Óг¬100Íǫ̀ӦÓÃDNSmasqµÄ×°±¸Ì»Â¶ÔÚ¹«Íø£¬¿ÉÄÜÊÜÓ°ÏìµÄ×°±¸Êý²»Ê¤Êý¡£
ÆäÖУ¬ CVE-2020-25684¡¢CVE-2020-25685 ºÍ CVE-2020-25686 ÕâÈý¸öÎó²î£¬¿ÉÄܵ¼Ö DNS ·þÎñÔâÓö»º´æÖж¾¹¥»÷¡£ÁíÍâËĸöÎó²îΪ CVE-2020-25687¡¢CVE-2020-25683¡¢CVE-2020-25682 ºÍ CVE-2020-25681 £¬¾ùΪ»º³åÇøÒç³öÎó²î¡£ºÚ¿Í»ò¿ÉÔÚÉèÖÃÁË DNSmasq µÄÍøÂç×°±¸ÉÏ£¬Ê¹ÓÃÕâЩÎó²îÔ¶³ÌÖ´ÐÐí§Òâ´úÂë¡£
DNSÐÒé¼ò½é
DNSµÄÇëÇóºÍÏìÓ¦µÄ»ù±¾µ¥Î»ÊÇDNS±¨ÎÄ£¨Message£©¡£ÇëÇóºÍÏìÓ¦µÄDNS±¨ÎĽṹÊÇÍêÈ«ÏàͬµÄ£¬Ã¿¸ö±¨ÎĶ¼ÓÉÒÔÏÂÎå¶Î£¨Section£©×é³É£º
DNS HeaderÊÇÿ¸öDNS±¨ÎĶ¼±ØÐèÓµÓеÄÒ»²¿·Ö£¬ËüµÄ³¤¶ÈÀο¿Îª12¸ö×Ö½Ú¡£Question²¿·Ö´æ·ÅµÄÊÇÏò·þÎñÆ÷ÅÌÎʵÄÓòÃûÊý¾Ý£¬Ò»Ñùƽ³£ÇéÐÎÏÂËüÖ»ÓÐÒ»ÌõEntry¡£Ã¿¸öEntryµÄÃûÌÃÊÇÏàͬµÄ£¬ÈçÏÂËùʾ£º
QNAME£ºÓÉlabelsÐòÁÐ×é³ÉµÄÓòÃû¡£QNAMEµÄÃûÌÃʹÓÃDNS±ê×¼Ãû³ÆÌåÏÖ·¨¡£Õâ¸ö×Ö¶ÎÊDZ䳤µÄ£¬Òò´ËÓпÉÄÜ·ºÆðÆæÊý¸ö×Ö½Ú£¬µ«²»¾ÙÐв¹Æë¡£DNSʹÓÃÒ»ÖÖ±ê×¼ÃûÌöÔÓòÃû¾ÙÐбàÂë¡£ËüÓÉһϵÁеÄlabel£¨ºÍÓòÃûÖÐÓÃ.Ö§½âµÄlabel²î±ð£©×é³É¡£Ã¿¸ölabelÊ××ֽڵĸßÁ½Î»ÓÃÓÚÌåÏÖlabelµÄÀàÐÍ¡£RFC1035ÖзÖÅÉÁËËĸöÄÚÀïµÄÁ½¸ö£¬»®·ÖÊÇ£º00ÌåÏÖµÄͨË×label£¬11£¨0xC0£©ÌåÏÖµÄѹËõlabel¡£
Answer£¬AuthorityºÍAdditionalÈý¸ö¶ÎµÄÃûÌÃÊÇÍêÈ«ÏàͬµÄ£¬¶¼ÊÇÓÉÁãÖÁ¶àÌõResource Record£¨×ÊÔ´¼Í¼£©×é³É¡£ÕâЩ×ÊÔ´¼Í¼ÓÉÓÚ²î±ðµÄÓÃ;¶ø±»ÍÑÀë´æ·Å¡£Answer¶ÔÓ¦ÅÌÎÊÇëÇóÖеÄQuestion£¬QuestionÖеÄÇëÇóÅÌÎÊЧ¹û»áÔÚAnswerÖиø³ö£¬ÈôÊÇÒ»¸öÏìÓ¦±¨ÎĵÄAnswerΪ¿Õ£¬ËµÃ÷Õâ´ÎÅÌÎÊûÓÐÖ±½Ó»ñµÃЧ¹û¡£
RR(ResourceRecord)×ÊÔ´¼Í¼ÊÇDNSϵͳÖкÜÊÇÖ÷ÒªµÄÒ»²¿·Ö£¬ËüÓµÓÐÒ»¸ö±ä³¤µÄ½á¹¹£¬ÏêϸÃûÌÃÈçÏ£º
¡ñ NAME£ºËüÖ¸¶¨¸ÃÌõ¼Í¼¶ÔÓ¦µÄÊÇÄĸöÓòÃû£¬ÃûÌÃʹÓÃDNS±ê×¼Ãû³ÆÌåÏÖ·¨
¡ñ TYPE£º×ÊÔ´¼Í¼µÄÀàÐÍ¡£
¡ñ CLASS£º¶ÔÓ¦QuestionµÄQCLASS£¬Ö¸¶¨ÇëÇóµÄÀàÐÍ£¬³£ÓÃֵΪIN£¬ÖµÎª0x001¡£
¡ñ TTL(Time To Live)×ÊÔ´µÄÓÐÓÃÆÚ£ºÌåÏÖÄã¿ÉÒÔ½«¸ÃÌõRR»º´æTLLÃ룬TTLΪ0ÌåÏÖ¸ÃRR²»¿É±»»º´æ¡£TTLÊÇÒ»¸ö4×Ö½ÚÓзûºÅÊý£¬¿ÉÊÇֻʹÓÃËü´óÓÚ¼´ÊÇ0µÄ²¿·Ö¡£
¡ñ RDLENGTH£ºÒ»¸öÁ½×ֽڷǸºÕûÊý£¬ÓÃÓÚÖ¸¶¨RDATA²¿·ÖµÄ³¤¶È£¨×Ö½ÚÊý£©¡£
¡ñ RDATA£ºÌåÏÖÒ»¸ö³¤¶ÈºÍ½á¹¹¶¼¿É±äµÄ×ֶΣ¬ËüµÄÏêϸ½á¹¹È¡¾öÓÚTYPE×Ö¶ÎÖ¸¶¨µÄ×ÊÔ´ÀàÐÍ¡£
DNS³£¼û×ÊÔ´¼Í¼ÀàÐÍÓÐNS¼Í¼¡¢A¼Í¼¡¢CNAME¼Í¼¡£
¡ñ NS¼Í¼
NS¼ÍÈÎÃüÓÚÖ¸¶¨Ä³¸öÓòµÄȨÍþDNS¡£ºÃ±ÈÔÚcomµÄDNSÀ¼Í¼×Åhttp://www.dgsseo.comÕâ¸öÓòµÄDNS£¬»òÐíÈçÏ£º
www.dgsseo.com. NS ns1.www.dgsseo.com.
www.dgsseo.com. NS ns2.www.dgsseo.com.
www.dgsseo.com. NS ns3.www.dgsseo.com.
ÕâÈýÌõ¼Í¼£¬¾ÍÊÇ˵http://ns1.www.dgsseo.com¡¢http://ns2.www.dgsseo.com¡¢http://ns3.www.dgsseo.com£¨ÒÔϼò³Æns1¡¢ns2¡¢ns3£©¶¼ÊÇhttp://www.dgsseo.comÓòµÄȨÍþDNS£¬Ñ¯ÎÊí§ÒâÆäÖÐÒ»¸ö¶¼¿ÉÒÔ¡£
ËäÈ»£¬ÔÚcomµÄȨÍþDNSÀ»¹»á¼Í¼ns1~ns3Õ⼸¸öhttp://www.dgsseo.comȨÍþDNSµÄIP£¬»áÒ»²¢·µ»Ø¸øÎÊѯÕߣ¬ÒÔ±ãÎÊѯÕßÖ±½ÓÓÃIPÁªÏµns1~ns3¡£
¡ñ A¼Í¼
A¼Í¼¾ÍÊÇ×î¾µäµÄÓòÃûºÍIPµÄ¶ÔÓ¦£¬ÔÚhttp://ns1.www.dgsseo.comÄÚÀ¼Í¼×Űٶȹ«Ë¾¸÷²úÆ·µÄÓòÃûºÍIPµÄ¶ÔÓ¦¹Øϵ£¬Ã¿Ò»¸öÕâÑùµÄ¼Í¼£¬¾ÍÊÇÒ»¸öA¼Í¼£¬ºÃ±ÈÏÂÃæµÄ3¸öA¼Í¼£º
image.www.dgsseo.com A 1.2.3.4
wenku.www.dgsseo.com A 5.6.7.8
tieba.www.dgsseo.com A 9.10.11.12
ÈôÊÇÓû§Ñ¯ÎÊhttp://ns1.www.dgsseo.com£º¡°http://wenku.www.dgsseo.comµÄIPÊǼ¸¶à£¿¡±£¬ns1¾Í»áÕÒµ½¶ÔÓ¦µÄA¼Í¼»òÕßCNAME¼Í¼²¢·µ»Ø¡£
¡ñ CNAME¼Í¼
CNAME¼Í¼Ҳ³ÆÓÖÃû¼Í¼£¬ÔÊÐí½«¶à¸ö¼Í¼ӳÉ䵽ͳһ̨ÅÌËã»úÉÏ¡£ºÃ±È£¬ÔÚns1ÖУ¬²¢Ã»ÓÐhttp://www.www.dgsseo.comµÄA¼Í¼£¬¶øÊÇÒ»¸öCNAME¼Í¼£º
www.www.dgsseo.com CNAME www.a.shifen.com
Ò²¾ÍÊǸæËßÓû§£¬http://www.www.dgsseo.comµÄÓÖÃûÊÇhttp://www.a.shifen.com£¬¿ÉÒÔÖ±½ÓÇëÇóÆÊÎöhttp://www.a.shifen.com¡£
DNS»º´æ¹¥»÷
µ±»á¼ûwww.www.dgsseo.comʱ£¬ÓòÃûÆÊÎöµÄ´óÖÂÁ÷³ÌÈçÏÂͼËùʾ¡£
DNS»º´æÖж¾ÊÇÒ»ÖÖ½ÏÁ¿¾µäµÄ¹¥»÷·½·¨£¬ÈôÊǹ¥»÷Õß¿ÉÒÔÀÖ³ÉÖ´ÐУ¬¾Í»áÔÚDNS»º´æ·þÎñÆ÷ÉÏÁôÏÂÒ»¸öÓꦵÄÌõÄ¿£¬Ê¹µÃÓû§»á¼ûÕý³£ÍøÕ¾µÄÇëÇóÖض¨Ïòµ½±»¹¥»÷Õß¿ØÖƵĶñÒâÍøÕ¾¡£
DNSpooqϵÁлº´æÖж¾Îó²îµÄ¼òÆÓ¹¥»÷Á÷³ÌͼÈçÏÂͼËùʾ£º
£¨1£©Óû§·¢ËÍä¯ÀÀÌÔ±¦µÄÇëÇó¸øDNSת·¢Æ÷£¬Ï£Íû»ñµÃ¶ÔÓ¦µÄIP¡£
£¨2£©DNSת·¢Æ÷ûÓдËÓòÃûµÄ»º´æ£¬ÒÔÊǽ«ÇëÇóת·¢¸øÉÏÓÎDNS·þÎñÆ÷¡£
£¨3£©ÔÚ»ñµÃÉÏÓÎDNS·þÎñÆ÷»Ø¸´Ç°£¬¹¥»÷Õß·¢ËÍÒ»¸öαÔìµÄ»Ø¸´£¬½«ÌÔ±¦ÓòÃûÓëÒ»¸ö¶ñÒâIPÏà¶ÔÓ¦¡£
£¨4£©DNSת·¢Æ÷½ÓÊÜÁËÕâ¸öαÔìµÄ»Ø¸´£¬²¢·¢Ë͸øÓû§£¬ÓÚÊÇÓû§ÇëÇó»á¼ûµÄÌÔ±¦±»Öض¨Ïòµ½Á˹¥»÷ÕßʹÓõĶñÒâÍøÕ¾¡£
Õâ¸öDNSת·¢Æ÷Ó¦Óó¡¾°ºÜÆձ飬ºÃ±ÈСÎÒ˽¼Ò¿ªµÄÈÈÃÅ£¬»ú³¡¡¢±ö¹ÝÀïµÄ¹«¹²ÍøÂçµÈ£¬Ò»µ©¹¥»÷Àֳɣ¬ÔòÓ°ÏìʹÓÃÕâЩÍøÂçµÄËùÓÐÈË¡£
ÔÚDNS HeaderÖÐÓÐÒ»¸ö16-bitµÄÇøÓò½ÐTXID£¨transaction ID£©£¬ÓÃÓÚ½«ÅÌÎÊ°üºÍ»Ø¸´°üÆ¥Åä¡£ÔÚÒÑÍù£¬TXIDÊÇ·ÀÓùDNS»º´æÖж¾µÄÖ÷ÒªÊֶΡ£¿ÉÊÇÔÚ2008Ä꣬Çå¾²Ñо¿Ô±Dan Kaminsky֤ʵ16-bitµÄTXIDÊÇÔ¶Ô¶²»·óµÄ£¬ØʺóÓÖÔöÌíÁ˶˿ÚËæ»ú»¯£¬ÒÔÊÇÕâ¸öʱ¼äÏëαÔì»Ø¸´°ü£¬²»µ«ÐèÒª²Â¶ÔTXID£¬»¹ÐèÒª²Â¶Ô¶Ë¿Ú£¬Ò»¹²32λµÄËæ»úÖµ£¬±ðµÄ»¹ÐèÒªÖªµÀÔ´IPºÍÄ¿µÄIP¡£
DNSÇå¾²À©Õ¹
µ½ÁË21ÊÀ¼Í£¬DNSÇå¾²À©Õ¹ÕýÔÚ±»Öð²½Ó¦Óá£DNSÇå¾²À©Õ¹ÊÇÏÖÔÚΪÏàʶ¾öDNSÓÕÆ»ººÍ´æÎÛȾÎÊÌâ¶øÉè¼ÆµÄÒ»ÖÖÇå¾²»úÖÆ¡£DNSSECÒÀÀµÊý×ÖÊðÃûÀ´°ü¹ÜDNSÓ¦´ð±¨ÎĵÄÕæʵÐÔºÍÍêÕûÐÔ¡£¼òÆÓÀ´Ëµ£¬È¨Íþ·þÎñÆ÷ʹÓÃ˽Կ¶Ô×ÊÔ´¼Í¼¾ÙÐÐÊðÃû£¬µÝ¹é·þÎñÆ÷ʹÓÃȨÍþ·þÎñÆ÷µÄ¹«Ô¿¶ÔÓ¦´ð±¨ÎľÙÐÐÑéÖ¤¡£ÈôÊÇÑé֤ʧ°Ü£¬Ôò˵Ã÷ÕâÒ»±¨ÎÄ¿ÉÄÜÊÇÓÐÎÊÌâµÄ¡£
ΪÁËʵÏÖ×ÊÔ´¼Í¼µÄÊðÃûºÍÑéÖ¤£¬DNSSECÔöÌíÁËËÄÖÖÀàÐ͵Ä×ÊÔ´¼Í¼£ºRRSIG£¨Resource Record Signature£©¡¢DNSKEY£¨DNS Public Key£©¡¢DS£¨Delegation Signer£©¡¢NSEC£¨Next Secure£©¡£
ÀýÈçÎÒÃÇÖ´ÐÐÏÂÁîÐУºdig @8.8.8.8 paypal.com£¬»ñµÃµÄDNSÅÌÎÊЧ¹ûÈçÏÂËùʾ£º
ºì¿òÖÐΪӦ´ð²¿·Ö£¬ÕâÊÇ먦ÆôDNSSECµÄÇéÐÎϵġ£ÎÒÃÇÖ´ÐÐÏÂÁîÐУºdig+dnssec @8.8.8.8 paypal.com£¬»ñµÃµÄDNSÅÌÎÊЧ¹ûÈçÏÂËùʾ£º
À¶¿òÖм´ÊÇRRSIG×ÊÔ´¼Í¼´æ´¢£¬¸Ã×ÊÔ´¼Í¼´æ´¢µÄÊǶÔ×ÊÔ´¼Í¼ÜöÝÍ£¨RRSets£©µÄÊý×ÖÊðÃû¡£
Dnsmasq»º´æÖж¾Îó²î
ÒÔÏÂÈý¸öÎó²î£¬×éºÏÆðÀ´ÓÿÉÒÔ½µµÍαÔì»Ø¸´°üµÄìØÖµ¡£
¡ñ CVE-2020-25684
DNSmasq×Ô¼ºÏÞÖÆÁËת·¢¸øÉÏÓηþÎñÆ÷ÅÌÎÊ°üµÄÊýÄ¿£¬Í¨³£×î´óÊÇ150Ìõ¡£Óû§¿ÉÒÔ×Ô¼ºÉ趨Õâ¸öÖµ¡£×ª·¢ÅÌÎÊʹÓõÄÊÇfrec(forwardrecord)½á¹¹¡£Ã¿¸öfrec¶¼ºÍTXIDÏà¹ØÁª¡£µ±»Ø¸´±»½ÓÊÜ»ò¾ÓÉһ׼ʱ¼ä£¬Õâ¸öfrecs¾Í»á±»É¾³ý¡£
ͨ³£ÇéÐÎÏ£¬ÓÃÓÚת·¢ÅÌÎʵÄsocketÊýÄ¿±»ÏÞÖÆÔÚ64¸ö¡£Ã¿¸öÓÃÓÚת·¢µÄsocketºÍÒ»¸öËæ»úµÄ¶Ë¿Ú°ó¶¨¡£
ÀíÂÛÉÏ£¬ÅÌÎÊ°üÖÐTXIDºÍÔ´¶Ë¿Ú¼ÓÆðÀ´»áÓÐ32-bitµÄìØ¡£¿ÉÊÇÏÖʵÉÏ£¬Õâ¸öìØÒª¸üÉÙһЩ¡£ÓÉÓÚdnsmasqÔÚͳһ¸ö¶Ë¿Ú»á¶à·¸´Óöà¸öTXID£¬¶øûÓн«Ã¿¸öTXIDºÍÿ¸ö¶Ë¿ÚÉèÖÃΪÖðÒ»¶ÔÓ¦µÄ¹Øϵ£¬ÈçÏÂͼËùʾ¡£Ð§¹û¾ÍÊÇ£¬¹¥»÷ÕßÖ»ÐèÒªÁÏÖÐ64¸ö¶Ë¿ÚÖеÄÒ»¸ö¶Ë¿ÚÉÐÓÐ׼ȷµÄTXID¾Í¿ÉÒÔÁË£¬¶ø²»±ØÁÏÖÐij¸öÌض¨µÄ¶Ë¿ÚºÍÌض¨µÄTXID¡£ÒÔÊÇÕâµ¼ÖÂÏÖʵÉÏÖ»ÓÐ26λìØÖµ¡£
¡ñ CVE-2020-25685
ÈôÊÇÒª¶ÔDNSת·¢Æ÷¾ÙÐÐͶ¶¾£¬³ýÁËÐèÒª²Â¶Ô׼ȷµÄTXIDºÍÔ´¶Ë¿Ú£¬¹¥»÷Õß·¢ËÍαÔìµÄ»Ø¸´»¹ÐèҪƥÅäÒÑ¿ª·ÅµÄfrecs¡£ÈôÊÇÏëÈÃfrecÆ¥Å䣬ÄÇôTXIDºÍÎÊÌâÇø¶¼ÒªÆ¥Å䣬»»¾ä»°Ëµ£¬»Ø¸´µÄÄÚÈÝÊÇ֮ǰѯÎʹýµÄ¡£
dnsmasqÖ»´æ·ÅÎÊÌâÇøµÄ¹þÏ£Öµ£¬¶ø²»ÊÇ°ÑÕû¸öÓï¾ä´æÏÂÀ´¡£µ±Õû¸öÅÌÎÊÌá½»µÄʱ¼ä£¬Õâ¸ö¹þÏ£Öµ»á±»ÉúÑÄ¡£
ÈôÊÇdnsmasqûÓбàÒëDNSSECÖ§³Ö£¬ÄÇôËûĬÈÏʹÓÃCRC32×÷Ϊ¹þÏ£Ëã·¨¡£ÎÊÌâ¾ÍÔÚÓÚCRC32´ÓÃÜÂëѧ½Ç¶È²¢²»ÊÇÒ»¸öÇå¾²µÄËã·¨¡£¿ÉÒÔºÜÇáËɵÄʹÓÃÀàËÆSMT solverµÈ¹¤¾ß¾ÙÐÐCRC32Åöײ£¬ÕâÀïÔÀí²»×ö¹ý¶àÏÈÈÝ¡£
ÒÔÊÇ»ùÓÚÕâÒ»ÌØÕ÷£¬¹¥»÷Õß¿ÉÒÔÌìÉú¶à¸öÅÌÎÊ£¬Ã¿Ò»¸öÅÌÎʵÄCRC32µÄÖµ¶¼Ïàͬ£¬²»¹ýÅÌÎʵÄÊDzî±ðµÄÓòÃû£¬¶øÕâЩÓòÃû×îºÃÊDz»±£´æµÄ£¬¼´Ã»Óб»»º´æµÄ¡£È»ºó¹¥»÷Õß¿ÉÒÔ·¢ËÍÒ»¸ö¾ßÓÐÏàͬCRC32ÖµµÄαÔìµÄ»Ø¸´¡£
ÈçÏÂͼËùʾ£¬¹¥»÷Õß¿ØÖÆһ̨¿Í»§¶Ë¶Ô¶à¸öÓòÃûÌᳫÎÊѯ£¬Ã¿Ò»¸öCRC32µÄÖµ¶¼ÊÇÏàͬµÄ£¬È»ºóÔڵݹéDNS·þÎñÆ÷»Ø¸´Ö®Ç°£¬»Ø¸´Ò»¸ö¾ßÓÐÏàͬCRC32ÖµµÄÓòÃû»òIP£¬¹¥»÷¼´ÓпÉÄÜÀֳɡ£
¡ñ CVE-2020-25686
dnsmasqµÄÁíÒ»¸öÎÊÌâ¾ÍÊÇÔÚͳһ¸öÓòÃû±»ÅÌÎÊÇëÇóʱ»á´Ö±©µÄ½¨Éè¶à¸öfrecs¡£Ëæºó»áת·¢ËùÓеÄÇëÇó£¬ÈôÊÇÀֳɵÄÆ¥ÅäÆäÖеÄí§ÒâÒ»¸ö£¬¾Í¼ÆÈ뻺´æ¡£Õâ¸öÎÊÌâµ¼Ö¾ÍËãdnsmasqʹÓÃÇå¾²µÄ¹þÏ£Ëã·¨£¬Ò²¿ÉÄÜÀֳɵÄʵÑé¹¥»÷¡£
ͨ¹ýÒÔÉÏÈý¸öÎó²î£¬µ¼Ö¹¥»÷ÕßαÔì¶ñÒâ»Ø¸´°üµÄÀÖ³ÉÂÊ´ó´óÌá¸ß£¬ºóÃ滹ÐèҪʹÓÃdnsmasqûÓжԻظ´°ü×öÑéÖ¤µÄÌØÕ÷¾ÙÐй¥»÷¡£
Ò»Ñùƽ³£ÇéÐÎÏ£¬Ôڵݹé·þÎñÆ÷ÉÏ»á¶Ô»Ø¸´°ü×öһЩÑéÖ¤»úÖÆ£¬ÀýÈçbailiwicks¡£¿ÉÊÇÔÚÉèÖÃdnsmasqµÄ×°±¸Éϲ¢Ã»ÓÐ×öÈκÎÑéÖ¤£¬ÒÔÊÇ¿ÉÒÔÔÚÓû§ÇëÇówww.example.comµÄʱ¼ä£¬¹¥»÷Õß¿ÉÒÔ·¢ËÍÈçÏ»ظ´:
www.example.com CNAME www.bank.com
www.bank.com A 6.6.6.6
È»ºóÕâÌõ¼Í¼µÄ»º´æ¾Í»á±»²åÈëµ½dnsmasqµÄ×°±¸ÖС£Ç°ÎÄÏÈÈݹýCNAME£¬ÒÔÊǵ±Óû§Ïë»á¼ûwww.bank.comµÄʱ¼ä£¬»á±»Öض¨Ïòµ½±»¹¥»÷Õß¿ØÖƵÄIPΪ6.6.6.6µÄ·þÎñÆ÷¡£¶øÉèÖÃÁËÀàËÆbailiwicksµÄ×°±¸£¬»áÈ¥ÕÒȨÍþ·þÎñÆ÷ѯÎÊwww.bank.comµÄIP¡£
Dnsmasq»º³åÇøÒç³öÎó²î
¡ñ CVE-2020-25681
ÒÔÏÂÃû³ÆÒԹ淶µÄDNSÃû³Æ˳ÐòÅÅÐò¡£×îÖ÷ÒªµÄ±êÇ©ÊÇ¡°example¡±¡£Ôڴ˼¶±ðÉÏ£¬¡°example¡±½«Ê×ÏÈÅÅÐò£¬È»ºóÊÇÒÔ¡°a.example¡±×îºóµÄÃû³Æ£¬È»ºóÊÇÒÔ¡°z.example¡±×îºóµÄÃû³Æ¡£Ã¿¸ö¼¶±ðÖеÄÃû³ÆÒÔÏàͬµÄ·½·¨ÅÅÐò¡£ÈçÏÂͼËùʾ¡£
CVE-2020-25681Îó²îλÓÚdnssec.cÎļþµÄsort_rrset()º¯ÊýÖУ¬¸Ãº¯ÊýÈÏÕæƾ֤DNSSECÑéÖ¤Àú³ÌµÄÒªÇó½ÓÄÉðÅÝÅÅÐòËã·¨½«¸ø¶¨µÄ×ÊÔ´¼Í¼ÜöÝÍ£¨RRSets£©ÅÅÐòΪ¹æ·¶Ë³Ðò¡£¸Ãº¯Êý½ç˵ÈçÏ£º
Ëü½ÓÊÜÁËÏìÓ¦Êý¾Ý°ü£¨header£©ÒÔ¼°Êý¾Ý°ü³¤¶È£¨plen£©¡£rrsetÊÇÖ¸Ïò×ÊÔ´¼Í¼ÜöÝÍÖÐRRÊý×éµÄÖ¸Õ룬¶ørrsetidxÊÇÜöÝÍÖеÄRRÊý£¬rr_descÊÇÖ¸ÏòÓëRRset¹ØÁªµÄRRÀàÐ͵ÄÐÎò·ûµÄÖ¸Õë¡£×îºó£¬ÓÐÁ½¸ö»º³åÇøbuff1ºÍbuff2£¬ËüÃÇÓÃ×÷ÅÅÐòÀý³ÌµÄÊÂÇéÇø»º³åÇø¡£ÕâÁ½¸ö»º³åÇøÔÚ³ÌÐò×îÏÈʱ¶¼ÊÇÏà¶Ô·ÖÅɵģ¬ËüÃÇÊÇdaemon> workspacenameºÍdaemon-> keyname¡£µ±dnsmasq¿ªÆôDNSSECʱ£¬½«»á·ÖÅÉÕâÁ½¸ö»º³åÇø¡£
MAXDNAME¾ÞϸΪ1025£¬ÒÔÊÇworkspacenameºÍkeynameµÄ¾Þϸ2050£¬Ò²ÊǸÃÎó²î±¬·¢Òç³öµÄ»º³åÇø¡£
Ê×ÏÈÆô¶¯dnsmasq£¬²¢ÉèÖòÎÊýΪ£º
-p 53535 --no-daemon --log-queries -S127.0.0.2 --no-hosts --no-resolv -d -q --dnssec--trust-anchor=.,20326,8,2,E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D£¬½á¹¹Íê¶ñÒâDNSÅÌÎÊÏìÓ¦°ü£¬Ê¹ÓÃÏÂÁîÐУºdig NS+dnssec @localhost -p 53535 .£¬ÖÀÖÐsort_rrset()º¯Êý¶ÏµãºóÈçÏÂͼËùʾ£º
Ôڽṹ×ÊÔ´¼Í¼ÜöÝÍ£¨RRSets£©Ê±£¬±ØÐè°ü¹Ü¼Í¼¸öÊý´óÓÚ1£¬ÕâÑù²Å»ª°ü¹Ü½øÈëÅÅÐòÑ»·¡£
ÕâÀï½á¹¹µÄrrsetidxΪ0x3¡£
Õý³£Êý¾Ý°üÈçÏÂͼËùʾ£º
Answers¿éÖУ¬p1Ö¸ÏòµÚÒ»¸ö×ÊÔ´¼Í¼£¬p2Ö¸ÏòµÚ¶þ¸ö£¬È»ºó¾ÙÐÐÅÅÐò¡£
»®·ÖÌø¹ýClass£¬TypeºÍTTL£¬µÖ´ïRDATAÇøÓò¡£
Data lenghΪ20£¬ÎªName ServerµÄ³¤¶È¡£È»ºó½øÈëÅÅÐòÑ»·¡£
ÐÐ315£¬Ê×ÏÈŲÓÃget_rdata()º¯ÊýÆÊÎöµÚÒ»¸ö×ÊÔ´¼Í¼p1µÄRDATAÓòÖеÄNameServer£¬¿´Ï¸ú¯ÊýʵÏÖ¡£
ÅжÏdÊÇ·ñ¼´ÊÇ-1£¬ÕâÀï²»¼´ÊÇ£¬²»½øÈëifÓï¾ä£¬À´µ½ÈçÏ´úÂë¡£
È»ºóŲÓÃextract_name()º¯ÊýÆÊÎö£¬ÕâÀïÐèÒª°ü¹Üextract_name()º¯ÊýÆÊÎö¹ýʧ·µ»Ø0£¬°ü¹Ü½øÈëget_rdata()º¯Êý·µ»ØΪ0£¬Í¨¹ýÉèÖ󬳤NameServer×Ö·û´®¼´¿É¡£
½øÈëifÓï¾ä£¬ÐÐ318£¬ÅÌËãlen1£¬Îªend1-p1£¬¼´ÊÇNameServerµÄ³¤¶È¡£ÐÐ319£¬Å²ÓÃmemcpy()½«p1¿½±´µ½buff1+left1ÖС£
ÕâÀïlen1ÉèÖÃΪ3550£¬p1ΪNameServer£¬³¤¶ÈRDLENGTHΪÓû§¿É¿Ø¡£Ç°ÎÄÒѾÏÈÈÝbuff1Ϊdaemon>workspacename£¬¾ÞϸΪ2020£¬Òò´Ë±¬·¢¶ÑÒç³ö¡£
»º½â²½·¥
¡ñ Éý¼¶dnsmasqµ½×îа汾(2.83¼°ÒÔÉÏ)£¬ÕâÊÇÏÖÔÚ×îÓÐÓõÄÒªÁì¡£
¡ñ ÈôÊDz»ÐëÒª£¬ÉèÖÃdnsmasq×°±¸²»ÒªÔÚWAN¿Ú¼àÌý¡£
¡ñ Ö»¹ÜÉèÖÃdnsmasq×î´óת·¢ÅÌÎÊÌõĿСһµã¡£
¡ñ ÔÝʱ¹Ø±ÕDNSSECÑé֤ѡÏî¡£
¡ñ ʹÓÃΪDNSÌṩ´«ÊäÇå¾²µÄÐÒ飬ÈçDoT»òDoH¡£
²Î¿¼Á´½Ó£º
[1] https://www.jsof-tech.com/disclosures/dnspooq/
[2] https://www.jsof-tech.com/wp-content/uploads/2021/01/DNSpooq-Technical-WP.pdf
[3] https://www.rfc-editor.org/rfc/rfc1664.txt
[4] https://security.googleblog.com/2017/10/behind-masq-yet-more-dns-and-dhcp.html
[5] https://spoofer.caida.org/summary.php
[6] https://www.rfc-editor.org/rfc/rfc7858.txt
[7] https://www.rfc-editor.org/rfc/rfc5452.txt
[8] http://www.thekelleys.org.uk/dnsmasq/doc.html
[9]https://dl.acm.org/doi/10.1145/3372297.3417280
[10] https://github.com/Z3Prover/z3
[11] https://www.chromium.org/developers/design-documents/dns-prefetching
[12] https://www.rfc-editor.org/rfc/rfc4033.txt
[13] https://zhuanlan.zhihu.com/p/92899876
ÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøÆð¾¢·ÀÓùʵÑéÊÒ£¨ADLab£©
ADLab½¨ÉèÓÚ1999Ä꣬ÊÇÖйúÇå¾²ÐÐÒµ×îÔ罨ÉèµÄ¹¥·ÀÊÖÒÕÑо¿ÊµÑéÊÒÖ®Ò»£¬Î¢ÈíMAPPÍýÏë½¹µã³ÉÔ±£¬¡°ºÚȸ¹¥»÷¡±¿´·¨Ê×ÍÆÕß¡£×èÖ¹ÏÖÔÚ£¬ADLabÒÑͨ¹ýCVEÀÛ¼ÆÐû²¼Çå¾²Îó²î½ü1100¸ö£¬Í¨¹ý CNVD/CNNVDÀÛ¼ÆÐû²¼Çå¾²Îó²î1000Óà¸ö£¬Ò»Á¬¼á³Ö¹ú¼ÊÍøÂçÇå¾²ÁìÓòÒ»Á÷Ë®×¼¡£ÊµÑéÊÒÑо¿Æ«Ïòº¸Ç²Ù×÷ϵͳÓëÓ¦ÓÃϵͳÇå¾²Ñо¿¡¢ÖÇÄÜÖÕ¶ËÇå¾²Ñо¿¡¢ÎïÁªÍøÖÇÄÜ×°±¸Çå¾²Ñо¿¡¢WebÇå¾²Ñо¿¡¢¹¤¿ØϵͳÇå¾²Ñо¿¡¢ÔÆÇå¾²Ñо¿¡£Ñо¿Ð§¹ûÓ¦ÓÃÓÚ²úÆ·½¹µãÊÖÒÕÑо¿¡¢¹ú¼ÒÖصã¿Æ¼¼ÏîÄ¿¹¥¹Ø¡¢×¨ÒµÇå¾²·þÎñµÈ¡£