From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../web/http/headers/x-xss-protection/index.html | 97 ++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 files/pt-br/web/http/headers/x-xss-protection/index.html (limited to 'files/pt-br/web/http/headers/x-xss-protection') diff --git a/files/pt-br/web/http/headers/x-xss-protection/index.html b/files/pt-br/web/http/headers/x-xss-protection/index.html new file mode 100644 index 0000000000..0cf075c016 --- /dev/null +++ b/files/pt-br/web/http/headers/x-xss-protection/index.html @@ -0,0 +1,97 @@ +--- +title: X-XSS-Protection +slug: Web/HTTP/Headers/X-XSS-Protection +tags: + - HTTP + - Referencia + - Segurança + - XSS + - cabeçalho +translation_of: Web/HTTP/Headers/X-XSS-Protection +--- +
{{HTTPSidebar}}
+ +

O cabeçalho de resposta HTTP X-XSS-Protection é uma funcionalidade do Internet Explorer, Chrome e Safari que impede páginas de carregarem quando eles detectam ataques de scripting entre sites ({{Glossary("XSS")}}) refletidos. Apesar destas proteções serem majoritariamente desnecessárias em navegadores modernos em sites utilizando uma forte {{HTTPHeader("Content-Security-Policy")}} que desabilita o uso de JavaScript inline ('unsafe-inline'), eles ainda podem oferecer proteções para usuários de navegadores mais antigos que ainda não suportam {{Glossary("CSP")}}.

+ +
+ + +

Isso significa que se você não precisa dar suporte para navegadores legado, é recomendado que você use Content-Security-Policy sem permitir scripts unsafe-inline ao invés disso.

+
+ + + + + + + + + + + + +
Tipo de cabeçalho{{Glossary("Response header")}}
{{Glossary("Forbidden header name")}}não
+ +

Sintaxe

+ +
X-XSS-Protection: 0
+X-XSS-Protection: 1
+X-XSS-Protection: 1; mode=block
+X-XSS-Protection: 1; report=<reporting-uri>
+
+ +
+
0
+
Desabilita filtragem XSS.
+
1
+
Habilita filtragem XSS (geralmente padrão em navegadores). Se um ataque de scripting entre sites é detectado, o navegador irá higienizar a página (remover as partes inseguras).
+
1; mode=block
+
Habilita filtragem XSS. Ao invés de higienizar a página, o navegador irá impedir a renderização da página em que o ataque foi detectado.
+
1; report=<reporting-URI> (Chromium somente)
+
Habilita filtragem XSS. Se o ataque de scripting entre sites é detectado, o navegador irá higienizar a página e reportar a violação. Isso utiliza a funcionalidade da diretiva CSP {{CSP("report-uri")}} para enviar o relatório.
+
+ +

Exemplos

+ +

Bloqueia páginas de carregarem quando elas detectam ataques XSS refletidos:

+ +
X-XSS-Protection: 1; mode=block
+ +

PHP

+ +
header("X-XSS-Protection: 1; mode=block");
+ +

Apache (.htaccess)

+ +
<IfModule mod_headers.c>
+  Header set X-XSS-Protection "1; mode=block"
+</IfModule>
+ +

Nginx

+ +
add_header "X-XSS-Protection" "1; mode=block";
+ +

Especificações

+ +

Não faz parte de nenhuma especificação ou rascunho.

+ +

Compatibilidade de navegador

+ + + +

{{Compat("http.headers.X-XSS-Protection")}}

+ +

Veja também

+ + -- cgit v1.2.3-54-g00ecf