TMAegisBeta
更多 iis 规则

Microsoft IIS

TMA-IIS-3.7

Ensure 'cookies' are set with HttpOnly attribute

中级别 1自动化iis

说明

The httpOnlyCookies attribute of the httpCookies node determines if IIS will set the HttpOnly flag on HTTP cookies it sets. The HttpOnly flag indicates to the user agent that the cookie must not be accessible by client-side script (i.e document.cookie). It is recommended that the httpOnlyCookies attribute be set to true. httpCookies httpOnlyCookies must be true in the root web.config and every site. PowerShell 5.1 with the WebAdministration module; run elevated.

检查方式

审计方法: Shell 命令

shell
Import-Module WebAdministration -ErrorAction Stop; $paths = @('MACHINE/WEBROOT') + @(Get-Website | ForEach-Object { "IIS:\Sites\$($_.Name)" }); $bad = @($paths | Where-Object { $c = Get-WebConfiguration -Filter 'system.web/httpCookies' -PSPath $_; $c.httpOnlyCookies -ne $true }); if ($bad.Count -eq 0) { 'compliant' } else { 'noncompliant' }
预期输出
compliant

修复方式

修复方法: 操作指南或基础设施补丁

Add <httpCookies httpOnlyCookies="true" /> inside <system.web> of each application web.config.

属性

操作系统
任意
标签
iissession
参考
CIS Microsoft IIS 10 Benchmark v1.2.1 - 3.7 Ensure 'cookies' are set with HttpOnly attribute

检查本机

请在您有权审计的机器上运行此命令。扫描为只读操作。

shell
tmaegis scan --target iis