跳到主要內容

安全性修正 - OWASP ZAP 常見弱點掃描含修正

安全性修正 - OWASP ZAP 常見弱點掃描含修正

弱點:Secure Apache from Clickjacking with X-FRAME-OPTIONS 編輯 httpd.conf 檔案,並新增下列參數 #Secure Apache from Clickjacking with X-FRAME-OPTIONS Header always append X-Frame-Options SAMEORIGIN
儲存後退出,重啟伺服器
$ service httpd restart
弱點:Incomplete or No Cache-control and Pragma HTTP Header Set
在主目錄下編輯或建立 .htaccess 檔案,並複製貼上下列內容
# DISABLE CACHING
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
</IfModule>
<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
<IfModule mod_headers.c>
FileETag None
Header unset ETag
Header unset Pragma
Header unset Cache-Control
Header unset Last-Modified
Header set Pragma "no-cache"
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
</IfModule>
</FilesMatch>
儲存後退出,重啟伺服器
$ service httpd restart
#弱點:X-Content-Type-Options Header Missing
在主目錄下編輯或建立 .htaccess 檔案,並複製貼上下列內容

Header unset X-Powered-By 
儲存後退出,重啟伺服器

$ service httpd restart

#資料來源請參考:
#https://stackoverflow.com/questions/2661799/removing-x-powered-by
弱點:Secure MIME Types in Apache & Nginx with X-Content-Type-Options
編輯 httpd.conf 檔案並確認 /etc/httpd/conf.modules.d/00-base.conf
裡面的 mod_headers.so 模組是啟用的.
LoadModule headers_module modules/mod_headers.so
並新增下列參數
#Secure MIME Types in Apache & Nginx with X-Content-Type-Options
Header set X-Content-Type-Options nosniff
儲存後退出,重啟伺服器 $ service httpd restart 來源請參考 https://geekflare.com/secure-mime-types-in-apache-nginx-with-x-content-type-options/
#Disable Server Signature on Apache by editing config file
$ vim /etc/httpd/conf/httpd.conf
加入下列敘述
ServerSignature Off
ServerTokens Prod
儲存後退出,重啟伺服器
$ service httpd restart
.httacess 設定檔,這個太好用了,很多安全防護功能都有了
https://gist.github.com/voku/d958041e7b1c19356e721de1eda1e6f8

留言

這個網誌中的熱門文章

安全性修正 - Apache: Disable the HTTP TRACE Method

Apache: Disable the HTTP TRACE Method 編輯 apache 的系統檔( Apache 1.3.34、2.0.55 以後版本) $ vi /etc/httpd/conf/httpd.conf 最下方找空白的地方加入 TraceEnable off 重啟 apache 服務 $ service httpd restart 測試是否正常關閉 $ curl -i -X TRACE http://www._website_.com/ HTTP/1.1 405 Method Not Allowed Date: Wed, 13 Feb 2013 14:30:32 GMT Server: Apache/2.2.15 (CentOS) Allow: Content-Length: 223 Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>405 Method Not Allowed</title> </head><body> <h1>Method Not Allowed</h1> <p>The requested method TRACE is not allowed for the URL /.</p> </body></html>

SSL Labs A+ 2021

可以先參考這篇進行修正,把內容放入 ssl.conf 裡基本上就有 A+  https://blog.camilord.com/2021/02/23/ssllabs-com-how-to-get-a-on-ssl-server-test-as-of-feb-2021/ 再搭配這篇調整 https://zurgl.com/how-to-get-a-100-score-on-ssl-labs-red-hat-centos-7-x-apache-lets-encrypt/

安全性修正 - 調整 SSL 安全性設定含檢測 Rank A+

SSL 相關安全測試含修正 SSL 申請可以透過 SSL For Free 進行申請免費 SSL https://www.sslforfree.com/ 檢測 SSL 憑證安全的十種工具 https://geekflare.com/ssl-test-certificate/#SSL-Labs 如果有使用 VirtualHost 記得加在設定裡就可以 $ vim /etc/httpd/conf/http.conf   <VirtualHost *:80> RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] Alias /cp /var/www/cp/public <Directory /var/www/cp> AllowOverride All </Directory> <Directory /var/www/html> AllowOverride All </Directory> DocumentRoot /var/www/html ServerName www.sakura-home.com.tw </VirtualHost> <VirtualHost *:443> Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;" RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] SSLEngine on SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 ...