Ручной тестер одного из наших клиентов отметил, что созданный нами сайт не возвращает правильные заголовки для ответов 302, 500 и 403. Я проверил это, и в Fiddler я вижу, что заголовки, возвращаемые из 302, действительно отличаются от нормального ответа 200. Я проверил наш файл конфигурации и вижу, что все заголовки находятся в файле конфигурации, как и ожидалось.
Почему заголовки разные и что мне нужно сделать, чтобы это исправить?
Ответ от ручного тестера был следующим:
The following HTTP security headers were found to be missing from 403, 302 and 500 responses:
• HTTP Strict Transport Security (HSTS) – The header ensures that supported browsers should only interact with it using HTTPS protocol, rejecting the insecure HTTP protocol, protecting against protocol downgrade attacks and cookie hijacking.
• X-Frame-Options – The header ensures that the browser must not display the transmitted content in frames of other web pages, protecting against Clickjacking attacks.
• X-XSS-Protection – The header will force the browser to enable any available Cross-Site Scripting filter, providing an additional defence against Cross-Site Scripting attacks.
• X-Content-Type-Options – The header will prevent the browser from interpreting files as something else other than what is declared by the content type, which can help protect against some Cross-Site Scripting attacks.
• Referrer Policy – The header governs which referrer information is sent in the Referer header along with requests.
Мой файл веб-конфигурации:
<add name="Vary" value="Accept-Encoding"/>
<add name="X-UA-Compatible" value="IE=edge"/>
<add name="P3P" value="policyref="/w3c/p3p.xml", CP="This is not a privacy policy!""/>
<add name="E-TAG" value=""/>
<add name="Arr-Disable-Session-Affinity" value="True"/>
<add name="Access-Control-Allow-Origin" value="*"/>
<add name="Access-Control-Allow-Methods" value="*"/>
<add name="Access-Control-Allow-Headers" value="*"/>
<add name="Strict-Transport-Security" value="max-age=31536000;includeSubDomains"/>
<add name="Referrer-Policy" value="strict-origin"/>
<add name="x-Content-Type-Options" value="nosniff"/>
<nwebsec>
<httpHeaderSecurityModule xsi:noNamespaceSchemaLocation="NWebsecConfig/HttpHeaderSecurityModuleConfig.xsd" xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<redirectValidation enabled="false" />
<securityHttpHeaders>
<x-Frame-Options policy="Deny" />
<strict-Transport-Security max-age="365" includeSubdomains="true" httpsOnly="true" preload="true" />
<x-Content-Type-Options enabled="true" />
<x-Download-Options enabled="true" />
<x-XSS-Protection policy="FilterEnabled" blockMode="true" />
<content-Security-Policy enabled="false" />
</securityHttpHeaders>
</httpHeaderSecurityModule>
</nwebsec>
и ответ 200 возвращает:
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Frame-Options: Deny
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-XSS-Protection: 1; mode=block
X-UA-Compatible: IE=edge
P3P: policyref="/w3c/p3p.xml", CP="This is not a privacy policy!"
E-TAG: True
Arr-Disable-Session-Affinity: *
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Headers: max-age=31536000;includeSubDomains
Strict-Transport-Security: strict-origin
Referrer-Policy: nosniff
однако 302 возвращает: -
Vary: Accept-Encoding
X-UA-Compatible: IE=edge
P3P: policyref="/w3c/p3p.xml", CP="This is not a privacy policy!"
E-TAG: True
Arr-Disable-Session-Affinity: *
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Headers: max-age=31536000;includeSubDomains
Strict-Transport-Security: strict-origin
Referrer-Policy: nosniff
Мне кажется, что все заголовки x- * отсутствуют?