FGF-College-Work / Forum

:beer: Espaço dedicado a discussões e tira dúvida sobre disciplinas e conteúdo tecnológico.
MIT License
13 stars 4 forks source link

Security HTTP Headers to Prevent Vulnerabilities? #231

Open marcialwushu opened 4 years ago

marcialwushu commented 4 years ago

Security is as essential as content and SEO of your website, and thousands of websites get hacked due to misconfiguration or lack of protection. If you are a website owner or security engineer and looking to protect your website from Clickjacking, code injection, MIME types, XSS, etc. attacks then this guide will help you.

In this article, I will talk about various HTTP Headers to implement in multiple web servers, network edge & CDN providers for better website protection.

Notes:

LoadModule headers_module modules/mod_headers.so

Using WordPress?: you may want to try using HTTP Headers plugin, which takes care of these headers and a lot more.

X-XSS-Protection

X-XSS-Protection header can prevent some level of XSS (cross-site-scripting) attacks, and this is compatible with IE 8+, Chrome, Opera, Safari & Android.

Google, Facebook, Github use this header, and most of the penetration testing consultancy will ask you to implement this.

There are four possible ways you can configure this header.

Parameter Value Meaning
0 XSS filter disabled
1 XSS filter enabled and sanitized the page if attack detected
1;mode=block XSS filter enabled and prevented rendering the page if attack detected
1;report=http://example.com/report_URI XSS filter enabled and reported the violation if attack detected

Apache HTTP Server

Add the following entry in httpd.conf of your Apache webserver

Header set X-XSS-Protection "1; mode=block"

Nginx

Add the following in nginx.conf under http block

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

Nginx restart is needed to get this reflected on your web page response header.

Restart the apache to verify


GeekFlare