{"id":229229,"date":"2023-12-25T00:18:18","date_gmt":"2023-12-24T16:18:18","guid":{"rendered":"https:\/\/www.idc.net\/help\/229229\/"},"modified":"2023-12-25T00:18:18","modified_gmt":"2023-12-24T16:18:18","slug":"iis%e5%ae%89%e5%85%a8%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8x-xss-protection%e5%a4%b4%e9%83%a8%e5%90%af%e7%94%a8xss%e8%bf%87%e6%bb%a4","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/229229\/","title":{"rendered":"IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-XSS-Protection\u5934\u90e8\u542f\u7528XSS\u8fc7\u6ee4"},"content":{"rendered":"<p><title id=\"iis%e5%ae%89%e5%85%a8%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8x-xss-protection%e5%a4%b4%e9%83%a8%e5%90%af%e7%94%a8xss%e8%bf%87%e6%bb%a4-GosieiXfID\">IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-XSS-Protection\u5934\u90e8\u542f\u7528XSS\u8fc7\u6ee4<\/title><\/p>\n<h1 id=\"iis%e5%ae%89%e5%85%a8%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8x-xss-protection%e5%a4%b4%e9%83%a8%e5%90%af%e7%94%a8xss%e8%bf%87%e6%bb%a4-GosieiXfID\">IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-XSS-Protection\u5934\u90e8\u542f\u7528XSS\u8fc7\u6ee4<\/h1>\n<p>XSS\uff08\u8de8\u7ad9\u811a\u672c\uff09\u653b\u51fb\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u7f51\u7edc\u5b89\u5168\u5a01\u80c1\uff0c\u5b83\u53ef\u4ee5\u4f7f\u653b\u51fb\u8005\u6ce8\u5165\u6076\u610f\u811a\u672c\u4ee3\u7801\u5230\u7f51\u9875\u4e2d\uff0c\u4ece\u800c\u83b7\u53d6\u7528\u6237\u7684\u654f\u611f\u4fe1\u606f\u6216\u8005\u6267\u884c\u5176\u4ed6\u6076\u610f\u64cd\u4f5c\u3002\u4e3a\u4e86\u4fdd\u62a4\u7f51\u7ad9\u514d\u53d7XSS\u653b\u51fb\u7684\u5f71\u54cd\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528IIS\uff08Internet Information Services\uff09\u7684X-XSS-Protection\u5934\u90e8\u6765\u542f\u7528XSS\u8fc7\u6ee4\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afx-xss-protection%e5%a4%b4%e9%83%a8%ef%bc%9f-GosieiXfID\">\u4ec0\u4e48\u662fX-XSS-Protection\u5934\u90e8\uff1f<\/h2>\n<p>X-XSS-Protection\u5934\u90e8\u662f\u4e00\u79cdHTTP\u54cd\u5e94\u5934\u90e8\uff0c\u7528\u4e8e\u544a\u8bc9\u6d4f\u89c8\u5668\u542f\u7528\u5185\u7f6e\u7684XSS\u8fc7\u6ee4\u5668\u3002\u5f53\u6d4f\u89c8\u5668\u63a5\u6536\u5230\u5e26\u6709X-XSS-Protection\u5934\u90e8\u7684\u54cd\u5e94\u65f6\uff0c\u5b83\u4f1a\u5c1d\u8bd5\u68c0\u6d4b\u5e76\u963b\u6b62\u6f5c\u5728\u7684XSS\u653b\u51fb\u3002<\/p>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8iis%e4%b8%ad%e5%90%af%e7%94%a8x-xss-protection%e5%a4%b4%e9%83%a8%ef%bc%9f-GosieiXfID\">\u5982\u4f55\u5728IIS\u4e2d\u542f\u7528X-XSS-Protection\u5934\u90e8\uff1f<\/h2>\n<p>\u8981\u5728IIS\u4e2d\u542f\u7528X-XSS-Protection\u5934\u90e8\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u6253\u5f00IIS\u7ba1\u7406\u5668\uff0c\u5e76\u9009\u62e9\u8981\u914d\u7f6e\u7684\u7f51\u7ad9\u3002<\/li>\n<li>\u5728\u7f51\u7ad9\u7684\u7279\u6027\u7a97\u53e3\u4e2d\uff0c\u627e\u5230HTTP\u54cd\u5e94\u5934\u90e8\u3002<\/li>\n<li>\u53cc\u51fb\u201c\u6dfb\u52a0\u201d\u6309\u94ae\uff0c\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684HTTP\u54cd\u5e94\u5934\u90e8\u3002<\/li>\n<li>\u5728\u201c\u540d\u79f0\u201d\u5b57\u6bb5\u4e2d\u8f93\u5165\u201cX-XSS-Protection\u201d\uff0c\u5728\u201c\u503c\u201d\u5b57\u6bb5\u4e2d\u8f93\u5165\u201c1; mode=block\u201d\u3002<\/li>\n<li>\u4fdd\u5b58\u66f4\u6539\u5e76\u91cd\u65b0\u542f\u52a8\u7f51\u7ad9\u3002<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u6210\u529f\u5730\u5728IIS\u4e2d\u542f\u7528\u4e86X-XSS-Protection\u5934\u90e8\uff0c\u5e76\u63d0\u9ad8\u4e86\u7f51\u7ad9\u7684\u5b89\u5168\u6027\u3002<\/p>\n<h2 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a0%81-GosieiXfID\">\u793a\u4f8b\u4ee3\u7801<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u5982\u4f55\u5728ASP.NET\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528C#\u542f\u7528X-XSS-Protection\u5934\u90e8\uff1a<\/p>\n<pre><code>\nprotected void Application_BeginRequest(object sender, EventArgs e)\n{\n    HttpContext.Current.Response.Headers.Add(\"X-XSS-Protection\", \"1; mode=block\");\n}\n<\/code><\/pre>\n<p>\u901a\u8fc7\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5168\u5c40`BeginRequest`\u4e8b\u4ef6\u4e2d\u6dfb\u52a0\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u4fdd\u6bcf\u4e2a\u8bf7\u6c42\u90fd\u4f1a\u5305\u542bX-XSS-Protection\u5934\u90e8\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-GosieiXfID\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4f7f\u7528IIS\u7684X-XSS-Protection\u5934\u90e8\uff0c\u6211\u4eec\u53ef\u4ee5\u6709\u6548\u5730\u9632\u6b62XSS\u653b\u51fb\u5bf9\u7f51\u7ad9\u7684\u5f71\u54cd\u3002\u542f\u7528X-XSS-Protection\u5934\u90e8\u662f\u4e00\u79cd\u7b80\u5355\u800c\u6709\u6548\u7684\u5b89\u5168\u63aa\u65bd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u62a4\u7528\u6237\u7684\u654f\u611f\u4fe1\u606f\u548c\u7f51\u7ad9\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u53ef\u9760\u7684\u9999\u6e2f\u670d\u52a1\u5668\u4f9b\u5e94\u5546\uff0c\u540e\u6d6a\u4e91\u662f\u60a8\u7684\u9996\u9009\u3002\u6211\u4eec\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u53ef\u6ee1\u8db3\u60a8\u7684\u5404\u79cd\u9700\u6c42\u3002\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684\u5b98\u7f51\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff1a<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-XSS-Protection\u5934\u90e8\u542f\u7528XSS\u8fc7\u6ee4 IIS\u5b89\u5168\u6559\u7a0b\uff1a\u4f7f\u7528X-XSS-Pro [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-229229","post","type-post","status-publish","format-standard","hentry","category-iis"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/229229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=229229"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/229229\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=229229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=229229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=229229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}