E安全9月15日讯 思科Talos团队的Cory Duplantis发现LibOFX 0.9.11中存在可利用的缓冲区溢出漏洞。特制OFX文件可能会导致写带外数据( Out of Bound data)引起堆栈缓冲区溢出。攻击者可创建恶意OFX文件触发该漏洞——CVE-2017-2816。
带外(Out of Band,OOB)数据
端对端数据传输时,用于迅速通告对方本端发生的重要事件。带外数据比普通数据(也称带内数据)有更高的优先级,总是立即发送,而不论发送缓冲区是否有排队等待发送的普通数据。 带外数据的传输可以使用一条独立的传输层连接,也可以映射到传输普通数据的连接中,即带外数据并不是通过两条套接字连接来实现的,这类数据也是通过已有的连接来传输。
Talos公司此次发现一项可被利用的缓冲区溢出漏洞,利用特定OFX文件,其可能出现写入操作边界溢出,并导致对方获得代码执行能力:
TALOS-2017-0317 (CVE-2017-2816) - LibOFX标签解析代码执行漏洞
此项漏泄目前尚未得到修复,而Talos方面在《供应商漏洞报告与披露政策》指定的期限之内亦未收到相关开发人员给出的回复。
讽刺的是,该漏洞位于清理功能当中的标签解析流程内。在此功能当中,标签名称会以本地方式存储在堆栈之内,而过长的标签名称则会造成堆栈溢出。
CVE-2017-2816漏洞详情
OFX是一个开放性财务数据交换协议,金融机构使用OFX与客户共享财务数据。
LibOFX是开放性金融交易(OFX)的开源解析库,金融机构使用OFX与客户共享金融数据。作为一套复杂的标准实现方案,这套库被GnuCash等财务软件所广泛使用。GnuCash能使用OFX的开源解析库libOFX导入OFX记录。
解析给定OFX记录的标签时, libOFX尝试去掉现有OFX的专有标签。
检查正确OFX标签
【代码】
lib/ofx_preproc.cpp:75
const unsigned int READ_BUFFER_SIZE = 1024;
lib/ofx_preproc.cpp:417
string sanitize_proprietary_tags(string input_string)
{
unsigned int i;
size_t input_string_size;
bool strip = false;
bool tag_open = false;
int tag_open_idx = 0; //Are we within < > ?
bool closing_tag_open = false; //Are we within ?
int orig_tag_open_idx = 0;
bool proprietary_tag = false; //Are we within a proprietary element?
bool proprietary_closing_tag = false;
int crop_end_idx = 0;
char buffer[READ_BUFFER_SIZE] = "";
char tagname[READ_BUFFER_SIZE] = "";
int tagname_idx = 0;
char close_tagname[READ_BUFFER_SIZE] = "";
for (i = 0; i < input_string_size; i++)
if (input_string.c_str()[i] == '<')
{
tag_open = true;
tag_open_idx = i;
if (proprietary_tag == true && input_string.c_str()[i+1] == '/')
{
...
}
else if (proprietary_tag == true)
{
//It is the start of a new tag, following a proprietary tag
crop_end_idx = i - 1;
strip = true;
}
}
else if (input_string.c_str()[i] == '>')
{
...
}
else if (tag_open == true && closing_tag_open == false)
{
if (input_string.c_str()[i] == '.')
{
if (proprietary_tag != true)
{
orig_tag_open_idx = tag_open_idx;
proprietary_tag = true;
}
}
tagname[tagname_idx] = input_string.c_str()[i]; [0]
tagname_idx++;
由于input_string变量会造成循环,如果input_string大于READ_BUFFER_SIZE,这个堆栈变量tagname就造成缓冲区溢出,并可能潜在执行恶意代码。
【崩溃信息】
==6542==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffffbb4260 at pc 0x7fab9d30ccc1 bp 0x7fffffbb39b0 sp 0x7fffffbb39a8
WRITE of size 1 at 0x7fffffbb4260 thread T0
#0 0x7fab9d30ccc0 (/home/vagrant/fuzzing/libofx-asan/libofx-0.9.11/lib/.libs/libofx.so.7+0x30cc0)
#1 0x7fab9d30aba0 (/home/vagrant/fuzzing/libofx-asan/libofx-0.9.11/lib/.libs/libofx.so.7+0x2eba0)
#2 0x7fab9d3057cb (/home/vagrant/fuzzing/libofx-asan/libofx-0.9.11/lib/.libs/libofx.so.7+0x297cb)
#3 0x4f8ba2 (/home/vagrant/fuzzing/libofx-asan/libofx-0.9.11/ofxdump/.libs/lt-ofxdump+0x4f8ba2)
#4 0x7fab9c06982f (/lib/x86_64-linux-gnu/libc.so.6+0x2082f)
#5 0x419618 (/home/vagrant/fuzzing/libofx-asan/libofx-0.9.11/ofxdump/.libs/lt-ofxdump+0x419618)
Address 0x7fffffbb4260 is located in stack of thread T0 at offset 2208 in frame
#0 0x7fab9d30c38f (/home/vagrant/fuzzing/libofx-asan/libofx-0.9.11/lib/.libs/libofx.so.7+0x3038f)
This frame has 9 object(s):
[32, 1056) 'buffer'
[1184, 2208) 'tagname' <== Memory access at offset 2208 overflows this variable
[2336, 3360) 'close_tagname'
[3488, 3520) ''
[3552, 3584) ''
[3616, 3617) ''
[3632, 3664) ''
[3696, 3728) ''
[3760, 3761) ''
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
(longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/vagrant/fuzzing/libofx-asan/libofx-
0.9.11/lib/.libs/libofx.so.7+0x30cc0)
Shadow bytes around the buggy address:
0x10007ff6e7f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10007ff6e840: 00 00 00 00 00 00 00 00 00 00 00 00[f2]f2 f2 f2
0x10007ff6e850: f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 00 00 00 00
0x10007ff6e860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x10007ff6e890: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==6542==ABORTING
欲了解更多与此项安全漏洞相关的细节信息,请参阅研究报告:TALOS-2017-0317
LibOFX 0.9.11
https://github.com/libofx/libofx
8.8分- CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
未检查输入大小的缓冲区拷贝(传统的缓冲区溢出)
2017-04-14 - 厂商披露
2017-09-13 – 公开发布
漏洞影响
作为一套开源库,LibOFX适用于多种财务应用程序。此项漏洞的存在意味着攻击者将能够借此实现多种操作。触发此项漏泄并不需要特定的用户交互活动,且任何受此漏洞影响的系统皆有可能包含具有重要价值的财务信息——此类信息可能被用于实施身份盗用、欺诈或者被转售给其他犯罪分子。
各类企业机构可能尚未意识到这套库存在于第三方软件内被用于解析OFX文件,或者被纳入内部项目中的某些软件。大家应当持续关注内部项目中所使用的开源库方案,并快速应用由第三方供应商提供的修复补丁,从而确保此类安全漏洞在被攻击者实际利用之前得到正确管理。
以下Snort规则将检查对该漏洞的利用活动:
Snort规则: 42277-4227
请注意:未来可能将陆续发布更多后续规则,且目前的规则亦可能在更多漏洞信息曝光后发生变更。欲了解与最新规则相关的信息,请参阅您的FireSIGHT管理中心或者Snort.org网站。
注:本文由E安全编译报道,转载请注明原文地址
https://www.easyaq.com/news/1761671404.shtml
相关阅读:
▼点击“阅读原文” 查看更多精彩内容