網路電台業者速升級Icecast,抑制buffer overflow干擾
- 發布單位:TWCERT/CC
- 更新日期:2019-04-03
- 點閱次數:731
CVE編號
內文
●概述:
非營利性組織Xiph.Org基金會致力創作開源多媒體格式及程式,其中音訊串流媒體伺服器軟體Icecast,支援影音資料處理公開標準,經Semmle Security研究團隊以LGTM工具發掘出後台程式缺陷,auth_url.c內某段迴圈在接收用戶request內HTTP header後,以snprintf( )運算回傳輸出資料byte長度,以遞增緩衝區位址指標,然相關算式缺乏安全設計,將造成越界寫入,破壞其他堆疊內容,該項記憶體區段錯誤(segfault),恐造成Icecast server 2.4.x系列(且定義為mount以啟動URL驗證)出現DoS狀態,更嚴重者將觸發RCE,對於安裝Icecast之網路電台,有營運中斷風險,建議儘速取得Xiph.Org基金會新版軟體。
●編註:
(1)緩衝區溢位成因
(1-1)snprintf( )特性
在C語言裡,程式人員常以snprintf( )代替sprintf( ),避免觸發buffer overflow,而snprintf( )接收變數資料型態如下:
int snprintf(char *str, size_t size, const char * restrict format, ...)
參數size用途就是限制最大的寫入資料量,若輸出字串超過size律定長度時,則截斷字串,目的即避免溢位狀況,而理論上,snprintf( )應該回傳輸出字串所需的字元陣列長度。
然實際上,snprintf( )所回傳的值,並非真正輸出資料byte量,而是假設參數size夠大,方能輸出之資料byte長度。
(1-2)Icecast程式碼瑕疵
Icecast server中,原始碼auth_url.c內url_add_client()函數某段迴圈反複呼叫snprintf( ),處理用戶端request內HTTP header,複製到buffer後再建立POST請求,交給認證伺服器,局部程式如下:
post_offset += snprintf(post + post_offset, sizeof(post) - post_offset, "&%s%s=%s",url->prefix_headers ? url->prefix_headers : "",cur_header, header_valesc);
顯然post_offset將持續累加,很有可能越過緩衝區邊界,也有可能接收到包含鉅量資料的http header,造成sizeof(post) - post_offset算式出現二進位補數underflow結果,反而產生極大值,導致post_offset跳躍至buffer外某處,並覆蓋其他程式正使用的stack內容,造成Segmentation fault。
(2)Segmentation fault
記憶體區段錯誤(Segmentation fault)縮寫為segfault,別稱存取權衝突(access violation),該程式錯誤出現在存取無法定址的記憶體區段時,通常是因為指向某個位址,而該位址為空值(NULL)所致,而越界存取陣列變數也可能產生同樣錯誤。
影響產品
解決辦法
https://gitlab.xiph.org/xiph/icecast-server/commit/03ea74c04a5966114c2fe66e4e6892d11a68181e
https://gitlab.xiph.org/xiph/icecast-server/blob/release-2.4.4/ChangeLog
(2)下載icecast-2.4.4.tar.gz(適用Linux、Unix)、icecast_win32_2.4.4.exe(適用Windows),參考http://www.icecast.org/download/
https://ftp.osuosl.org/pub/xiph/releases/icecast/
相關連結
- https://lgtm.com/blog/icecast_snprintf_CVE-2018-18820
- https://icecast.org/news/icecast-release_2_4_4/
- https://www.bleepingcomputer.com/news/security/security-bug-in-icecast-puts-online-radio-stations-at
- https://gitlab.xiph.org/xiph/icecast-server/issues/2342
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-18820
- https://www.openwall.com/lists/oss-security/2018/11/01/3
- https://securitytracker.com/id/1042019
- https://www.debian.org/security/2018/dsa-4333
- https://xiph.org/
- https://zh.wikipedia.org/wiki/Xiph.Org%25E5%259F%25BA%25E9%2587%2591%25E6%259C%2583
- https://zh.wikipedia.org/wiki/Icecast
- https://zh.wikipedia.org/wiki/%25E8%25A8%2598%25E6%2586%25B6%25E9%25AB%2594%25E5%258D%2580%25E6%25AE
- https://kheresy.wordpress.com/2010/01/28/%25E7%2594%25A8-snprintf-asprintf-%25E5%258F%2596%25E4%25BB
- https://blog.xuite.net/tzeng015/twblog/113272245-snprintf
- http://radionanet.com/images/Icecast_logo.png