<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    原文地址:http://drops.wooyun.org/news/1011

    最近蘋果的那一行沒有驗證SSL證書的bug代碼,鬧的紛紛攘攘,其實歷史上也有很多出現類似的代碼,讓我們來回顧一下:

    X

    回到2006年,X server檢測用戶是否為root用戶,竟然忘記了調用檢測函數

    #!diff
    --- hw/xfree86/common/xf86Init.c
    +++ hw/xfree86/common/xf86Init.c
    @@ -1677,7 +1677,7 @@
       }
       if (!strcmp(argv[i], "-configure"))
       {
    -    if (getuid() != 0 && geteuid == 0) {
    +    if (getuid() != 0 && geteuid() == 0) {
            ErrorF("The '-configure' option can only be used by root.\n");
            exit(1);
         }
    

    很奇怪吧,編譯的時候沒有人看到警告信息嗎?

    Debian OpenSSL

    在2008年,Debian發行了的一個版本密鑰可能被猜測到

    #!diff
    --- openssl-a/md_rand.c
    +++ openssl-b/md_rand.c
    @@ -271,10 +271,7 @@
                    else
                            MD_Update(&m,&(state[st_idx]),j);
    
    -/*             
    - * Don't add uninitialised data.
                    MD_Update(&m,buf,j);
    -*/
                    MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c));
                    MD_Final(&m,local_md);
                    md_c[1]++;
    

    嗯,這個是三行修復代碼,搞不明白代碼審計的時候發生了什么。

    OpenSSL

    同樣是OpenSSL,同樣在2008年,OpenSSL 0.9.8i以及更早版本中沒有正確的檢查EVP_VerifyFinal函數的返回值,導致遠程攻擊者可以通過繞過證書的驗證

    #!diff
    --- lib/libssl/src/ssl/s3_srvr.c
    +++ lib/libssl/src/ssl/s3_srvr.c
    @@ -2009,7 +2009,7 @@ static int ssl3_get_client_certificate(S
        else
            {
            i=ssl_verify_cert_chain(s,sk);
    -       if (!i)
    +       if (i <= 0)
                {
                al=ssl_verify_alarm_type(s->verify_result);
                SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,SSL_R_NO_CERTIFICATE_RETURNED);
    

    這可能是你想象中最嚴重的安全問題了吧?

    Android

    這次是2010年,修復細節

    #!diff
    --- libc-a/memset.c
    +++ libc-b/memset.c
    @@ -1,6 +1,6 @@
     void *memset(void *_p, unsigned v, unsigned count)
     {
         unsigned char *p = _p;
    -    while(count-- > 0) *p++ = 0;
    +    while(count-- > 0) *p++ = v;
         return _p;
     }
    

    這里也沒有人編譯的時候提示警告有個未使用的參數信息?

    Tarsnap

    2011年,借此重構AES-CTR代碼

    #!diff
    --- tarsnap-autoconf-1.0.27/lib/crypto/crypto_file.c
    +++ tarsnap-autoconf-1.0.28/lib/crypto/crypto_file.c
    @@ -108,7 +108,7 @@
    
            /* Encrypt the data. */
            if ((stream =
    -           crypto_aesctr_init(&encr_aes->key, encr_aes->nonce)) == NULL)
    +           crypto_aesctr_init(&encr_aes->key, encr_aes->nonce++)) == NULL)
                    goto err0;
            crypto_aesctr_stream(stream, buf, filebuf + CRYPTO_FILE_HLEN, len);
            crypto_aesctr_free(stream);
    

    原文:http://www.tedunangst.com/flak/post/a-brief-history-of-one-line-fixes

    97av