[研究]ASP.NET WebForm 網站 HCL AppScan 10.18.0 報告【低】【找到可快取的 SSL 頁面】弱點,如何處理?(一)WebResource.axd 和 ScriptResource.axd
2025-07-10
環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 20
********************************************************************************
URL: https://isg.nat.gov.tw/WebResource.axd
實體: WebResource.axd (Page)
URL: https://isg.nat.gov.tw/ScriptResource.axd
實體: ScriptResource.axd (Page)
風險: 有可能收集 Web 應用程式相關的機密性資訊,如:使用者名稱、密碼、機器名稱及/或機密檔案位置
原因: 瀏覽器可能已快取機密性資訊
修正: 在 SSL 頁面的回應中新增 "Cache-Control: no-store" 和 "Pragma: no-cache" 標頭,以防止快取 SSL 頁面。
********************************************************************************
ASP.NET WebForm 網站 HCL AppScan 10.18.0 報告【找到可快取的 SSL 頁面】弱點,如何處理?
ScriptResource.axd 實際並不存在,網址點選會跳到 Web.Config 中設定 customErrors 指向的網頁,
檢視網頁 Source ,
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Cache-Control" content="no-cache" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>
是有 content="no-cache" 的
敝人註:ChatGPT提供的某些方法,實際測試有問題,Deploy 後網站就死掉,其中對敝人可用的方法是 Global.asax.cs 增加
protected void Application_BeginRequest(object sender, EventArgs e)
{
string path = Request.Path.ToLower();
if (path.EndsWith("webresource.axd") || path.EndsWith("scriptresource.axd"))
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(-1));
Response.AppendHeader("Pragma", "no-cache");
}
}
|
以 HCL AppScan再次測試,弱點不存在,表示成功了。
如何手動複測? ChatGPT 說可以用
curl -k -I https://網域/WebResource.axd
curl -k -I https://網域/ScriptResource.axd
去檢測回應是否有 Pragma: no-cache",這是錯誤的;因為最後回應的是 customErrors 指向的 .aspx 網頁,而不是 .axd,是否可用 Burp Suite敝人就沒有研究了。
你遇到的 HCL AppScan 弱點【找到可快取的 SSL 頁面】是指 HTTPS 頁面回應中允許快取(如 Cache-Control: public),可能導致機密資料被快取於中介代理(proxy)或使用者裝置中。
********************************************************************************
(完)
相關

沒有留言:
張貼留言