Ô´´ | Ripple20£ºTreck TCP/IPÐÒéÕ»Îó²îÆÊÎöÓëÑéÖ¤
Ðû²¼Ê±¼ä 2020-06-30Ò»¡¢Ç°ÑÔ
ÍâÑóÇå¾²Ñо¿Ö°Ô±ÔÚÓÉTreck¿ª·¢µÄTCP/IPÐÒéÕ»Öз¢Ã÷Á˶à¸öÎó²î£¬ÕâһϵÁÐÎó²îͳ³ÆΪRipple20¡£ÕâЩÎó²îÆձ鱣´æÓÚǶÈëʽºÍÎïÁªÍø×°±¸ÖУ¬Ó°ÏìÁ˶à¸öÐÐÒµÁìÓò£¨°üÀ¨Ò½ÁÆ¡¢ÔËÊä¡¢ÄÜÔ´¡¢µçÐÅ¡¢¹¤Òµ¿ØÖÆ¡¢ÁãÊÛºÍÉÌÒµµÈ£©£¬Éæ¼°ÁËÖڶ๩ӦÉÌ£¨°üÀ¨HP¡¢Schneider Electric¡¢Intel¡¢Rockwell Automation¡¢Caterpillar¡¢BaxterµÈ£©¡£
ÕâЩÎó²îÔ´ÓÚRipple20µÄ¶à¸öÐÒ飨°üÀ¨IPv4¡¢ICMPv4¡¢IPv6¡¢IPv6OverIPv4¡¢TCP¡¢UDP¡¢ARP¡¢DHCP¡¢DNS»òÒÔÌ«ÍøÁ´Â·²ã£©ÔÚ´¦Öóͷ£ÍøÂ籨ÎÄ·¢ËÍʱ±£´æȱÏÝ£¬ÆäÖаüÀ¨ËĸöÑÏÖØÎó²î£¬ËüÃǵÄCVE±àºÅ»®·ÖΪCVE-2020-11896¡¢CVE-2020-11898¡¢CVE-2020-11910¡¢CVE-2020-11911¡£CVE-2020-11896£¨CVSSÆÀ·Ö10£©¿Éµ¼ÖÂÔ¶³ÌÖ´ÐдúÂ룬CVE-2020-11897£¨CVSSÆÀ·Ö10£©¿Éµ¼ÖÂÔ½½çдÈ룬CVE-2020-11901£¨CVSSÆÀ·Ö9£©¿Éµ¼ÖÂÔ¶³ÌÖ´ÐдúÂ룬CVE-2020-11898£¨CVSSÆÀ·Ö9.1£©¿Éµ¼ÖÂй¶Ãô¸ÐÐÅÏ¢¡£ÆäËü15¸öRipple20Îó²îµÄÑÏÖØˮƽ¸÷Ò죬CVSSÆÀ·Ö»®·Ö´Ó3.1µ½8.2¡£
ÓÉÓÚÎïÁªÍø×°±¸¹©Ó¦Á´µÄÌØÕ÷£¬Îó²îÓ°ÏìµÄ×°±¸Öڶ࣬ӰÏì¹æÄ£¹ãÇÒÒ»Á¬Ê±¼ä³¤£¬Îó²îÐÞ¸´µÄʵÑé½ÏÄÑÌâ¡£Òò´Ë£¬ÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøADLabµÚһʱ¼ä¶ÔÏà¹ØÎó²î¾ÙÐÐÁËÆÊÎö²¢Ìá³öÁËÌá·À½¨Òé¡£
¶þ¡¢ÐÒéÕ»¼ì²â
ÓÉÓÚ½ÓÄÉTreckÐÒéÕ»µÄ³§¼Ò½Ï¶à£¬ÓÐЩ³§¼ÒÊÇÓ²¼þIPºËµÄ·½·¨ÒýÓÃÁËTreckÐÒéÕ»¡£´¿´âͨ¹ý×°±¸Ö¸ÎÆÀ´Ê¶±ðÎó²îÊÇȱ·¦µÄ£¬ÔõÑù¼ì²âÄ¿µÄ×°±¸ÊÇ·ñΪTreckÐÒéÕ»³ÉΪ×ʲúÅŲéµÄÒªº¦£¬Îª´ËÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøADLabÇå¾²Ñо¿Ô±¶ÔTreckÐÒéÕ»¾ÙÐÐÁËÉîÈëÆÊÎö£¬²¢¹ûÕæÁËTreckÐÒéÕ»Ö¸ÎƼì²âÒªÁì·¢Ã÷Îó²î¡£
TreckÐÒéÕ»×Ô½ç˵ÁËÀàÐÍΪ165(0xa5)µÄICMP°ü£¬²¢Ò»µ©ÊÕµ½165µÄICMP°ü»á»Ø¸´ÀàÐÍΪ166µÄICMP°üÏìÓ¦¡£ÈçÏ´úÂëËùʾ£º
Ê×ÏÈ£¬ÏòÄ¿µÄ·¢ËÍ ICMPÇëÇó°ü£¬ÆäÖÐtype=0xa5£¬code=0¡£ÈçÏÂͼËùʾ£º
È»ºó£¬ÎüÊÕÄ¿µÄ·µ»ØµÄicmpÏìÓ¦°üÊý¾Ý£¬ÆäÖÐtype =0xa6,code =0£¬ICMP±¨ÎĵÚ9×Ö½ÚºóµÄÁù¸ö×Ö½ÚΪ0x01,0x51,0x35,0x28,0x57,0x32(´ó¶Ë)»ò0x51,0x01,0x28,0x35,0x32,0x57(С¶Ë£©¡£
Öª×ãÉÏÊöµÄÌõ¼þ£¬ÔòÅúעĿµÄ×°±¸Îªtreck ÐÒéÕ»¡£ÈçÏÂͼËùʾ£º
Èý¡¢Ìá·À½¨Òé
1¡¢Ó¦ÓøüÐÂ
ʵʱ¸üе½Treck TCP/IPÐÒéÕ»Èí¼þµÄ×îÐÂÎȹ̰汾£¨6.0.1.67»ò¸ü¸ß°æ±¾£©¡£
2. ×èÖ¹Òì³£IPÁ÷Á¿
¿ÉÒÔͨ¹ýÉî¶ÈÊý¾Ý°ü¼ì²éÀ´×èÖ¹ÍøÂç¹¥»÷£¬ÒÔÏÂÊÇ¿ÉÒÔÊʵ±Ó¦ÓÃÓÚÍøÂçÇéÐÎÖеĿÉÄÜ»º½â²½·¥£¬¹ýÂËÑ¡Ïî°üÀ¨£º
¡ñ ÈôÊÇÍøÂçÇéÐβ»Ö§³Ö£¬Ôò¹æ·¶»¯»ò¾Ü¾øIP·ÖƬµÄÊý¾Ý°ü£¨IP·ÖƬ£©
¡ñ ÈôÊDz»ÐèÒª£¬Çë½ûÓûò×èÖ¹IPËíµÀ£¨IPv6-in-IPv4»òIP-in-IPËíµÀ£©
¡ñ ×èÖ¹IPԴ·ÓɺÍËùÓв»ÔÞ³ÉʹÓÃIPv6µÄ¹¦Ð§£¬ÀýÈç·ÓɱêÍ·
¡ñ Ç¿ÖÆÖ´ÐÐTCP¼ì²é²¢¾Ü¾øÃûÌùýʧµÄTCPÊý¾Ý°ü
¡ñ ×èֹδʹÓõÄICMP¿ØÖÆÐÂÎÅ£¬ÀýÈçMTU¸üк͵صãÑÚÂë¸üÐÂ
¡ñ ͨ¹ýÇå¾²µÄµÝ¹é·þÎñÆ÷»òÓ¦Óòã·À»ðǽ¹æ·¶DNS
¡ñ È·±£ÍøÂçÇéÐÎÖÐʹÓõÄÊÇ¿É¿¿µÄOSIµÚ2²ã×°±¸£¨ÒÔÌ«Íø£©
¡ñ ͨ¹ýDHCPÕìÌýµÈ¹¦Ð§ÌṩDHCP / DHCPv6Çå¾²ÐÔ
¡ñ ÈôÊÇδÔÚ½»Á÷»ù´¡¼Ü¹¹ÖÐʹÓã¬Ôò½ûÓûò×èÖ¹IPv6¶à²¥¡£
ËÄ¡¢Ïà¹Ø¿´·¨ÏÈÈÝ
1¡¢IP·ÖƬ
IP·ÖƬʹµÃÔÚÍøÂçÖз¢ËÍ´óµÄIP°ü³ÉΪ¿ÉÄÜ£¬×ÝÈ»Æä¾Þϸ´óÓÚÍøÂçÌض¨Á´Â·ÖÐÔÊÐíµÄ×î´óÖµ¡£IP·ÖƬÊÖÒÕÊÇÒ»ÖÖ½«Êý¾Ý°ü·Ö³É¼¸¸ö½ÏСµÄ²¿·ÖÒÔÖ§³Öͨ¹ýÕâЩÁ´Â·ºÍÍøÂç´«ÊäµÄÊÖÒÕ¡£¸ÃÐÒéÖ§³ÖÔÚ·¢ËͶ˾ÙÐзÖƬ£¬È»ºóÔÚÎüÊն˶ԷÖƬÖØÐÂ×éºÏ¡£ÕâÔÊÐí²î±ðµÄ°üÔÚÍøÂçÖÐÁãÐǵش«Ê䣬²¢ÔÚÁíÒ»²à׼ȷµØÖØÐÂ×é×°¡£
²î±ðµÄ°üʹÓÃIPÍ·Öеıêʶ×ֶΣ¨Identification£©¾ÙÐзÖ×é¡£´Ë±êʶ×Ö¶ÎÐÎò·ÖƬÊôÓÚÄĸö°ü¡£Í³Ò»¸ö°üµÄ¶à¸ö·ÖƬµÄIdentificationÊÇÒ»ÑùµÄ¡£IPv4ͨ¹ýFlags¼°Fragment Offset×ֶζԷÖƬ¾ÙÐÐÖÎÀí£¬FlagsÓÉR¡¢DF¡¢MFÈý²¿·Ö×é³É£º
¡ñ R£¨Reserve bit£©±£´æδÓÃ
¡ñ DF (Don't Fragment) DF =1£ºÕ¥È¡·ÖƬ , DF =0£ºÔÊÐí·ÖƬ
¡ñ MF (More Fragment) MF =1£º·Ç×îºóһƬ, MF =0£º×îºóһƬ(»òδ·ÖƬ)
Fragment Offset(13λ)£ºÒ»¸öIP·Ö×é·ÖƬ·â×°ÔIP·Ö×éÊý¾ÝµÄÏà¶ÔÆ«ÒÆÁ¿, ƬƫÒÆ×Ö¶ÎÒÔ8×Ö½ÚΪµ¥Î»¡£IP°ü½á¹¹ÈçÏÂͼËùʾ£º
2¡¢IPËíµÀÊÖÒÕ
IPËíµÀÔÊÐíÁ½¸ö×ÔÁ¦ÍøÂçÖ®¼äµÄÐéÄâµãµ½µãÁ´Â·¡£ËüÊÇͨ¹ý½«°ü£¨¿ÉÒÔÊÇIP°ü£©·â×°ÔÚÁíÒ»¸ö°üÖÐÀ´ÊµÏֵģ¬Ê¹µÃÄÚ²¿°ü¾ßÓÐÓëÍⲿ°ü²î±ðµÄÔ´µØµãºÍÄ¿µÄµØµã¡£Íⲿ°üµÄÔ´µØµãºÍÄ¿µÄµØµãÊÇËíµÀ¶Ëµã£¬ÄÚ²¿°üÖеĵصãÓÃÓÚËíµÀÁ½Í·µÄÍøÂç·ÓÉ¡£ËíµÀÈë¿ÚµãÊÇÎüÊÕӦͨ¹ýËíµÀת·¢µÄIPÊý¾Ý°üµÄ½Úµã¡£Ëü½«´ËÊý¾Ý°ü·â×°ÔÚÍⲿIPÊý¾Ý°üÖС£µ±Êý¾Ý°üµÖ´ïËíµÀ³ö¿Úµãʱ£¬Ëü±»½â·â×°²¢×ª·¢£¬¾ÍËƺõËüÊÇÔÚÄ¿µÄÍøÂçÖз¢Ë͵ÄͨÀýÊý¾Ý°üÒ»Ñù¡£IP-in-IP°üÈçÏÂͼËùʾ£º
IPËíµÀÊÖÒÕÖ÷ÒªÓ¦ÓÃÔÚÐéÄâרÓÃÍø£¨VPN£©ÊÖÒÕÖС£ÏÖÔÚÓм¸ÖÖËíµÀÐÒ飬ÆäÖÐ×î¼òÆÓºÍ×î¹ÅÀϵÄÊÇIP-in-IP£¨IPÐÒé±àºÅ4£©¡£IP-in-IPÊÇÒ»ÖÖIPËíµÀÐÒ飬ÆäÖÐÒ»¸öIP°üͨ¹ýÌí¼ÓÒ»¸öÍⲿIP±¨Í·£¨ÆäÔ´µØµãºÍÄ¿µÄµØµã»®·Ö¼´ÊÇËíµÀµÄÈë¿ÚµãºÍ³ö¿Úµã£©·â×°ÔÚÁíÒ»¸öIP°üÖС£ÄÚ²¿Êý¾Ý°üδ±»Ð޸ģ¬ÍⲿIPÍ·´ÓÄÚ²¿IPÍ·¸´ÖÆһЩ×ֶΡ£Íⲿ±¨Í·µÄIPÐÒéºÅΪ4¡£IP-in-IP±¨ÎÄʾÀýÈçÏÂͼËùʾ£º
Îå¡¢TreckÐÒéÕ»
1¡¢ÐÒéÕ»¸ÅÊö
TreckÐÒéջͨ¹ýtsPacket½á¹¹À´ÐÎò°ü½á¹¹£¬Í¨¹ýtsUserPacket½á¹¹Ö§³ÖÊý¾Ý°ü·ÖƬ¡£ÕâÁ½¸ö½á¹¹ÌåÔÚtreck/include/trsocket.hÎļþÖнç˵¡£Treck TCP/IPÐÒéÕ»ÖеİüÊý¾ÝÓÉtsPacketµÄ½á¹¹ÌåÏÖ¡£Ã¿¸ö°ü¶¼ÓëÒ»¸öÊý¾Ý»º³åÇøÏà¹ØÁª£¬¸ÃÊý¾Ý»º³åÇøÉúÑÄ´Ó½Ó¿ÚÇý¶¯³ÌÐòµÖ´ïµÄÔʼÊý¾Ý¡£tsPacket½á¹¹»¹ÉúÑÄÁíÒ»¸ö³ÆΪttUserPacketµÄÖ÷Òª½á¹¹£¬ÒÔ¼°Ö¸ÏòtsSharedData½á¹¹µÄÖ¸Õ룬¸Ã½á¹¹°üÀ¨ÍøÂçÐÒéÕ»´¦Öóͷ£Êý¾Ý°üʱËùÐèµÄÐÅÏ¢£¨Ö¸ÏòÌ×½Ó×ֽṹ¡¢src/dstµØµã»ò¶Ë¿ÚµÈµÄÖ¸Õ룩¡£½ç˵ÈçÏ£º
struct tsPacket {
ttUserPacket pktUserStruct;
ttSharedDataPtr pktSharedDataPtr;
struct tsPacket * pktChainNextPtr;
struct tsDeviceEntry * pktDeviceEntryPtr;
union anon_union_for_pktPtrUnion pktPtrUnion;
tt32Bit pktTcpXmitTime;
tt16Bit pktUserFlags;
tt16Bit pktFlags;
tt16Bit pktFlags2;
tt16Bit pktMhomeIndex;
tt8Bit pktTunnelCount;
tt8Bit pktIpHdrLen;
tt8Bit pktNetworkLayer;
tt8Bit pktFiller[1];
};
ÕâÊÇ°üÀ¨µÄttUserPacket½á¹¹£¨tsUserPacketµÄtypedef£©£¬½ç˵ÈçÏ£º
struct tsUserPacket {
void * pktuLinkNextPtr; // Next tsUserPacket for fragmented data
ttUser8BitPtr pktuLinkDataPtr;
ttPktLen pktuLinkDataLength;
ttPktLen pktuChainDataLength;
int pktuLinkExtraCount;
};
pktuLinkNextPtr £ºÓÃÓÚ¸ú×ÙÊý¾Ý°üÖеķÖƬ¡£´Ë×Ö¶ÎÖ¸ÏòÌåÏÖÏÂÒ»¸ö·ÖƬµÄÁíÒ»¸ötsPacket½á¹¹£¬¸ÃtsPacket»¹ÉúÑĶÔÏÂÒ»¸ö·ÖƬµÄÒýÓã¬ÈôÊÇ´ËÁ´½ÓÊÇ×îºóÒ»¸ö·ÖƬ£¬»òÕßÊý¾Ýδ±»·ÖƬ£¬Ôò´Ë×ֶν«ÎªNULL¡£
pktuLinkDataPtr£ºÖ¸ÏòÄ¿½ñ·ÖƬµÄÊý¾Ý»º³åÇø¡£µ±TreckÐÒéÕ»ÔÚ²î±ð½×¶Î´¦Öóͷ£Êý¾Ý°üʱ£¬Êý¾Ý»º³åÇøÖмòÖ±ÇÐλÖûᱬ·¢×ª±ä£¬ÕâÈ¡¾öÓÚÄ¿½ñÕýÔÚ´¦Öóͷ£µÄÊý¾Ý°üËùÔÚÐÒé²ã¡£ÀýÈ磬µ±TreckÐÒéÕ»´¦Öóͷ£ÒÔÌ«Íø²ã£¨ÔÚtfEtherRecv()º¯ÊýÖУ©Ê±£¬´Ë×Ö¶ÎÖ¸ÏòÒÔÌ«Íø±¨Í·¡£
pktuLinkDataLength£ºpktuLinkDataPtrÖ¸ÏòµÄÊý¾ÝµÄ¾Þϸ£¬¼´µ¥¸ö·ÖƬµÄ¾Þϸ¡£
pktuChainDataLength£ºÌåÏÖ°üÀ¨ËùÓзÖƬµÄÊý¾Ý°ü³¤¶È£¬¼´Êý¾Ý°üµÄ×ܾÞϸ¡£ËüֻΪµÚÒ»¸ö·ÖƬÉèÖá£ÈôÊÇÊý¾ÝûÓзÖƬ£¬Ôò¼´ÊÇpktuLinkDataLength¡£
2¡¢ÐÒéÕ»´¦Öóͷ£Àú³Ì
ÐÒéÕ»ÖеÄÒ»¸ö³£¼ûģʽÊÇÔÚÐÒéÕ»ÖеIJãÖ®¼äÒƶ¯Ê±µ÷½âpktuLinkDataPtrÖ¸Õë¡£ÀýÈ磬ÈôÊÇÎÒÃǵİüÊÇÒ»¸öICMP»ØÏÔÇëÇó°ü£¨ping£©£¬ËüµÄÐÒéÓÉÈý²ã×é³É£ºEthernet¡¢IPv4¡¢ICMP¡£ÔÚÕâÖÖÇéÐÎÏ£¬µ±´¦Öóͷ£ÒÔÌ«Íø²ã£¨ÔÚtfEtherRecv()º¯ÊýÖУ©Ê±£¬pktuLinkDataPtrÖ¸ÏòÒÔÌ«Íø±¨Í·µÄ×îÏÈ£¬È»ºóÔÚÒƶ¯µ½ÏÂÒ»²ã֮ǰ£¬Ê¹ÓÃÒÔÏ´úÂë¶ÔÆä¾ÙÐе÷½â£¬ÈçÏ´úÂëËùʾ£º
ÔÚ±¾ÀýÖУ¬0xe£¨Ê®½øÖÆΪ14£©ÊÇÒÔÌ«Íø±¨Í·£¨6£¨dst MAC£©+6£¨src MAC£©+2£¨etherType£©£©µÄ¾Þϸ¡£µ±tfEtherRecv()º¯ÊýÍê³É°ü´¦Öóͷ£Ê±£¬Ëü½«°üת·¢µ½ÏÂÒ»²ã´¦Öóͷ£¡£Ö§³ÖµÄÒÔÌ«ÍøÀàÐÍÓÐARP¡¢IPv4ºÍIPv6¡£ÈçÏ´úÂëËùʾ£º
ÔÚʾÀýÖУ¬µ±IPv4²ãÎüÊÕµ½Êý¾Ý°ü£¨ÔÚº¯ÊýtfIpIncomingPacket()º¯ÊýÖУ©Ê±£¬Ö¸ÕëpktuLinkDataPtrÒѾָÏòIP±¨Í·¡£´«ÈëÊý¾ÝÓɾßÓÐÏàͬÃüÃûÔ¼¶¨tf*IncomingPacketµÄº¯Êý´¦Öóͷ££¬ÆäÖÐ*ÊÇÐÒéÃû¡£¹ØÓÚICMP°üÀ´Ëµ£¬ËüÓÉÈý²ãÐÒé×é³É£¨Ethernet/IPv4/ICMP£©£¬Êý¾Ý°ü½«Óɺ¯ÊýtfEtherRecv¡¢tfIpIncomingPacketºÍtfIcmpIncomingPacketº¯Êý»®·Ö´¦Öóͷ£¡£
3¡¢·ÖƬÖØ×é
TreckÐÒéÕ»ÔÚtfIpReassemblePacket()º¯ÊýÖд¦Öóͷ£·ÖƬµÄÖØ×飬¸Ãº¯ÊýÓÉtfIpIncomingPacket()ŲÓá£Ã¿µ±ÎüÊÕµ½·¢Íù×°±¸µÄIP·ÖƬʱ£¬¾Í»áŲÓô˺¯Êý¡£ÈôÊÇȱÉÙ·ÖƬ£¬º¯Êý½«·µ»ØNULL¡£²»È»£¬ÈôÊÇËùÓзÖƬ¶¼µÖ´ï²¢ÇÒûÓÐÆÓª£¬ÔòÍøÂçÐÒéÕ»½«Ê¹ÓÃpktuLinkNextPtr×ֶν«·ÖƬÁ´½ÓÔÚÒ»Æð£¬È»ºó½«Êý¾Ý°üת´ï¸øÏÂÒ»²ã¾ÙÐнøÒ»²½´¦Öóͷ£¡£ÔÚ´ËÉÏÏÂÎÄÖУ¬¡°ÖØ×顱һ´Ê²¢²»ÁÏζ׎«Êý¾Ý°ü¸´ÖƵ½Ò»Á¬µÄ´æ´¢¿é£¬¶øÖ»ÊǼòÆӵؽ«ËüÃÇÁ´½Óµ½Ò»¸öÁ´±íÖС£·ÖƬÊý¾ÝÁ´±í½á¹¹ÈçÏÂͼËùʾ£º
4¡¢tfIpIncomingPacketº¯Êý
tfIpIncomingPacket()º¯ÊýÊÇ´¦Öóͷ£IP°üµÄÖ÷Òªº¯Êý£¬¸Ãº¯ÊýÖ÷ÒªÁ÷³ÌÈçÏÂͼËùʾ£º
tfIpIncomingPacket()Ê×ÏÈÅжÏÊý¾Ý°üÕýµ±ÐÔ¡£tfIpIncomingPacket()º¯Êý³ýÁËÑéÖ¤IPͷУÑéºÍ£¬Ëü»¹¾ÙÐÐÒÔÏÂÑéÖ¤£¬ÈçÏ´úÂëËùʾ£º
È»ºóÈôÊÇËùÓÐÕýµ±ÐÔ¼ì²é¶¼Í¨¹ý£¬tfIpIncomingPacket()º¯Êý½«¼ì²éIP±¨Í·ÖÐTotalLength ÊÇ·ñÑÏ¿áСÓÚÊý¾Ý°üµÄpktuChainDataLength£¬ÕâÌåÏÖÏÖʵÎüÊÕµÄÊý¾Ý±ÈIP±¨Í·ÖÐÉùÃ÷µÄÊý¾Ý¶à¡£ÈôÊÇÊÇÕæµÄ£¬Ôò¾ÙÐÐÐÞ¼ô²Ù×÷£¬ÒªÉ¾³ýÌØÁíÍâÊý¾Ý£¬ÈçÏ´úÂëËùʾ£º
ÔÙÕßÈôÊÇIPÊý¾Ý°üµÄMFΪ1»òÕßFragment Offset´óÓÚ0£¬ÔòtfIpIncomingPacket()º¯Êý¾ÍҪŲÓÃtfIpReassemblePacket()º¯Êý¾ÙÐзÖƬÖØ×é¡£ÈôÊÇIP·ÖƬÊý¾ÝÎüÊÕ²»ÍêÕû£¬ÔòtfIpReassemblePacket()º¯Êý·µ»ØNULL¡£ÈôÊÇËùÓÐIP·ÖƬ¶¼µÖ´ï²¢ÇÒûÓйýʧ£¬ÔòTreckÐÒéջʹÓÃpktuLinkNextPtr×ֶν«ÕâЩ·ÖƬÁ´½ÓÔÚÒ»Æ𣬽¨ÉèÁ´±í£¬²¢½«°üת´ïµ½ÏÂÒ»²ã¾ÙÐнøÒ»²½´¦Öóͷ££¬ÈçÏ´úÂëËùʾ£º
×îºóÈôÊÇÒѾÊÕµ½ÍêÕûµÄIPÊý¾Ý°ü£¬ÔòtfIpIncomingPacket()º¯Êýƾ֤IPÊý¾Ý°üÖеÄÐÒé×ֶεÄÐÒéºÅ£¬Å²ÓÃÏìÓ¦µÄÐÒé°ü´¦Öóͷ£º¯Êý¾ÙÐд¦Öóͷ£¡£ÔÚÏÂÁдúÂëÖУ¬µ±ÐÒéºÅΪUDPʱ£¬ÔòŲÓÃtfUdpIncomingPacket()º¯Êý£¬µ±Êý¾Ý°üÐÒéΪIP-in-IPÐÒ飨ÐÒéºÅ4£©Ê±£¬»áµÝ¹éŲÓÃtfIpIncomingPacket()º¯Êý£¬´úÂëʵÏÖÈçÏÂËùʾ£º
Áù¡¢Îó²îÔÀíÆÊÎö
1¡¢CVE-2020-11896
Ç°ÎÄÒѾÏÈÈÝtfIpIncomingPacket()º¯ÊýµÄʵÏÖÀú³Ì£¬µÚ¶þ²½µÄÊý¾Ý²Ã¼ôÊÇÎó²îµÄÔµ¹ÊÔÓÉ£¬ÈçÏ´úÂëËùʾ£º
pktuLinkDataLength±£´æÄ¿½ñ·ÖƬµÄ¾Þϸ£¬pktuChainDataLength±£´æÕû¸öIPÊý¾Ý°üµÄ¾Þϸ¡£ÈôÊÇÖ´ÐÐÉÏÊö²Ù×÷£¬½«µ¼ÖÂÒ»¸ö·×ÆçÖÂÐÔµÄ״̬£¬ÆäÖÐpkt->pktuChainDataLength==pkt->pktuLinkDataLength£¬µ«¿ÉÄÜÓÐpkt->pktuLinkNextPtrÖ¸ÏòÆäËû·ÖƬ¡£¸ü½øÒ»²½µÄÆäÖÐÁ´±íÉÏ·ÖƬµÄ×ÜÊý¾Ý¾Þϸ¿ÉÄÜ´óÓÚ´æ´¢ÔÚpktuChainDataLength±äÁ¿ÖеľÞϸ¡£ÕâÖÖ²Ù×÷µ¼Öµķ×ÆçÖÂÐÔ½«»áµ¼ÖºóÐø±¨ÎÄ´¦Öóͷ£±¬·¢Òì³£¡£
ͨ¹ý¼òÆÓµØÉèÖùýʧµÄIP°ü·ÖƬÊÇÎÞ·¨´¥·¢Îó²îµÄ£¬ÓÉÓڲüôʺóµÄ·ÖƬÊý¾ÝÔÚºóÐøµÄtfIpReassemblePacket()º¯Êý²Ù×÷Öлáƾ֤pktuChainDataLengthµÄ¾Þϸ£¬ÖØн¨Éè·ÖƬÁ´±í£¬²»»áÔì³É·×ÆçÖµÄ״̬¡£ÀíÏëµÄÁ÷³ÌÊÇÏÈÍêÒòËØƬÁ´±íµÄ½¨É裬ÔÙ¾ÙÐÐÁ´±íÊý¾Ý×ܾÞϸµÄ²Ã¼ôÁ÷³Ì£¬ÕâÑù¾Í»á½øÈë·×ÆçÖµÄ״̬¡£
ΪÁËÔÚIP²ã´¦Öóͷ£·ÖƬÊý¾Ý°ü²¢´¥·¢Ö´ÐÐÓÐÎÊÌâµÄÁ÷³Ì´úÂ룬¿ÉÒÔʹÓÃIP-in-IPÊý¾Ý°ü¡£¹ØÓÚ·ÖƬµÄIP-in-IPÊý¾Ý°ü£¬tfIpIncomingPacket()º¯Êý½«ÖÁÉٵݹéŲÓÃÁ½´Î£¬Ò»´ÎÓÃÓÚIPËíµÀ°üµÄÄÚ²ãIPÊý¾Ý°ü£¬¶à´ÎÓÃÓÚÍâ²ãIPÊý¾Ý°ü£¨Ã¿´¦Öóͷ£Ò»¸öÍâ²ãIP°ü·ÖƬËã×÷Ò»´Î£©¡£
tfIpIncomingPacket()º¯ÊýÔÚ´¦Öóͷ£IPËíµÀÊý¾Ý°üµÄʱ¼ä½«ÄÚ²¿IPÊý¾Ý°ü×÷Ϊ·Ç·ÖƬÊý¾Ý°ü¾ÙÐд¦Öóͷ£¡£ÄÚ²¿Êý¾Ý°üÏÖÔÚÓɶà¸ö·ÖƬ×é³É£¬µ«ÔÚIP±¨Í·Öбê¼ÇΪ·Ç·ÖƬ£¨MF=0£©£¬ÒÔÊÇËü²»»áÔÙ½øÈëtfIpReassemblePacket()º¯Êý¾ÙÐÐÖØ×é¡£ËüÏÖÔÚÓÉÒ»¸öÁ´±íÖеļ¸¸öµ¥¶ÀµÄtsPacketÁ´½Ó×é³É£¬Ã¿¸öÁ´½Ó¶¼ÓÐÒ»¸öµ¥¶ÀµÄpktuLinkDataLengthÖµ¡£Ë¼Á¿ÏÂÃæµÄÀý×Ó£¬Ëü½«ÓÐÖúÓÚÃ÷È·Îó²îµÄ³ÉÒò£º
¡ñ Inner IP packet: IPv4{len=32, proto=17}/UDP{checksum=0, len=12}£¬ÆäÖаüÀ¨1000×Ö½ÚµÄÊý¾Ý¡¯A¡¯¡£
¡ñ Outer IP packet (fragment 1): IPv4{frag offset=0, MF=1, proto=4, id=0xabcd} ,ÆäÖаüÀ¨40×Ö½ÚµÄIPÊý¾Ý¡£
¡ñ Outer IP packet (fragment 2): IPv4{frag offset=40, MF=0, proto=4, id=0xabcd} £¬ÆäÖÐÊý¾Ý¸ººÉΪ988×Ö½Ú¡£
ΪÁËÈƹýUDPУÑ飬½«Ð£ÑéºÍ×Ö¶ÎchecksumÉèÖÃΪ0¡£ÊµÀýÖеķÖƬ½á¹¹ÈçÏÂͼËùʾ£º
µ±TreckÐÒéÕ»´¦Öóͷ£Íⲿ·ÖƬʱ£¬ËüʹÓÃtsUserPacket½á¹¹ÖеÄpktuLinkNextPtr×Ö¶ÎÀ´Á´½ÓËüÃÇ¡£ÈçÇ°ËùÊö£¬µ±tfIpIncomingPacket()º¯Êý´¦Öóͷ£ÄÚ²¿IPÊý¾Ý°ü£¨ÐÒéΪ4£¬IP-in-IP£©Ê±£¬ËüÒѾÍê³ÉÁË·ÖƬÊý¾ÝµÄÖØ×飨ÄÚ²¿IPÊý¾Ý°üÓÉÁ´½ÓÔÚÒ»ÆðµÄÁ½¸ötsPacket½á¹¹ÌåÏÖ£©¡£·ÖƬÊý¾ÝÖØ×éºóµÄÁ´±í½á¹¹ÈçÏÂͼËùʾ£º
ÓÉÓÚtfIpIncomingPacket()º¯ÊýÔÚ¾ÙÐÐÓÐÓÃÐÔÅжÏʱ£¬Ö»Ë¼Á¿tsUserPacketÖеÄpktuChainDataLength×ֶΣ¨¶ø²»ÊÇpktuLinkDataLength£©£¬ÒÔÊÇÔÚ´¦Öóͷ£ÄÚ²¿IP°üʱ½«½øÈë¹ýʧµÄÁ´±í³¤¶ÈµÄ²Ã¼ôÁ÷³Ì£¬´Ó¶øµ¼ÖÂÁËÎÊÌâ¡£
ÄÚ²¿IP°üͨ¹ýÁËIPÍ·ÍêÕûÐÔ¼ì²é£¬ÔÚ¸ÃÀý×ÓÖУ¬ÄÚ²¿IP°üµÄ×ܳ¤¶È(32£©Ð¡ÓÚÁ´±íÊý¾Ý³¤¶È£¨1000+8+20=1028£©£¬Òò´ËTreckÐÒéÕ»½«ÊµÑé¹ýʧµØÐÞ¼ôÊý¾Ý°ü£¬ÒªÁìÊǽ«×Ö¶ÎpktuLinkDataLengthºÍpktuChainDataLengthÉèÖÃΪÏàͬµÄÖµipTotalLength£¨ÔÚÎÒÃǵÄʾÀýÖÐΪ32£©¡£Õâµ¼ÖÂÄÚ²¿IPÊý¾Ý°üÓÉÁ´½ÓÔÚÒ»ÆðµÄÁ½¸ötsPacket½á¹¹ÌåÏÖ£¬µ«ËüÃǵÄÊý¾Ý×ܳ¤¶È´óÓÚpktuChainDataLength×ֶΣ¨ÐÞ¼ôºópktuChainDataLength×ֶβ»ÊÇ1028×Ö½Ú£¬¶øÊǼ´ÊÇ32£©¡£¾ÓÉÊý¾Ý³¤¶È²Ã¼ôºóµÄÁ´±í½á¹¹ÈçÏÂͼËùʾ£º
ÏÖÔÚÒѾʹµÃÁ´±íµÖ´ïÁË·×ÆçÖµÄ״̬£¬ÏÂÃ潫ÏÈÈÝÔõÑùʹÓÃÕâÖÖ·×ÆçÖµÄ״̬À´µ¼ÖÂÄÚ´æÆÆËð¡£
ÔÚTreckÐÒéÕ»´úÂëÖÐÖÁÉÙÓÐÒ»¸ö´úÂë·¾¶¿ÉÒÔ½«·ÖƬÊý¾Ý¸´ÖƵ½µ¥¸öÒ»Á¬»º³åÇøÖС£ÏêϸµÄÖ´Ðз¾¶Îª£º
tfUdpIncomingPacket() -> tfSocketIncomingPacket() -> tfCopyPacket()¡£ÏÂÃæµÄ´úÂëÊÇtfSocketIncomingPacket()º¯Êý´¦Öóͷ£UDPÊý¾Ý±¨µÄ´úÂëµÄÒ»²¿·Ö£¬ÈçÏ´úÂëËùʾ£º
Õâ¶Î´úÂëÖÐtfSocketIncomingPacket()º¯ÊýŲÓÃtfGetSharedBuffer()ÉêÇëÄڴ棬Æä¾Þϸ»ùÓÚpktuChainDataLength×ֶεÄÖµ£¬È»ºóͨ¹ýtfCopyPacket()º¯Êý½«Êý¾Ý°üµÄ²î±ð·ÖƬÖð¸ö¸´ÖƵ½Ð·ÖÅɵÄÄÚ´æ¿Õ¼äÖУ¬±¬·¢Òç³öµÄ´úÂëÈçÏÂËùʾ£º
ÓÉÓÚÁ½¸ö·ÖƬÖеÄpktuLinkDataLengthÖ®ºÍΪ1000×Ö½Ú£¬ºóÐøµÄtfCopyPacketº¯Êý½«»á°Ñ1000×Ö½ÚµÄÊý¾Ý¿½±´µ½Õâ¶ÎÄÚ´æÖУ¬Õ⽫µ¼Ö¶ÑÒç³ö¡£
2¡¢CVE-2020-11898
ÕýÈçÇ°ÎÄÐÎòÔõÑù´¥·¢CVE-2020-11896Îó²îÄÇÑù£¬Treck TCP/IPÐÒéÕ»ÎÞ·¨×¼È·´¦Öóͷ£Í¨¹ýIP-in-IPËíµÀ´«ÈëµÄIPv4·ÖƬ¡£ÕâÒ²¿ÉÄÜÔÊÐíδ¾Éí·ÝÑéÖ¤µÄ¹¥»÷Õß´Ó¶ÑÖÐ×ß©ÄÚ´æ¡£¿ÉÒÔ½ÓÄÉÒÔÏÂʾÀý¾ÙÐÐÎó²î´¥·¢£º
¡ñ ÄÚ²¿IPÊý¾Ý°ü£ºIPv4 {ihl = 0xf£¬len = 100£¬proto = 0}£¬ÓÐÓÃÔغÉΪ'\ x00'* 40 +'\ x41'* 100¡£
¡ñ ÍⲿIPÊý¾Ý°ü£¨·ÖƬ1£©£ºIPv4 {frag offset = 0£¬MF = 1£¬proto = 4£¬id = 0xabcd}£¬ÆäÖÐ24¸ö×Ö½ÚÀ´×ÔÄÚ²¿IPÊý¾Ý°üÓÐÓøºÔØ¡£ÕâÒâζ׎«¸´ÖÆ20¸ö×Ö½ÚµÄIP±êÍ·£¬Íâ¼Ó4¸ö¿Õ×Ö½Ú¡£
¡ñ ÍⲿIPÊý¾Ý°ü£¨·ÖƬ2£©£ºIPv4 {frag offset = 24£¬MF = 0£¬proto = 4£¬id = 0xabcd}£¬À´×ÔÄÚ²¿IPÊý¾Ý°üµÄÆäÓà×Ö½Ú×÷ΪÓÐÓøºÔØ¡£
ʵÀýÖеķÖƬ½á¹¹ÈçÏÂͼËùʾ£º
ÕâÀïihlΪ0xf£¬ÌåÏÖΪ×î´óIPÑ¡Ï³¤¶ÈΪ60×Ö½Ú£¬Êý¾Ý°ü×ܳ¤¶Ètotal_lengthΪ100¡£µ±ÍøÂçÐÒéÕ»ÊÕµ½Á½¸ö·ÖƬʱ£¬Ëü½«Ê¹ÓÃtfIpReassemblePacket()º¯ÊýÖØÐÂ×é×°ËüÃÇ¡£·ÖƬÊý¾ÝÖØ×éºóµÄÁ´±í½á¹¹ÈçÏÂͼËùʾ£º
¸ÃtfIpReassemblePacket()º¯ÊýʹÓÃtsUserPacket½á¹¹ÖеÄ×Ö¶ÎpktuLinkNextPtrÁ´½ÓÁ½¸ö·ÖƬ¡£ÈôÊÇÆôÓÃÁËIP-in-IPËíµÀ´«Ê䣬ÔòÄÚ²¿IPÊý¾Ý°ü½«ËæºóÓÉtfIpIncomingPacket()º¯ÊýÖд¦Öóͷ££¬ÐÞ¼ôºóµÄpktuChainDataLength×ֶβ»ÊÇ160£¬¶øÊǼ´ÊÇ100¡£¾ÓÉÊý¾Ý³¤¶È²Ã¼ôºóµÄÁ´±í½á¹¹ÈçÏÂͼËùʾ£º
ÄÚ²¿IPÊý¾Ý°üͨ¹ýIP±êÍ·ÍêÕûÐÔ¼ì²é£¬ÓÉÓÚ½ö˼Á¿ÁËtsUserPacketµÄpktuChainDataLength×ֶΣ¨¶ø²»Ë¼Á¿pktuLinkDataLength£©¡£ÓÉÓÚÔÚ±ê×¼IPÍ·²¿£¨20¸ö×Ö½Ú£©Ö®ºóÓÐ4¸ö¿Õ×Ö½Ú£¬²¢ÇÒÒ»¸ö¿Õ×Ö½Ú´ú±íIPÑ¡ÏîµÄĩ⣬IPÑ¡ÏîÆÊÎöͨ¹ý¼ì²é¡£ÓÉÓÚÄÚ²¿IPÊý¾Ý°ü°üÀ¨ÎÞЧµÄIPv4ÐÒé±àºÅ£¨ProtocolΪ0£©£¬½øÈëdefault·ÖÖ§£¬È»ºóÖ±½Ó½øÈëTM_IP_LOCAL_FLAG·ÖÖ§¡£ÈçÏ´úÂëËùʾ£º
Òò´ËÍøÂçÐÒéÕ»½«Í¨¹ý·¢ËÍÀàÐÍΪ3£¨Ä¿µÄ²»¿É´ï£©ºÍ´úÂëΪ2£¨ÐÒé²»¿É´ï£©µÄICMP¹ýʧÐÂÎÅÀ´¾Ü¾ø¸ÃÊý¾Ý°ü¡£ÈçÏ´úÂëËùʾ£º
ÈÏÕ潨Éè¹ýʧÊý¾Ý°üµÄÊÇtfIcmpErrPacket()º¯Êý¡£Ëü·ÖÅÉÒ»¸öеÄÊý¾Ý°ü£¬³õʼ»¯Ò»Ð©ICMPÍ·²¿×ֶΡ£ÈçÏ´úÂëËùʾ£º
×îºó´ÓºóÐøÊý¾Ý°ü£¨ÄÚ²¿IPÊý¾Ý°ü£©Öи´ÖÆһЩÊý¾Ý¡£¸´ÖƲ¿·ÖÈçÏ´úÂëËùʾ£º
Èç´úÂëËù¼û£¬tfIcmpErrPacket()º¯Êýͨ¹ý»ñÈ¡IP±¨Í·³¤¶È£¨ÒÔ×Ö½ÚΪµ¥Î»¼ÓÉÏ8£¬ÔÚÏÖÕæÏàÐÎÏÂΪ60 + 8 = 68£©ÓëpktuLinkDataLength×ֶΣ¨ÒÔ¼°±»²Ã¼ôΪ100£©Ö®¼äµÄ×îСֵÀ´ÅÌËãÒª¸´ÖƵÄ×Ö½ÚÊý ¡£ÓÉÓÚ·¢ËÍÊý¾Ý°üµÄµÚÒ»¸ö·ÖƬµÄÏÖʵÁ´Â·Êý¾Ý³¤¶ÈΪ24£¨¶ø²»ÊÇ100£©£¬Òò´ËtfIcmpErrPacket()º¯Êý½«´Ó¶ÑÖи´ÖÆ68-24 = 44×Ö½ÚµÄÌØÊâÊý¾Ý¡£È»ºóÉèÖÃv12_icmpErrPacketÖÐÏà¹ØÊý¾Ý¡£ÈçÏ´úÂëËùʾ£º
×îºóŲÓÃtfIpSendPacket()º¯Êý·¢ËÍicmp_ErrPacket°üµ½Ä¿µÄµØµã£¬Õ⽫µ¼ÖÂ44×Ö½ÚµÄÐÅϢй¶¡£
3¡¢CVE-2020-11910
CVE-2020-11910ÊÇÔ½½ç¶ÁÎó²î£¬¸ÃÎó²î±£´ætfIcmpIncomingPacketº¯ÊýÖУ¬¸Ãº¯ÊýÖ÷ÒªÊÇ´¦Öóͷ£ICMP°ü¡£tfIcmpIncomingPacketº¯ÊýÔÚ´¦Öóͷ£×°±¸ÊÕµ½ÀàÐÍΪ3£¬codeΪ4µÄICMP°üµÄʱ¼ä£¬´úÂ벢ûÓÐÑéÖ¤ºóÐøÊý¾ÝµÄ³¤¶È£¬Ö±½Ó¾Í»á¼ûÁ˶ÔӦλÖõÄÊý¾Ý£¬Ôì³ÉÁËÔ½½ç¶ÁÎó²î¡£ÈçÏ´úÂëËùʾ£º
4¡¢CVE-2020-11911
CVE-2020-11911ÊÇδÊÚȨµÄÃô¸ÐÐÅÏ¢¸üÐÂÎó²î£¬¸ÃÎó²î±£´ætfIcmpIncomingPacketº¯ÊýÖУ¬¸Ãº¯ÊýÖ÷ÒªÊÇ´¦Öóͷ£ICMP°ü¡£tfIcmpIncomingPacketº¯ÊýÔÚ´¦Öóͷ£×°±¸ÊÕµ½ÀàÐÍΪ18£¨Address mask reply£©°üµÄʱ¼ä£¬´úÂ벢ûÓÐÑé֤װ±¸ÊÇ·ñ·¢Ë͹ýÀàÐÍ17£¨Address mask request£©ÇëÇ󣬾ÍÖ±½Ó¸üÐÂÁË×°±¸µÄ×ÓÍøÑÚÂë¡£ÈçÏ´úÂëËùʾ£º
Æß¡¢CVE-2020-11898Îó²îÑéÖ¤
Ô¶³Ì¹¥»÷´òÓ¡»ú£¬ÊÓƵÇ뵽΢ÐŹ«ÖÚºÅÖÐÉó²é£ºÑéÖ¤ÊÓƵ¡£
°Ë¡¢²Î¿¼
1¡¢https://www.ietf.org/rfc/rfc2003.txt
2¡¢https://www.ietf.org/rfc/rfc792.txt
3¡¢https://www.ietf.org/rfc/rfc1853.txt
4¡¢https://www.jsof-tech.com/ripple20/
5¡¢https://kb.cert.org/vuls/id/257161
6¡¢/article/1/11834.html
7¡¢JSOF_Ripple20_Technical_Whitepaper_June20.pdf
ÓÅ·¢¹ú¼ÊÍøÕ¾¹ÙÍøÆð¾¢·ÀÓùʵÑéÊÒ£¨ADLab£©
ADLab½¨ÉèÓÚ1999Ä꣬ÊÇÖйúÇå¾²ÐÐÒµ×îÔ罨ÉèµÄ¹¥·ÀÊÖÒÕÑо¿ÊµÑéÊÒÖ®Ò»£¬Î¢ÈíMAPPÍýÏë½¹µã³ÉÔ±£¬¡°ºÚȸ¹¥»÷¡±¿´·¨Ê×ÍÆÕß¡£×èÖ¹ÏÖÔÚ£¬ADLabÒÑͨ¹ýCVEÀÛ¼ÆÐû²¼Çå¾²Îó²î1000Óà¸ö£¬Í¨¹ý CNVD/CNNVDÀÛ¼ÆÐû²¼Çå¾²Îó²î800Óà¸ö£¬Ò»Á¬¼á³Ö¹ú¼ÊÍøÂçÇå¾²ÁìÓòÒ»Á÷Ë®×¼¡£ÊµÑéÊÒÑо¿Æ«Ïòº¸Ç²Ù×÷ϵͳÓëÓ¦ÓÃϵͳÇå¾²Ñо¿¡¢Òƶ¯ÖÇÄÜÖÕ¶ËÇå¾²Ñо¿¡¢ÎïÁªÍøÖÇÄÜ×°±¸Çå¾²Ñо¿¡¢WebÇå¾²Ñо¿¡¢¹¤¿ØϵͳÇå¾²Ñо¿¡¢ÔÆÇå¾²Ñо¿¡£Ñо¿Ð§¹ûÓ¦ÓÃÓÚ²úÆ·½¹µãÊÖÒÕÑо¿¡¢¹ú¼ÒÖصã¿Æ¼¼ÏîÄ¿¹¥¹Ø¡¢×¨ÒµÇå¾²·þÎñµÈ¡£