[研究]GCB,IIS 設定「拒絕 TRACE」影響
2025-11-05
********************************************************************************
| 項次 | TWGCB-ID | 類別 | 原則設定名稱 | 說明 | 設定位置 | 設定路徑 | GCB設定值 |
| 30 | TWGCB-04-014-0030 | 要求篩選與其他限制模組 | HTTP TRACE方法 | ▪這項原則設定決定允許或拒絕使用HTTP TRACE方法 ▪HTTP TRACE方法會傳回用戶端提交的HTTP請求內容,攻擊者可利用此方法繞過HttpOnly限制,來存取HTTP標頭中所包含的機敏資訊(如驗證資料或Cookie) ▪預設值為允許 |
伺服器 | IIS管理員\伺服器\IIS\要求篩選\動作\開啟功能\HTTP指令動詞\動作\拒絕指令動詞\輸入「TRACE」 | 拒 絕 |
********************************************************************************
政府組態基準(Government Configuration Baseline,簡稱GCB)
IIS管理員\伺服器\IIS\要求篩選\動作\開啟功能\HTTP指令動詞\動作\拒絕指令動詞\輸入「TRACE」
請問設定 TRACE 後的影響?
Visual Studio 是否無法 Trace 或 Debug ?
Elmah 套件是否無法運作?
其他?
ChatGPT
🔒 一、設定內容
在 IIS 管理員中:
IIS管理員 → 伺服器 → IIS → 要求篩選 → 動作 → 開啟功能 → HTTP 指令動詞 → 拒絕指令動詞 → 輸入 TRACE
或在 applicationHost.config / Web.config 裡等效設定:
<system.webServer>
<security>
<requestFiltering>
<verbs>
<add verb="TRACE" allowed="false" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
|
📘 二、TRACE 是什麼?
HTTP TRACE 方法是一種診斷用指令,讓客戶端要求伺服器「回傳請求的原文」,以檢查中間是否被代理或防火牆修改。
但這也造成安全風險,例如:
- 攻擊者可利用 TRACE 取得 Cookie、Authorization header(跨站追蹤攻擊 XST, Cross Site Tracing)。
- 不常用於一般應用。
👉 因此 GCB、OWASP、CIS Benchmark 都建議停用。
🧠 三、實際影響分析
| 項目 | 是否受影響 | 說明 |
|---|---|---|
| 一般網站運作 (GET/POST) | ❌ 不受影響 | 常見的 HTTP 方法(GET、POST、HEAD)仍可用。 |
| Visual Studio Debug / Trace.axd | ⚠️ 不受影響(但名稱相似而不同) | ASP.NET 的 Trace.axd 與 HTTP TRACE 無關,它使用的是 GET/POST over HTTP。所以即使封鎖 HTTP TRACE,Visual Studio 附加 Debug、System.Diagnostics.Trace、Trace.axd 仍可正常運作。 |
| ELMAH / Logging 套件 | ❌ 不受影響 | ELMAH、Serilog、NLog 等都記錄例外,與 HTTP TRACE 方法無關。照常運作。 |
| 外部掃描工具 (e.g. Burp, Nikto) | ✅ 受影響(正面效果) | TRACE 將被拒絕,安全性掃描會顯示「TRACE disabled」,屬於強化。 |
| WebDAV / Proxy / REST API 測試工具 | ⚠️ 可能受限 | 若自訂工具用到 TRACE 測試 HTTP request headers,會被 IIS 拒絕(回應 405 Method Not Allowed)。 |
🧩 四、回應代碼範例
設定拒絕後:
curl -v -X TRACE https://example.com/
會回:
HTTP/1.1 405 Method Not Allowed
Allow: GET, POST, HEAD, OPTIONS
✅ 五、總結表
| 功能 | 是否影響 | 備註 |
|---|---|---|
| HTTP TRACE 測試工具 | ✅ 無法使用 | |
| Visual Studio 偵錯(F5 / 附加程序) | ❌ 不受影響 | |
| ASP.NET Trace.axd | ❌ 不受影響 | |
| ELMAH / Exception Logging | ❌ 不受影響 | |
| OWASP / GCB 安全性評估 | ✅ 必須停用 | |
| REST API / AJAX 正常傳輸 | ❌ 不受影響 |
********************************************************************************
實際用 curl 測試某網站 TRACE 的狀態
C:\>curl -v -X TRACE https://(略) * Host (略):443 was resolved. * IPv6: (none) * IPv4: (略) * Trying (略):443... * schannel: disabled automatic use of client certificate * ALPN: curl offers http/1.1 * ALPN: server accepted http/1.1 * Connected to (略) ((略)) port 443 * using HTTP/1.x > TRACE / HTTP/1.1 > Host: (略) > User-Agent: curl/8.13.0 > Accept: */* > * Request completely sent off * schannel: server close notification received (close_notify) < HTTP/1.1 200 OK < Content-Type: text/html; charset=UTF-8 < Cache-Control: no-cache < Pragma: no-cache < Expires: 0 < Connection: close < <html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"> <title>Error Page</title></head> <body bgcolor="white"> <h2>網頁出現非預期錯誤The incident ID is: N/A.The Event ID is: (略)</h2> <h2>可能原因: 1626</h2></body></html> * schannel: server indicated shutdown in a prior call * shutting down connection #0 C:\> |
結果被 WAF (網頁應用程式防火牆,Web Application Firewall) 攔截。
****************************************
敝人建議
- 正式環境可考慮設定拒絕TRACE。
- 如果開發機,會用 Burp Suite、REST API測試工具 (例如:Postman) 測試在開發機建立的網站,不要拒絕 TRACE。
(完)


沒有留言:
張貼留言