Cookie中的HttpOnly属性值规定了Cookie是否可以通过客户端脚本进行访问,能起到保护Cookie安全的作用,如果在Cookie中没有将HttpOnly属性设置为true,那么攻击者就可以通过程序(JS脚本、Applet等)窃取用户Cookie信息,增加攻击者的跨站脚本攻击威胁。窃取的Cookie中可能包含标识用户的敏感信息,如ASP.NET会话标识等,攻击者借助窃取的Cookie达到伪装用户身份或获取敏感信息的目的,进行跨站脚本攻击等。

对于敏感业务,如登录、转账、支付等,需要使用HTTPS来保证传输安全性,如果会话Cookie缺少secure属性,Web应用程序通过SSL向服务器端发送不安全的Cookie,可能会导致发送到服务器的Cookie被非HTTPS页面获取,造成用户Cookie信息的泄露。如果启用了secure属性,浏览器将仅在HTTPS请求中向服务端发送cookie内容。

<session-config> <cookie-config> <secure>true</secure> </cookie-config> </session-config> |
| <httpCookies requireSSL="true" /> |
| session.cookie_secure = True |
| void session_set_cookie_params ( int $lifetime [, string $path [, string $domain [, bool $secure= false [, bool $HttpOnly= false ]]]] ) |
| bool setcookie ( string $name [, string $value? [, int $expire= 0 [, string $path [, string $domain [, bool $secure= false [, bool $HttpOnly= false ]]]]]] ) |
<wls:session-descriptor> <wls:cookie-secure>true</wls:cookie-secure> <wls:cookie-http-only>true</wls:cookie-http-only> </wls:session-descriptor> |
因Web应用程序编程或配置不安全,导致HTTP响应缺少“Content-Security-Policy”头,可能产生跨站脚本攻击等隐患,可能会收集有关Web应用程序的敏感信息,如用户名、密码、卡号或敏感文件位置等。

<system.webServer> <httpProtocol>? <customHeaders> <add name="Content-Security-Policy" value="default-src 'self';"/> </customHeaders> </httpProtocol> </system.webServer> |
| <meta http-equiv=”Content-Security-Policy” content=”default-src ‘self’”/> |
因Web应用程序编程或配置不安全,导致缺少“Content-Security-Policy”头,可能产生偷渡式下载攻击等隐患。

| <add name="X-Content-Type-Options" value="nosniff"/> |
| <meta http-equiv=”X-Content-Type-Options” content=”nosniff” /> |
因Web应用程序编程或配置不安全,导致缺少“Content-Security-Policy”头,可能产生跨站脚本攻击等隐患。

| <add name="X-XSS-Protection" value="1;mode=block"/> |
| <meta http-equiv=”X-XSS-Protection” content=”1;mode=block” /> |
因Web应用程序编程或配置不安全,导致缺少 HTTP Strict-Transport-Security 头。为了用户体验,有些网站允许使用HTTPS和HTTP访问,当用户使用HTTP访问时,网站会返回给用户一个302重定向到HTTPS地址,后续访问都使用HTTPS协议传输,但这个302重定向地址可能会被劫持篡改,被改成一个恶意的或者钓鱼HTTPS站点,导致敏感信息如用户名、密码、卡号或敏感文件位置泄露等风险。

页面未能设置适当的X-Frame-Options或Content-Security-Policy HTTP头,则攻击者控制的页面可能将其加载到iframe中,导致点击劫持攻击,此类攻击属于一种视觉欺骗手段,主要实现方式有两种:一是攻击者将一个透明的iframe覆盖在一个网页上,诱使用户在该页面上进行操作,那么用户就在不知情的情况下点击透明的iframe页面;二是攻击者使用一张图片覆盖在网页,遮挡网页原有位置的含义。

| <add name="X-Frame-Options" value="SAMEORIGIN"/> |
| <meta http-equiv=”X-Frame-Options” content=”SAMEORIGIN” /> |
Web服务器或应用服务器以不安全的方式进行配置,导致启用了WebDAV和不安全的HTTP方法,不安全的HTTP方法一般包括:TRACE、PUT、DELETE、COPY等,可能会造成攻击者在Web服务器上上传、修改或删除Web页面、脚本和文件的隐患。

#单独禁用Trace方法: RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) RewriteRule .* - [F] 单独禁用Options方法: RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(OPTIONS) RewriteRule .* - [F] 同时禁用Trace方法和Options方法: RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS) RewriteRule .* - [F]<VirtualHost *:80> DocumentRoot "D:\wwwroot" ServerName www.abc.com ServerAlias abc.com <Directory "D:\wwwroot"> Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted RewriteEngine on RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS) RewriteRule .* - [F] </Directory></VirtualHost> |
if ($request_method !~* GET|POST) { return 403; } |
<security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> <http-method>PUT</http-method> <http-method>DELETE</http-method> <http-method>HEAD</http-method> <http-method>OPTIONS</http-method> <http-method>TRACE</http-method> </web-resource-collection> <auth-constraint> </auth-constraint> </security-constraint> |
<system.webServer> <security> <requestFiltering> <verbs allowUnlisted="false"> <add verb="GET" allowed="true"/> <add verb="POST" allowed="true"/> </verbs> </requestFiltering> </security></system.webServer> |
因Web服务器、应用服务器配置不安全,导致响应报文的响应头中"X-Powered-By"字段泄露服务器信息,攻击者可以通过获取服务器版本信息,收集相关漏洞,进行特定的攻击。

<configuration> <location> <system.webServer> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> </customHeaders> </httpProtocol> </system.webServer> </location> </configuration> |
location / { proxy_hide_header X-Powered-By; } |
因Web服务器、应用服务器配置不安全,导致响应报文的响应头中"Server"字段泄露服务器信息,攻击者可以通过获取服务器版本信息,收集相关漏洞,进行特定的攻击。

<system.webServer> <modules> <add name="CustomHeaderModule" type="StrongNamespace.HttpModules.CustomHeaderModule" /> |