SSL/TLS協議信息泄露漏洞(CVE-2016-2183)


當時看升級openssl能夠解決此問題,於是,開始升級openssl

1. 下載新版本openssl
查看當前openssl版本信息

[root@localhost ~]# openssl version -a
OpenSSL 1.0.2r 26 Feb 2019 #openssl版本信息
built on: reproducible build, date unspecified
platform: linux-x86_64
options: bn(64,64) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -Wa,--noexecstack -m64 -DL_ENDIAN -O3 -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/local/ssl"
下載新版本:

[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# ll
總用量 0
[root@localhost src]# wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz

下載過程:
--2021-06-04 10:51:29-- https://www.openssl.org/source/openssl-1.1.1h.tar.gz
正在解析主機 www.openssl.org (www.openssl.org)... 104.117.217.32, 2600:1417:1000:882::c1e, 2600:1417:1000:8a4::c1e
正在連接 www.openssl.org (www.openssl.org)|104.117.217.32|:443... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:9810045 (9.4M) [application/x-gzip]
正在保存至: “openssl-1.1.1h.tar.gz”

100%[======================================================================================================================================>] 9,810,045 156KB/s 用時 73s

2021-06-04 10:52:45 (132 KB/s) - 已保存 “openssl-1.1.1h.tar.gz” [9810045/9810045])
2. 備份證書文件和秘鑰文件
[root@localhost src]# mv /usr/bin/openssl /usr/bin/openssl.old
[root@localhost src]# mv /usr/include/openssl /usr/include/openssl.old
3. 安裝新版本openssl
解壓:

[root@localhost src]# cd /usr/local/src/
[root@localhost src]# tar -zxvf openssl-1.1.1h.tar.gz
安裝:

#進入目錄
[root@172-15-4-5 openssl-1.1.1h]# cd openssl-1.1.1h

預編譯到指定安裝路徑,生成Makefile文件,-t參數可測試編譯情況,–prefix:指定安裝目錄;–openssldir:指定openssl配置文件路徑

[root@172-15-4-5 openssl-1.1.1h]# ./config --prefix=/usr/local/openssl

輸出內容:

Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1h (0x1010108fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
*** ***
*** OpenSSL has been successfully configured ***
*** ***
*** If you encounter a problem while building, please open an ***
*** issue on GitHub <https://github.com/openssl/openssl/issues> ***
*** and include the output from the following command: ***
*** ***
*** perl configdata.pm --dump ***
*** ***
*** (If you are new to OpenSSL, you might want to consult the ***
*** 'Troubleshooting' section in the INSTALL file first) ***
*** ***
**********************************************************************


編譯

[root@172-15-4-5 openssl-1.1.1h]# make
輸出結果(部分)

gcc -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG -MMD -MF test/x509_dup_cert_test.d.tmp -MT test/x509_dup_cert_test.o -c -o test/x509_dup_cert_test.o test/x509_dup_cert_test.c
rm -f test/x509_dup_cert_test
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \
-o test/x509_dup_cert_test test/x509_dup_cert_test.o \
test/libtestutil.a -lcrypto -ldl -pthread
gcc -I. -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG -MMD -MF test/x509_internal_test.d.tmp -MT test/x509_internal_test.o -c -o test/x509_internal_test.o test/x509_internal_test.c
rm -f test/x509_internal_test
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \
-o test/x509_internal_test test/x509_internal_test.o \
test/libtestutil.a libcrypto.a -ldl -pthread
gcc -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG -MMD -MF test/x509_time_test.d.tmp -MT test/x509_time_test.o -c -o test/x509_time_test.o test/x509_time_test.c
rm -f test/x509_time_test
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \
-o test/x509_time_test test/x509_time_test.o \
test/libtestutil.a -lcrypto -ldl -pthread
gcc -Iinclude -pthread -m64 -Wa,--noexecstack -Wall -O3 -DNDEBUG -MMD -MF test/x509aux.d.tmp -MT test/x509aux.o -c -o test/x509aux.o test/x509aux.c
rm -f test/x509aux
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \
-o test/x509aux test/x509aux.o \
test/libtestutil.a -lcrypto -ldl -pthread
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" apps/CA.pl.in > "apps/CA.pl"
chmod a+x apps/CA.pl
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" apps/tsget.in > "apps/tsget.pl"
chmod a+x apps/tsget.pl
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" tools/c_rehash.in > "tools/c_rehash"
chmod a+x tools/c_rehash
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
"-oMakefile" util/shlib_wrap.sh.in > "util/shlib_wrap.sh"
chmod a+x util/shlib_wrap.sh
make[1]: Leaving directory `/usr/local/src/openssl-1.1.1h'

安裝

[root@172-15-4-5 openssl-1.1.1h]# make install
輸出結果(部分)

/opt/openssl/share/doc/openssl/html/man7/X448.html -> /opt/openssl/share/doc/openssl/html/man7/X25519.html
/opt/openssl/share/doc/openssl/html/man7/bio.html
/opt/openssl/share/doc/openssl/html/man7/crypto.html
/opt/openssl/share/doc/openssl/html/man7/ct.html
/opt/openssl/share/doc/openssl/html/man7/des_modes.html
/opt/openssl/share/doc/openssl/html/man7/evp.html
/opt/openssl/share/doc/openssl/html/man7/ossl_store-file.html
/opt/openssl/share/doc/openssl/html/man7/ossl_store.html
/opt/openssl/share/doc/openssl/html/man7/passphrase-encoding.html
/opt/openssl/share/doc/openssl/html/man7/proxy-certificates.html
/opt/openssl/share/doc/openssl/html/man7/scrypt.html
/opt/openssl/share/doc/openssl/html/man7/ssl.html
/opt/openssl/share/doc/openssl/html/man7/x509.html

4. 替換原有舊openssl文件
[root@localhost ~]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
[root@localhost ~]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl

#在/etc/ld.so.conf文件中寫入openssl庫文件的搜索路徑
[root@localhost ~]# echo "/usr/local/openssl/lib" >> /etc/ld.so.conf

#使修改后的/etc/ld.so.conf生效
[root@localhost ~]# ldconfig -v


5. 驗證版本
[root@172-15-4-5 openssl-1.1.1h]# openssl version
OpenSSL 1.1.1h 22 Sep 2020
完美,也能正常查看版本信息。為了確保萬無一失,決定重啟一下系統。

[root@172-15-4-5 openssl-1.1.1h]# reboot
再次驗證版本

[root@172-15-4-5 openssl-1.1.1h]# openssl version
OpenSSL 1.1.1h 22 Sep 2020


再次漏掃,已經沒有該漏洞了。

6. 過程中遇到的坑
升級完openssl,直接裂開。

openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
於是上網查了一下,主要原因是缺少依賴。大部分網上解決方案,都是創建軟連接。主要是執行以下命令:

[root@172-15-4-5 lib]# ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
[root@172-15-4-5 lib]# ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1
然而,這並不能解決問題,因為我是通過源碼安裝的openssl新版本,在/usr/local/lib目錄下,根本就沒有上面的文件。也不知道如何下載這些文件。當然,這個過程中也試過了其他的方法,比如修改配置等。最終我是發現我根本沒有上面兩個依賴的文件,包括在lib64目錄下也沒有。

於是,我想試試yum安裝,這樣是不是就能夠自動添加依賴。

yum安裝openssl

[root@172-15-4-5 lib64]# yum -y install openssl
安裝完成后驗證版本:

[root@172-15-4-5 lib64]# openssl version -a
OpenSSL 1.0.2k-fips 26 Jan 2017
built on: reproducible build, date unspecified
platform: linux-x86_64
options: bn(64,64) md2(int) rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx)
compiler: gcc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DKRB5_MIT -m64 -DL_ENDIAN -Wall -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wa,--noexecstack -DPURIFY -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DRC4_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/etc/pki/tls"
engines: rdrand dynamic
沒有報錯。只不過openssl版本沒有我自己下載的版本高,相當於其實是降低了版本的。並沒有解決漏洞問題。沒法,又重新用源碼安裝新版ssl(上述步驟),發現之前的步驟存在一點小問題,一個是confi階段的參數問題,二是創建軟連接時並未生效。總之,最終還是解決了問題。

1-5步驟,親測已經可以使用,並且重啟系統后,對ssh,nginx都沒有帶來影響。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM