透過隱藏 IIS 版本號碼增加網站安全性

最近專案又來到尾聲,開始做弱點掃描,發現了一個小問題:
    
Version Disclosure (IIS)
LOW 1
Netsparker identified a version disclosure (IIS) in the target web server's HTTP response.
This information can help an attacker gain a greater understanding of the systems in use and potentially develop further attacks
targeted at the specific version of IIS.
Impact
An attacker might use the disclosed information to harvest specific security vulnerabilities for the version identified
    


就是在 HTTP 回應的 Header 中有包含伺服器軟體名稱和版本資訊,此資訊是 Web 伺服器自動增加的。這些資訊讓使用者知道可能會提供了可利用的漏洞、增加攻擊的風險和可能、造成安全隱患,所以才會建議移除。

要查看可以使用 Windows 下的「命令提示字元」執行:
(PowerShell 的 curl 使用方式不同)

curl -I https://ruyut.app/
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Content-Type: text/html
Server: Microsoft-IIS/10.0
Strict-Transport-Security: max-age=2592000
Date: Wed, 29 Mar 2023 23:59:59 GMT
    

在 IIS 中關閉 Server 資訊

要修改很簡單,顯開啟 IIS ,點選「站台」,再點選「設定編輯器」

在區段中輸入下面路徑:
    
system.webServer/security/requestFiltering
    

將 removeServerHeader 改為 true ,並點選右上角的「套用」

設定完之後再次使用「命令提示字元」測試:
	
curl -I https://ruyut.app/
HTTP/1.1 302 Found
Transfer-Encoding: chunked
Location: https://ruyut.app/Identity/Account/Login?ReturnUrl=%2F
Strict-Transport-Security: max-age=2592000
Date: Wed, 29 Mar 2023 07:05:02 GMT
    

就會發現 Header 中已經沒有 Server 資訊了!

留言