[研究] IIS 10.0 GCB "要求篩選與其他限制模組","允許未列出的副檔名" ,那些副檔名被攔截,實測
2026-01-20
********************************************************************************
Windows Server 從Windows Server 2016開始,IIS為10.0版,後續 Windows Server 2019, Windows Server 2022, Windows Server 2025 也都是 10.0版,大版本號碼相同,小版本可能不同,畫面幾乎相同。
政府組態基準(Government Configuration Baseline,簡稱GCB)
TWGCB-04-014_Microsoft IIS 10政府組態基準說明文件v1.1_1141002
https://www.nics.nat.gov.tw/core_business/cybersecurity_defense/GCB/GCB_Documentation/
| 項次 | TWGCB-ID | 類別 | 原則設定名稱 | 說明 | 設定位置 | 設定路徑 | GCB設定值 |
| 31 | TWGCB-04-014-0031 | 要求篩選與其他限制模組 | 允許未列出的副檔名 | ▪這項原則設定決定是否允許未列出的副檔名在網頁伺服器上被執行 ▪限制網頁伺服器只能執行特定之檔案類型,可提升安全性 ▪在取消勾選「允許未列出的副檔名」後,必須將網站中所有使用到之副檔名(例如:.asax、.cs及.html等)加入允許清單,網頁才能正常運作 | 伺服器 | ▪取消勾選: IIS管理員\伺服器\IIS\要求篩選\動作\開啟功能\動作\編輯功能設定\一般\不勾選「允許未列出的副檔名」 ▪新增允許副檔名: IIS管理員\伺服器\IIS\要求篩選\動作\開啟功能\動作\允許副檔名 | 不允許 |
下圖,程式在 Visual Studio 2019 中執行正常
下圖,
Deploy 後,照 GCB 要求設定「允許未列出的副檔名」為「不允許」
**********
HTTP 錯誤 404.7 - Not Found
要求篩選模組設定為拒絕副檔名。
最有可能的原因:
已為網頁伺服器設定要求篩選,並且明確拒絕此要求的副檔名。
解決方法:
確認 applicationhost.config 和 web.config 中的 configuration/system.webServer/security/requestFiltering/fileExtensions 設定。
詳細錯誤資訊:
模組 RequestFilteringModule
通知 BeginRequest
處理常式 ExtensionlessUrlHandler-Integrated-4.0
錯誤碼 0x00000000
要求的 URL https://localhost:443/
實體路徑 D:\Production\Test443
登入方法 尚未判定
登入使用者 尚未判定
詳細資訊:
此為安全性功能。除非完全瞭解變更的範圍,否則請勿變更此功能。如果要允許要求的副檔名,則移除 configuration/system.webServer/security/requestFiltering/fileExtensions 中拒絕的副檔名。
檢視詳細資訊 »
**********
下圖,上圖點 "檢視詳細資訊"
檢視網站目錄中檔案,添加允許的副檔名
移除 .config、新增 .config (預設有,但為 False,無法變更設定,只好刪除後,新增允許)
新增 .aspx、.axd、.dll、.exe、.pdb、.rsp、.targets
註:.axd 檔案是動態產生的,不在目錄中。
依然失敗,訊息沒有明確說明哪個副檔名被禁止,微軟 Microsoft 官方也沒有公布全部 ASP.NET WebForm 會用的副檔名清冊。
而且還有第三方元件用到的所有檔案的副檔名也是一個問題,看得到的好添加,若動態產生的新副檔名的也難預知。
暫時無解,建議排除。
********************************************************************************
2026-01-16補
實際測試,「網站」層級設定可以覆蓋「伺服器」層級設定。
【「允許未列出的副檔名」設定為「不允許」】
「伺服器」層級設定修改 C:\Windows\System32\inetsrv\config\applicationHost.config
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="false" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
|
「網站」層級修改網站根目錄 Web.Config
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="false" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
|
(看起來相同)
【副檔名白名單】
「伺服器」層級設定修改 C:\Windows\System32\inetsrv\config\applicationHost.config
<requestFiltering>
<fileExtensions allowUnlisted="false">
<add fileExtension=".aspx" allowed="true" />
</fileExtensions>
</requestFiltering>
|
「網站」層級修改網站根目錄 Web.Config
<requestFiltering>
<fileExtensions allowUnlisted="false">
<add fileExtension=".aspx" allowed="true" />
</fileExtensions>
</requestFiltering> |
(看起來相同)
(完)





沒有留言:
張貼留言