【Apache】HTTPD 2.4.37 + OpenSSL 1.1.1 企业级安全配置(含TLS修复)
我为什么要写这一篇稿子?
为了避免更多的运维、开发者没能实现企业的信息安全,我将共享出我个人的HTTPD的安全修复(2.2和2.4差不太多就看2.4就好)
起因:我为某M工作,但因某M和testin合作,结果他们跑个脚本在安全上检测到
SlowHTTPDenialofServiceAttack(解决方案是reqtimeout_module,下面我就不写了)
不安全的http
poodle
sweet32
中间件漏洞:
响应包版本泄露
【顺便一提,这些问题我早知道了,他们的修复建议并没什么用,依然是CV大法】
首先我们来看看2.2有哪些风险
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 安全配置
#增加了httpd对Trace的限制
<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 </IfModule> <IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" Header always set X-Frame-Options SAMEORIGIN Header always set X-Content-Type-Options nosniffs 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 # # Note: The following must must be present to support # starting without SSL on platforms with no /dev/random equivalent # but a statically compiled-in mod_ssl. # <IfModule ssl_module> 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]
我为什么增加了安全头?这些安全头有什么作用?作为萌新的你可能不懂,但我懒得写,需要的话请在我博客后面留言我考虑一下加上。
Trace是一定要禁用的,因为这个并不安全,详见其他人的博客(我嫌占篇幅),增加ssl时请记得load,我想其他人已经替你做了。
#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 SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 SSLProxyProtocol all -SSLv3 SSLSessionTickets off SSLSessionCache "shmcb:/opt/apache/httpd-2.4.37/logs/ssl_scache(512000)" SSLSessionCacheTimeout 300 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,追求最佳的安全,否则这些就够了。其他的配置一切安全
采用了TLS1.2(1.3没开)。
如何去测试配置现在是否安全?
https://testssl.sh/
我不知道怎么使用
testssl.sh <hostname>/<URI>
我需要一份报告
testssl.sh <options> <URI> | aha >output.html
啥是URI
你暂时,在这里完全可以理解成URL