DNS緩存投毒攻擊原理與防御策略
N ETWORK & INFORMATION SECURITY網(wǎng)絡(luò)與信息安全DNS緩存投毒攻擊原理與防御策略靳沖1,2,郝志宇1,吳志剛112中國科學(xué)院計算技術(shù)研究所,北京100190中國科學(xué)院研
N ETWORK & INFORMATION SECURITY
網(wǎng)絡(luò)與信息安全
DNS緩存投毒攻擊原理與防御策略
靳沖1,2,郝志宇1,吳志剛1
1
2中國科學(xué)院計算技術(shù)研究所,北京100190中國科學(xué)院研究生院,北京100190
摘 要:DNS是Internet最重要的基礎(chǔ)設(shè)施之一,若遭受攻擊將影響Internet的正常運轉(zhuǎn),因而其安全性備受關(guān)注。本文分析了傳統(tǒng)以及新型(Kaminsky)DNS緩存投毒(Cache Poisoning)攻擊的原理,給出攻擊實例,詳細(xì)描述了攻擊流程,驗證了DNS緩存投毒攻擊潛在的危害性,并提出若干防御策略。
關(guān)鍵詞:DNS;緩存投毒;Kaminsky攻擊
Principles and Defense Strategies of DNS Cache Poisoning
Jin Chong1, 2, Hao Zhiyu1, Wu Zhigang1
1
2Institute of Computing Technology of Chinese Academy of Sciences, Beijing 100190Graduate University of Chinese Academy of Sciences, Beijing 100190
Abstract : DNS is one of the most important basic infrastructures of the Internet, attacks on which will prevent the Internet from working properly. Therefore, its security is receiving great concern. This
paper analyzes the principles of both traditional and novel (Kaminsky) DNS Cache Poisoning, presents attack samples and describes the whole attack process in detail. After verifying the potential harm of DNS Cache Poisoning, the paper gives out several defense strategies.
Key Words: DNS; cache poisoning; Kaminsky attack
I.概述
DNS(Domain Name System)是一個多層次的
分布式數(shù)據(jù)庫系統(tǒng),其基本功能是完成域名解析,
即提供域名和IP 地址之間的映射關(guān)系,為互聯(lián)網(wǎng)
(Internet)用戶提供便利。DNS 是Internet 的基礎(chǔ),
也是目前互聯(lián)網(wǎng)上最成功的應(yīng)用之一,其安全性備受關(guān)注。DNS緩存投毒(DNS Cache Poisoning)是DNS 攻擊中危害較大的一種,也是當(dāng)前DNS 攻擊領(lǐng)域的研究熱點。它通過使用虛假IP 地址信息替換名字服務(wù)器緩存中主機記錄的真實IP 地址信息來制造破壞[6,7]。本文介紹了傳統(tǒng)DNS 緩存投毒攻擊以及新型的Kaminsky 攻擊的基本原理,并提出了可行的防御策略。
2009.11 17
,China Communications
II.傳統(tǒng)DNS緩存投毒攻擊
一臺DNS 服務(wù)器只記錄本地資源的所有授權(quán)主機,若想查詢非本地的主機信息,則要向信息持有者(權(quán)威DNS 服務(wù)器)發(fā)送查詢請求。為了避免每次查詢都發(fā)送請求,DNS服務(wù)器會把權(quán)威DNS 服務(wù)器返回的查詢結(jié)果保存在緩存中,并保持一定時間,這就構(gòu)成了DNS 緩存(DNS Cache)。DNS緩存投毒攻擊就是通過污染DNS Cache,用虛假的IP 地址信息替換Cache 中主機記錄的真實IP 地址信息來制造破壞。
2.1 DNS解析過程
在分析DNS 緩存投毒攻擊原理之前,先闡述一下DNS 解析過程。假設(shè)要查詢的域名為,并假設(shè)客戶端和首選的緩存名字服務(wù)器(即緩存DNS 服務(wù)器)滿足以下條件:
(1)首選緩存名字服務(wù)器和客戶端首次啟動,沒有本地緩存信息。
(2)首選緩存名字服務(wù)器不是目標(biāo)域名的權(quán)威名字服務(wù)器。
查詢過程如圖1所示,步驟如下:
(1)客戶端向首選緩存名字服務(wù)器發(fā)起遞歸查詢的請求。
(2)首選緩存名字服務(wù)器檢查本地資源記錄, 若存在則作授權(quán)回答;若不存在,則檢查本地緩存,
如存在則直接給客戶端返回結(jié)果。若本地資源記錄
和緩存中都不存在,則向根名字服務(wù)器發(fā)起迭代查詢。根據(jù)假設(shè)條件,本例查詢中將向根名字服務(wù)器繼續(xù)查詢。
(3)根名字服務(wù)器返回cn 域的權(quán)威名字服務(wù)器(即頂級域名服務(wù)器)的地址,首選緩存名字服務(wù)器繼續(xù)向頂級域名服務(wù)器發(fā)起迭代查詢。
(4)頂級域名服務(wù)器返回ac.cn 域的權(quán)威名字
服務(wù)器地址,首選緩存名字服務(wù)器繼續(xù)向該地址請求迭代查詢。如此繼續(xù),直到得到的授權(quán)回答,保存在本地緩存中,并返回給客戶端,完成此次查詢。
2.2 DNS報文格式
DNS 定義了用于查詢和應(yīng)答的報文格式,通常采用UDP 協(xié)議傳輸查詢請求和應(yīng)答數(shù)據(jù)包。表1 (a)顯示了DNS 查詢報文格式,表1 (b)顯示了DNS 應(yīng)答報文格式。
表1(a) DNS查詢報文標(biāo)識問題數(shù)
查詢問題
標(biāo)志
資源記錄數(shù)附加資源記錄數(shù)
授權(quán)資源記錄數(shù)
表1(b) DNS應(yīng)答報文標(biāo)識 問題數(shù) 授權(quán)資源記錄數(shù)
查詢問題
標(biāo)志 資源記錄數(shù)附加資源記錄數(shù)
回答資源記錄(可變)授權(quán)資源記錄(可變)附加資源記錄(可變)

2.3 傳統(tǒng)DNS緩存投毒攻擊原理
目前DNS 采用UDP 協(xié)議傳輸查詢和應(yīng)答數(shù)據(jù)包,采用簡單信任機制,對首先收到的應(yīng)答數(shù)據(jù)包僅進(jìn)行原查詢包發(fā)送IP 地址、端口和隨機查詢ID 的確認(rèn),而不會對數(shù)據(jù)包的合法性做任何分析,若匹配,則接受其作為正確應(yīng)答數(shù)據(jù)包,繼續(xù)DNS 解析過程,并丟棄后續(xù)到達(dá)的所有應(yīng)答數(shù)據(jù)包。這就使得攻擊者可以仿冒權(quán)威名字服務(wù)器向緩存DNS 服務(wù)器發(fā)送偽造應(yīng)答包,力爭搶先完成應(yīng)答以污染DNS 緩存。若攻擊者發(fā)送的偽造應(yīng)答包在權(quán)威名字服務(wù)器發(fā)送的正確應(yīng)答包之前到達(dá)緩存DNS 服務(wù)器,并與原查詢包IP 地址、端口和隨機查詢ID 相匹配,就能夠成功污染DNS 緩存。圖2顯示了傳統(tǒng)DNS 緩存投毒攻擊的過程。
攻擊者偽造的應(yīng)答數(shù)據(jù)包(紅色所示)若能先于正確應(yīng)答數(shù)據(jù)包(黑色所示)到達(dá)緩存DNS 服務(wù)器,并與原查詢包發(fā)送IP 地址、端口和隨機查詢ID 相匹
18 2009.11
,N ETWORK & INFORMATION SECURITY
網(wǎng)絡(luò)與信息安全



配,則將成功污染緩存DNS 服務(wù)器的Cache[10],使
得在該Cache 有效期內(nèi),所有使用該緩存DNS 服務(wù)器的用戶對域名。
2.4 傳統(tǒng)DNS緩存投毒攻擊的缺陷
圖3顯示的是傳統(tǒng)DNS 緩存投毒攻擊成功的時間序列示意圖[1]。
其中,Active Attack階段表示:緩存DNS 服務(wù)器的Cache 中沒有要查詢域名主機的記錄,因而向外發(fā)送查詢數(shù)據(jù)包,從向該域名主機的權(quán)威名字服務(wù)器發(fā)送查詢請求開始到收到應(yīng)答數(shù)據(jù)包的時間(即如圖1中過程(4))。若緩存DNS 服務(wù)器的Cache 中存在要查詢域名主機的記錄,則緩存DNS 服務(wù)器將直接由Cache 中讀取相應(yīng)信息,TTL則表示DNS Cache 中對已有記錄信息的保持時間。
(1)如果DNS Cache 中沒有攻擊目標(biāo)域名的記錄,則由傳統(tǒng)DNS 緩存投毒攻擊原理可知,攻擊者在Active Attack階段內(nèi)發(fā)動攻擊,且偽造的應(yīng)答數(shù)據(jù)包在Active Attack階段內(nèi)到達(dá)緩存DNS 服務(wù)器,才有可能污染Cache,使得攻擊成功。
(2)如果DNS Cache 中存在攻擊目標(biāo)域名的記錄,即處于TTL 時間段內(nèi),這時緩存DNS 服務(wù)器將直接從Cache 中讀取信息,而不再進(jìn)行向根名字服務(wù)器等的迭代查詢,攻擊者將不可能成功;這種情況下,攻擊者要等該記錄在Cache 中失效,即TTL 時間后,重新處于(1)中所述情況時,再發(fā)動攻擊,才有可能成功。
當(dāng)對同一域名持續(xù)攻擊時,假設(shè)攻擊開始前緩存DNS 服務(wù)器的Cache 中沒有該域名記錄,若在一個Active Attack階段中攻擊不成功,再組織有效攻
擊則需要有TTL 的時間間隔。但是,Active Attack
階段時間一般較短,而當(dāng)前大多數(shù)緩存DNS 服務(wù)器的Cache TTL 設(shè)置的時間又較長,這就導(dǎo)致一定時間內(nèi)可利用的攻擊時間很少,大大降低了攻擊成功的概率。這也就是傳統(tǒng)DNS 緩存投毒攻擊最早在1990年即已出現(xiàn),并且一旦攻擊成功,危害極為嚴(yán)重,卻一直沒有引起廣泛關(guān)注的原因。然而,新型的Kaminsky 攻擊克服了這一缺陷,大大提高了攻擊成功率,因此一經(jīng)公布就受到廣泛重視。III.KAMINSKY緩存投毒攻擊
2008年夏天,Dan Kaminsky 發(fā)現(xiàn)了一種新型DNS 緩存投毒攻擊,引起了網(wǎng)絡(luò)安全界的廣泛關(guān)注。該攻擊方法克服了傳統(tǒng)DNS 緩存投毒攻擊存在的攻擊所需時間長、成功率很低的缺陷。
3.1 Kaminsky攻擊原理
傳統(tǒng)的DNS 緩存投毒攻擊,污染的目標(biāo)是應(yīng)答數(shù)據(jù)包中帶有查詢結(jié)果IP 地址的回答資源記錄部分(參見表1 (b)),而Kaminsky 攻擊上升了一個層次,污染的目標(biāo)是應(yīng)答數(shù)據(jù)包中Authority Records部分(授權(quán)資源記錄,參見表1 (b))。圖4顯示了Kaminsky 攻擊流程。
(1)攻擊者向被攻擊的目標(biāo)服務(wù)器發(fā)送一個DNS 查詢請求,該查詢請求中的域名主機使用隨機序列和目標(biāo)域名的組合,如圖4中的www276930. ict.ac.cn,其中ict.ac.cn 為目標(biāo)域名,276930是隨機生成的序列。顯然,這個查詢的域名主機是不存在的,正常返回的應(yīng)答數(shù)據(jù)包中回答資源記錄部分應(yīng)為NXDOMAIN(表示該域名主機不存在)。
(2)被攻擊目標(biāo)服務(wù)器會按2.1節(jié)中所述DNS
2009.11
19
,China Communications
解析過程進(jìn)行查詢,此時攻擊者偽造應(yīng)答數(shù)據(jù)包(紅色所示)并發(fā)送給目標(biāo)服務(wù)器,若該數(shù)據(jù)包能在正確應(yīng)答包(黑色所示) 之前到達(dá)目標(biāo)服務(wù)器,并能成功匹配原查詢包發(fā)送IP 地址、端口和隨機查詢ID,則攻擊成功。
(3)在攻擊者偽造的應(yīng)答數(shù)據(jù)包中,回答資源記錄部分與正確應(yīng)答包一樣(NXDOMAIN,表示該域名主機不存在),但是授權(quán)資源記錄部分是ns1. ict.ac.cn 的偽造IP 地址1.1.1.1,一旦攻擊成功,該資源記錄信息將被寫入目標(biāo)服務(wù)器的Cache 中。在Cache 保持時間內(nèi),對名字服務(wù)器ns1.ict.ac.cn 管轄的所有域名的查詢都將被發(fā)送到攻擊者自己控制的IP(1.1.1.1)中。
3.2 Kaminsky攻擊的優(yōu)勢
(1)如2.4節(jié)所述,傳統(tǒng)DNS 緩存投毒攻擊中,存在攻擊所需時間長、成功率低的問題,而Kaminsky 攻擊克服了這一缺陷。Kaminsky攻擊中,對同一域名進(jìn)行持續(xù)攻擊,每次查詢都會在目標(biāo)域名上添加隨機序列,這使得在目標(biāo)DNS Cache 中一般不存在各個構(gòu)造域名主機的記錄,因此若攻擊不成功,則可以更換隨機序列連續(xù)不斷地進(jìn)行攻擊,不存在有效攻擊時間的問題,也不存在攻擊時間間隔,這將極大地節(jié)省攻擊所需時間,有效提高攻擊成功率。
(2)傳統(tǒng)DNS 緩存投毒攻擊成功后,只是污染了目標(biāo)DNS Cache 中的一條主機記錄,之后對這一個域名主機的查詢將被發(fā)送到攻擊者控制的IP地址。而Kaminsky 攻擊成功后,污染的是目標(biāo)DNS Cache 中一個域名主機的權(quán)威名字服務(wù)器的記錄,之后對該名字服務(wù)器管轄的所有域名主機的查詢都將被發(fā)送到攻擊者控制的IP 地址中,破壞力度遠(yuǎn)高于傳統(tǒng)
DNS 緩存攻擊。
3.3 緩存投毒攻擊所需信息3.3.1所需信息
一個偽造的DNS 應(yīng)答數(shù)據(jù)包需要的信息包括TCP/IP層和DNS 協(xié)議層兩方面。
TCP/IP層包括srcip(權(quán)威名字服務(wù)器的IP 地址)、dstip(被攻擊的緩存DNS 服務(wù)器IP 地址)、sport(權(quán)威名字服務(wù)器使用的端口,通常為53)、dport(被攻擊的緩存DNS 服務(wù)器發(fā)送請求報文時使用的端口)。
DNS 協(xié)議層包括查詢域名、TXID(查詢隨機ID,16bit)。
3.3.2 獲取方式
srcip 通過查詢要攻擊域名的NS 即可獲得,可以用dig、nslookup 等命令查詢得到。sport通常為53。在公網(wǎng)上搜索可以得到要攻擊DNS 服務(wù)器的IP 地址信息,從而獲得dstip。緩存投毒攻擊為攻擊者主動發(fā)送查詢數(shù)據(jù)包,因此查詢域名為攻擊者自己構(gòu)造,相當(dāng)于已知,例如在3.1節(jié)中,查詢域名為276930.ict.ac.cn。
最難獲得的是dport 和TXID 字段。dport和TXID 都是16bit 字段,兩者都有216(65536)種可能值。對于TXID,只能進(jìn)行猜測,在被攻擊的緩存DNS 服務(wù)器收到正確應(yīng)答包之前,越多的偽造應(yīng)答包到達(dá),命中率越高。對于dport 可以有如下幾種獲取方法:
(1)猜測。若TXID 和dport 均采用猜測法,那么每個偽造應(yīng)答包命中的概率僅為1/ (65536x65536),攻擊成功難度較大。
(2)有些DNS 服務(wù)器軟件,如Bind 的一些版本,

在每次進(jìn)程啟動到停止之間,其發(fā)送查詢數(shù)據(jù)包的

圖5 查詢配置域名
20 2009.11
,N ETWORK & INFORMATION SECURITY
網(wǎng)絡(luò)與信息安全
圖6 獲取唯一源端口
源端口都是唯一的[3, 4]。對于上述DNS 服務(wù)器,可以通過其他手段獲得其源端口,即偽造應(yīng)答包的dport。例如,通過porttest.dns-oarc.net就可得知哪些DNS 服務(wù)器存在源端口唯一的漏洞;若再掌握一臺權(quán)威名字服務(wù)器,通過捕包即可獲得存在漏洞的DNS 服務(wù)器的源端口號。具體方法如下:
在一臺可控DNS 服務(wù)器上申請域名,例如:dnstest.com.cn,并為其配置一個權(quán)威名字服務(wù)器,例如:ns1.dnstest.com.cn。用dig 命令發(fā)送查詢域名dnstest.com.cn 的數(shù)據(jù)包,如圖5所示,其中10.0.15.231是存在源端口唯一漏洞的被攻擊服務(wù)器IP。
發(fā)送查詢包的同時,在配置的權(quán)威名字服務(wù)器ns1.dnstest.com.cn 上,用tcpdump 等工具捕包,即可獲得被攻擊目標(biāo)10.0.15.231的源端口號。如圖6所示。
至此,即可獲得緩存投毒攻擊的所需全部信息。3.4 Kaminsky緩存投毒攻擊實例
下面記錄了一次Kaminsky 攻擊前后的全過程。攻擊目標(biāo)DNS 服務(wù)器:10.0.15.231,攻擊目。Kaminsky攻擊前,在目標(biāo)DNS 服務(wù)器的緩存中,對域名的查詢結(jié)果如圖7。
可見,緩存中沒有關(guān)于域名的記錄信息。進(jìn)行Kaminsky 攻擊,如圖8所示。
圖7 攻擊前緩存中記錄
Kaminsky 攻擊結(jié)束后,在目標(biāo)DNS 服務(wù)器的緩存中,對域名dnstest.com.cn 的查詢結(jié)果如圖9。
3.5 緩存投毒攻擊存在的問題
對于源端口隨機性比較好的DNS 服務(wù)器[9],需要同時猜測TXID 和dport 字段,攻擊成功難度較大。
據(jù)緩存投毒攻擊原理,對已在目標(biāo)DNS Cache 中的域名進(jìn)行攻擊不能成功。
一個域名通常會有不止一臺權(quán)威名字服務(wù)器,對這樣的域名查詢時,會從多臺權(quán)威名字服務(wù)器中隨機選取一臺進(jìn)行應(yīng)答,而攻擊者無法估計選中的

是哪一臺,這就增加了攻擊難度。


2009.11
21
,China

Communications
V.結(jié)束語
DNS 在互聯(lián)網(wǎng)上應(yīng)用廣泛,其安全性關(guān)系整個Internet 的穩(wěn)定。本文對傳統(tǒng)DNS 緩存投毒和新型Kaminsky 攻擊進(jìn)行了討論分析,并提出了若干可行的防御策略。DNS緩存投毒攻擊還有很多未公開的應(yīng)用領(lǐng)域,危害性很大,若與其他技術(shù)結(jié)合,破壞性更強。因此,從根本上解決DNS 緩存投毒攻擊,全面加強DNS 的安全,具有重要意義,這也是下一步研究的重點。
(英文全文請參見75頁)
圖9 攻擊成功后緩存中記錄
參考文獻(xiàn)
IV.DNS緩存投毒攻擊的防御策略
盡管傳統(tǒng)DNS 緩存投毒攻擊已出現(xiàn)多年,Kaminsky 漏洞攻擊也已經(jīng)公布了一年多,但實際上仍有相當(dāng)一部分DNS 服務(wù)器沒有進(jìn)行漏洞補丁修復(fù)。針對這種攻擊方式,可采取以下幾種可行的防御策略:
(1)DNS服務(wù)器中Bind 等軟件采用源端口隨機性較好的較高版本。源端口的隨機性可以有效降低攻擊成功的概率,增加攻擊難度。
(2)增加權(quán)威名字服務(wù)器的數(shù)量。據(jù)調(diào)查,國際和國內(nèi)在權(quán)威名字服務(wù)器部署的數(shù)量方面近幾年均有所提升[5],但應(yīng)進(jìn)一步加強。
(3)在現(xiàn)有DNS 協(xié)議框架基礎(chǔ)上,引入一些技巧性方法,增強DNS 安全性。如在對DNS 應(yīng)答數(shù)據(jù)包的認(rèn)證方面,除原查詢包發(fā)送IP 地址、端口和隨機查詢ID 外,再增加其他可認(rèn)證字段,增強認(rèn)證機制。David Dagon等[2]就曾提出增加對查詢域名大小寫認(rèn)證的算法,使DNS 服務(wù)器在收到應(yīng)答數(shù)據(jù)包后,在原認(rèn)證基礎(chǔ)上,再利用該算法對應(yīng)答包與原查詢包中查詢域名大小寫進(jìn)行比對,若匹配,則說明是正確應(yīng)答包,否則可能為攻擊者偽造應(yīng)答包,進(jìn)一步增強了安全性。
(4)改進(jìn)現(xiàn)有DNS 協(xié)議框架,例如在DNS 服務(wù)器上配置DNSSEC[8],或引入IPv6協(xié)議機制。DNSSEC 是專門保證DNS 安全的機制,試圖提升對應(yīng)答數(shù)據(jù)包的弱認(rèn)證方式以提高DNS 安全性。建立在IPv6協(xié)議上面的DNS 是一種全新的模式,目前尚處于理論階段,有待進(jìn)一步實施。
[1]D.Dagon, M.Antonakakis, K.day, X.Luo, C.P.Lee, W.Lee: Recursive DNS Architectures and Vulnerability Implications. In Proceeding of The 16th Annual Network and Distributed System Security Symposium(NDSS 2009), San Diego, CA, February 2009.
[2]D.Dagon, M.Antonakakis, P.Vixie, T.Jinmei, and W.Lee: Increased DNS Forgery Resistance Through 0x20-Bit Encoding. In Proceedings of the 15th ACM Conference on Computer and Communications Security (CCS 2008), October 2008.
[3]Amit Klein: BIND 9 DNS Cache Poisoning. , 2007.
[4]Amit Klein: BIND 8 DNS Cache Poisoning. , 2007.
[5]王圭. 域名系統(tǒng)安全性研究[D]. 博士學(xué)位論文,哈爾濱工業(yè)大學(xué),2007.
[6]J.Stewart: DNS Cache Poisoning—The Next Generation [EB/OL]. (2007-08-25). http://www.secureworks.com/research/articles/dns-cache-poisoning/.
[7]T.Olzak: DNS Cache Poisoning: Definition and Prevention [EB/OL]. (2006-03-02). infosecwriters.com .
[8]M. A n d r e w s : T h e d n s s e c l o o k a s i d e validation(dlv) dns resource record,rfc 4431.
, 2006.
[9]“Internet Systems Consortium BIND 9.4.1” (Internet Systems Consortium web page).
h t t p ://w w w. i s c. o r g /i n d e x. p l ? /s w /b i n d /view/?release=9.4.1
[10]K e t i l F r o y n : “D N S P o i s o n i n g ” (demonstration web page), 2003.
22 2009.11
,N ETWORK & INFORMATION SECURITY
網(wǎng)絡(luò)與信息安全
Principles and Defense Strategies of DNS Cache Poisoning
Jin Chong1, 2, Hao Zhiyu1, Wu Zhigang1
12
Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190 Graduate University of Chinese Academy of Sciences, Beijing 100190
Abstract : DNS is one of the most important basic infrastructures of the Internet, attacks on which will prevent the Internet from working properly. Therefore, its security is receiving great concern. This paper analyzes the principles of both tradi-tional and novel (Kaminsky) DNS cache poison-ing, presents attack samples and describes the whole attack process in detail. After verifying the potential harm of DNS cache poisoning, the paper gives out several defense strategies.
Key words: DNS; cache poisoning; Kaminsky at-tack
DNS server with the fake IP address information [6, 7]. This paper introduces the basic principles of both traditional and novel (Kaminsky) DNS cache poisoning and offers several defense strategies.
II. TRADITIONAL DNS CACHE POISON-ING
A DNS server only records all local authorized hosts. If the information of a host is to be queried, which is not local, a request message should be sent to the information holder (authoritative name server). To avoid the repetition for deliveries of such requests, the DNS server will save the results returned by the authoritative name server in the cache for a certain time, which constitute the DNS cache. By contaminating the DNS cache, namely replacing the real IP address information of hosts’ records in the cache with the fake IP address infor-mation, DNS cache poisoning causes damages.2.1 DNS ResolutionWe brie? y introduce the DNS resolution here be-fore analyzing the principles of DNS cache poi-soning, assuming that the domain name we are about to query is , namely the target domain name, and that the client as well as the default caching , namely default DNS server, meet the following conditions:
I. INTRODUCTION
DNS (Domain Name System) is a multi-level dis-tributed database system, whose basic function is to complete name resolution, namely providing a mapping relation between domain names and IP addresses, and therefore it brings much conven-ience to Internet users. DNS is the foundation and also one of the most successful applications of the Internet, and its security has drawn a lot of at-tention. DNS cache poisoning is one of the most hazardous methods in DNS attacks, which is also a hot topic in the research area. DNS cache poison-ing causes damages by replacing the real IP ad-dress information of hosts’ records in the cache of
2009.11
75
,China Communications

(1) The client and the default caching start up for the ? rst time so that there is no local cache information.
(2) The default caching name server is not the authoritative name server of the target domain name.
Figure 1 shows the query process. It works as follows:
(1) The client sends a request of recursive query of to the default caching name serv-er.
(2) The default caching name server checks its local records. If there is such information, it re-turns the authoritative answer; else, it will check its local cache and return the result to the client if there exists. If there is no such record in the cache either, it will send an iterative query to a root name server. According to the assumption above, in this example an iterative query is sent.
(3) The root name server returns the address of the authoritative name server of “cn” domain, namely the top-level name server, and the default caching name server keeps sending the iterative query to the top-level name server.
(4) The top-level name server returns the ad-dress of the authoritative name server of “ac.cn ” domain. The default caching name server keeps querying until getting the authoritative answer of . After that, it saves the authoritative answer in its local cache and returns the authorita-tive answer to the client, ? nishing this query proc-ess.
2.2 DNS Message Format
DNS protocol defines message formats for both
queries and responses. Most of the time it uses UDP protocol to transfer the data packets. Table 1(a) shows the message format of DNS queries, and Table 1(b) shows the message format of DNS responses.
2.3 Principles of Traditional DNS Cache Poison-ing
Currently, DNS adopts simple trust mechanism, which only veri? es the destination IP address, the destination port and the random query ID of the re-ceived response data packet, and never makes any analysis of the legality of the response data packet. If the three ? elds above match, the response packet will be accept as the real response data packet. The DNS server will go on with the rest of the DNS resolution process and ignoring all the response packets that arrive later. Therefore, an attacker could pretend to be the authoritative name server and send fake response packets. If one of the fake response packets arrives at the DNS server before the real one, sent by the authoritative name server, and the three fields of the fake packet match the source IP address, the source port and the random query ID of the original query packet, the attacker could successfully contaminate the cache of the DNS server. Figure 2 shows the process of tradi-tional DNS cache poisoning.

76 2009.11
,N ETWORK & INFORMATION SECURITY
網(wǎng)絡(luò)與信息安全
,China Communications

packet (Table 1(b)). Figure 4 shows the process of the Kaminsky attack.
(1) The attacker sends a DNS query to the name server to be attacked, in which the hostname is a combination of the target domain name and a ran-dom series, namely www276930.ict.ac.cn in Figure 4, in which ict.ac.cn is the target domain name and 276930 is the random series. Obviously the queried hostname doesn’t exist and the answer resource record in the response data packet returned should normally be NXDOMAIN (namely the hostname doesn’t exist).
(2) The attacked name server will make the que-ry according to the DNS resolution described in 2.1. At this moment, the attacker fakes response data packets (e. g. the red packet in Figure 4) and sends them to the attacked name server. If one fake data packet arrives at the attacked name server prior to the real response data packet (the black packet in Figure 4) and its destination IP address, destination port and random query ID successfully match the corresponding ? elds of the original query packet, the attacker succeeds.
(3) The answer resource record in the fake re-sponse data packet is the same as that in the real response data packet (NXDOMAIN, which means the hostname doesn’t exist), but the authority re-source record is the fake IP address of ns1.ict.ac.cn (1.1.1.1). Once the attacker succeeds, the author-ity resource record will be written into the cache of the attacked name server. During the time that the cache is valid, all queries of the domain names
belonging to the name server ns1.ict.ac.cn will be sent to the IP address (1.1.1.1) which is actually designated by the attacker.
3.2 Advantages of Kaminsky Attack
(1) As mentioned in 2.4, there are several de? cien-cies in traditional DNS cache poisoning, namely the long time needed for a successful attack and the low success possibility, however, the Kaminsky at-tack makes up for such de? ciencies. In the Kamin-sky attack, when continuously attacking a domain name, random series will be appended to the target domain name in each query, and thus there are no records for the domain name of each query in the attacked DNS cache. If one attack is not success-ful, the attacker could replace the random series with a new one and repeat the attack, in which the problem that the effective time in attacks is quite short no longer exists. In this way, the Kaminsky attack saves the attack time dramatically and in-creases the success possibility effectively.(2) If the traditional DNS cache poisoning succeeds, it only contaminates a hostname record in the attacked DNS cache. After that, only the query for the same hostname will be sent to the IP address designated by the attacker. However, if the Kaminsky attack succeeds, it contaminates the domain name record of an authoritative name server in the attacked DNS cache, and then queries of all hostnames ad-ministered by that authoritative name server will be sent to the IP address designated by the attacker. Therefore, the damage caused by Kaminsky attack is much worse.
3.3 Information Needed for DNS Cache Poison-ing Attack
3.3.1 Information Needed
Information needed in faking DNS response data packet should include two aspects: TCP/IP layer and DNS layer.
In TCP/IP layer, it should include srcip (IP ad-dress of the authoritative name server), dstip (IP address of the DNS server to be attacked), sport (port used by the authoritative name server, usually 53), and dport (port used when the attacked DNS server sends queries).
78 2009.11