我爲何要寫這一篇稿子?html
爲了不更多的運維、開發者沒能實現企業的信息安全,我將共享出我我的的HTTPD的安全修復(2.2和2.4差不太多就看2.4就好) apache
原由:我爲某M工做,但因某M和testin合做,結果他們跑個腳本在安全上檢測到安全
SlowHTTPDenialofServiceAttack(解決方案是reqtimeout_module)服務器
不安全的http
poodle
sweet32
中間件漏洞:
響應包版本泄露session
【順便一提,這些問題我早知道了,他們的修復建議並沒什麼用,依然是CV大法】運維
首先咱們來看看2.2有哪些風險dom
Fixed in Apache httpd 2.2.23 low: XSS in mod_negotiation when untrusted uploads are supported (CVE-2012-2687) low: insecure LD_LIBRARY_PATH handling (CVE-2012-0883) Fixed in Apache httpd 2.2.24 low: XSS due to unescaped hostnames (CVE-2012-3499) --moderate: XSS in mod_proxy_balancer (CVE-2012-4558) Fixed in Apache httpd 2.2.25 low: mod_rewrite log escape filtering (CVE-2013-1862) --moderate: mod_dav crash (CVE-2013-1896) Fixed in Apache httpd 2.2.27 low: mod_log_config crash (CVE-2014-0098) --moderate: mod_dav crash (CVE-2013-6438) Fixed in Apache httpd 2.2.29 important: mod_cgid denial of service (CVE-2014-0231) low: HTTP Trailers processing bypass (CVE-2013-5704) --moderate: mod_deflate denial of service (CVE-2014-0118) --moderate: mod_status buffer overflow (CVE-2014-0226) Fixed in Apache httpd 2.2.31 low: HTTP request smuggling attack against chunked request parser (CVE-2015-3183) Fixed in Apache httpd 2.2.32 important: Apache HTTP Request Parsing Whitespace Defects (CVE-2016-8743) --moderate: mod_userdir CRLF injection (CVE-2016-4975) n/a: HTTP_PROXY environment variable "httpoxy" mitigation (CVE-2016-5387) Fixed in Apache httpd 2.2.34 important: Uninitialized memory reflection in mod_auth_digest (CVE-2017-9788) important: ap_get_basic_auth_pw() Authentication Bypass (CVE-2017-3167) important: mod_ssl Null Pointer Dereference (CVE-2017-3169) important: ap_find_token() Buffer Overread (CVE-2017-7668) important: mod_mime Buffer Overread (CVE-2017-7679) Not fixed in Apache httpd 2.2 *apache httpd 2.2已中止更新 其中個別漏洞是能夠形成源碼泄露的。 最新版本: apache ver.2.4.37 openssl ver.1.1.1
以上就是HTTPD2.2版本的風險,我我的也有基於低版本的修復,可是它並不安全,爲防止某些人重蹈覆轍,強烈建議升級到2.4.37,版本於2018年10月23日發佈,更新的版本請參照我新的博客,我將會持續跟蹤,分享。測試
Apache HTTPD 2.4.37 安全配置ui
<IfModule http2_module>
LogLevel http2:info
</IfModule>
——涉及文件:httpd.conf,httpd-ssl.conf加密
如何安裝(基於Centos7)
前置依賴:
<
>
./configure --prefix=/opt/apache/apr-1.6.5 make make install ./configure --prefix=/opt/apache/apr-iconv-1.2.2 --with-apr=/opt/apache/apr-1.6.5 make make install ./configure --prefix=/opt/apache/apr-util-1.6.1 --with-apr=/opt/apache/apr-1.6.5 --with-apr-iconv=/opt/apache/apr-iconv-1.2.2/bin/apriconv make make install *// apr-util-1.6.1 報錯 *// xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory 解決方法 yum install expat-devel *//ps:expat-devel-2.1.0-10.el7_3.x86_64 最新版是2.4.4 ./configure --prefix=/opt/apache/pcre-8.42 --with-apr=/opt/apache/apr-1.6.5/bin/apr-1-config make && make install ./configure --prefix=/opt/apache/httpd-2.4.37 --with-pcre=/opt/apache/pcre-8.42 --with-apr=/opt/apache/apr-1.6.5/bin/apr-1-config --with-apr-util=/opt/apache/apr-util-1.6.1 --with-apr-iconv=/opt/apache/apr-iconv-1.2.2/bin/apriconv --enable-so --enable-ssl --enable-mods-shared=all --enable-cache --enable-disk-cache --enable-file-cache --enable-mem-cache make && make install *//OpenSSL v1.1.1升級詳見 *//https://blog.csdn.net/evkj2013/article/details/82933079
我增長/修改了哪些配置
#conf/httpd.conf
#配置插件 <IfModule reqtimeout_module> RequestReadTimeout header=5-40,MinRate=500 body=20,MinRate=500
#用來解決 SlowHTTPDenialofServiceAttack 即超時慢DOS攻擊 </IfModule> <IfModule mod_headers.c>
#HSTS只能經過https請求訪問 Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
#配置只有同一個域才能訪問資源,用來解決點擊劫持 Header always set X-Frame-Options SAMEORIGIN
#script 和 styleSheet 元素會拒絕包含錯誤的 MIME 類型的響應 Header always set X-Content-Type-Options nosniffs
#XSS注入防範的安全頭 Header always set X-XSS-Protection "1; mode=block" </IfModule> # Configure mod_proxy_html to understand HTML4/XHTML1 <IfModule proxy_html_module> Include conf/extra/proxy-html.conf </IfModule> # Secure (SSL/TLS) connections include conf/extra/httpd-ssl.conf<IfModule ssl_module>
#增長的SSL配置 SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule> #禁用 Trace 跟蹤 TraceEnable off
#配置服務器生成頁面的頁腳 ServerSignature Off
#隱藏版本號 ServerTokens Prod #啓動重定向 #RewriteEngine on #RewriteCond %{SERVER_PORT} !^443$ #RewriteRule ^/?(.*)$ https://%{SERVER_NAME}/$1 [L,R]
這些安全頭有什麼做用,將挖一個坑。會增長在未來準備寫的CSP以前發佈
Trace是必定要禁用的,由於這個並不安全,爲何不安全將在後續的補全章節展出。
#conf/extra/httpd-ssl.conf
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256!SSLv3:!kRSA:!EXPORT:!ADH SSLProxyCipherSuite HIGH:MEDIUM:!SSLv3:!kRSA //在這裏我禁用了!EXPORT(不多人注意這裏,要加的)還有!ADH(就是DH)等套件由於過期了,我在這裏採用了ECDHE套件,牢固,十分安全。 SSLHonorCipherOrder on
#禁止SSL2&3,TLS1&1.1 SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLProxyProtocol all -SSLv3 #SSL 的session設置
SSLSessionTickets off SSLSessionCache "shmcb:/opt/apache/httpd-2.4.37/logs/ssl_scache(512000)" SSLSessionCacheTimeout 300
#OSCP SSLUseStapling On SSLStaplingResponderTimeout 5 SSLStaplingReturnResponderErrors off SSLStaplingCache "shmcb:/opt/apache/httpd-2.4.37/logs/ssl_stapling(32768)" SSLStaplingStandardCacheTimeout 3600 SSLStaplingErrorCacheTimeout 600 SSLEngine on //下面是密鑰的配置,每一個人都不同,不粘了
個人套件依然存在CBC(就是對稱密碼),因此有概率被lucky 13(概率有多高不知道,你們能夠試試),除非你不用CBC,追求最佳的安全,不然這些就夠了。其餘的配置一切安全。
1024和2048會致使響應慢
本HTTPD採用了TLS1.2(1.3沒開)。
如何去測試配置如今是否安全?
https://testssl.sh/
我不知道怎麼使用
testssl.sh <hostname>/<URI>
我須要一份報告
testssl.sh <options> <URI> | aha >output.html
啥是URI
你暫時,在這裏徹底能夠理解成URL