Bitcoin bitcoind ‘bitcoinrpc.cpp’ 密码信息泄露漏洞

QQ空间 新浪微博 微信 QQ facebook twitter
漏洞ID 1166873 漏洞类型 信息泄露
发布时间 2013-07-24 更新时间 2013-08-02
CVE编号 CVE-2013-4165 CNNVD-ID CNNVD-201307-568
漏洞平台 N/A CVSS评分 4.3
|漏洞来源
https://www.securityfocus.com/bid/61433
https://cxsecurity.com/issue/WLB-2013070189
http://www.cnnvd.org.cn/web/xxk/ldxqById.tag?CNNVD=CNNVD-201307-568
|漏洞详情
Bitcoin(比特币)是Bitcoin基金会的一种用开源的P2P软件开发的电子货币、数字货币,是一种网络虚拟货币。bitcoind是一个简洁的比特币客户端版本。bitcoind0.8.1版本中的bitcoinrpc.cpp文件中的‘HTTPAuthorized’函数中存在安全漏洞,该漏洞源于函数匹配密码采用一个字节一个字节对比。远程攻击者可通过时序攻击利用该漏洞确认密码。
|漏洞EXP
bool HTTPAuthorized(map<string, string>& mapHeaders)
{
    string strAuth = mapHeaders["authorization"];
    if (strAuth.substr(0,6) != "Basic ")
        return false;
    string strUserPass64 = strAuth.substr(6); boost::trim(strUserPass64);
    string strUserPass = DecodeBase64(strUserPass64);
    return strUserPass == strRPCUserColonPass;
}
Last string comparision strUserPass == strRPCUserColonPass gets compiled to:

    do
    {
      if ( !len )
        break;
      less = *(_BYTE *)strUserPass < *(_BYTE *)strRPCUserColonPass;
      eq = *(_BYTE *)strUserPass++ == *(_BYTE *)strRPCUserColonPass++;
      --len;
    }
    while ( eq );
which is a byte-by-byte compare. Attacker with precise clock (being in the same LAN, for example) might learn the RPC password letter by letter, by trying passwords like 'a...", "b...", "c..." and observing which took the longest time to verify.

This code in bitcoinrpc.cpp:

            if (mapArgs["-rpcpassword"].size() < 20)
                MilliSleep(250);
protects from bruteforce for short password. Unfortunately, when run, bitcoind suggest a 32 chars password. Paradoxically short passwords are safer to use than longer ones, wrt to the timing leak.

Here's an example of time independent array comparison: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/
|参考资料

来源:github.com
链接:https://github.com/bitcoin/bitcoin/pull/2845
来源:github.com
链接:https://github.com/bitcoin/bitcoin/issues/2838
来源:MLIST
名称:[oss-security]20130725Re:CVErequest:timingleakinbitcoind
链接:http://openwall.com/lists/oss-security/2013/07/25/5
来源:BID
名称:61433
链接:http://www.securityfocus.com/bid/61433