AttackVector.tech

What are Security Headers?

Security headers protect websites from XSS and clickjacking by setting browser rules. Learn their role and how to test them effectively.

Explain Like I'm 5

Think of your website as a house. Security headers are like different locks and rules you put on the doors and windows to keep unwanted guests out. Each type of security header acts like a specific lock or rule. For example, X-Content-Type-Options is like a doormat that only lets in the right kind of shoes, preventing anything suspicious from sneaking in. X-Frame-Options is like special blinds that stop people from peeking into your house through the windows.

Now, imagine Strict-Transport-Security (HSTS) as a rule that says only trusted people can use the front door securely. Referrer-Policy works like a privacy curtain that controls how much of your house's layout gets shared when someone leaves. Permissions-Policy is like a sign at the gate listing what's allowed inside, such as whether your guests can use their cameras or drones.

This matters because, just like you wouldn't want strangers wandering into your house or taking pictures without permission, you don't want hackers exploiting your website. Security headers help ensure your website is as safe as your home would be with all the right locks and rules in place.

Technical Definition

Definition

Security headers are HTTP response headers that provide an additional layer of security by instructing the browser on how to behave when interacting with a website. They help protect against common web threats like cross-site scripting (XSS), clickjacking, and data sniffing.

How It Works

  • X-Content-Type-Options: Prevents MIME type sniffing by enforcing the declared content type.
  • X-Frame-Options: Stops the page from being framed, protecting against clickjacking.
  • Strict-Transport-Security (HSTS): Forces browsers to use HTTPS, preventing man-in-the-middle attacks.
  • Referrer-Policy: Controls the amount of referrer information sent when navigating from the website.
  • Permissions-Policy: Manages the use of browser features like geolocation, camera, and microphone.
  • X-XSS-Protection: (Deprecated) Was used to enable the browser's built-in XSS protection.
  • Content-Security-Policy (CSP): Restricts resources the browser can load, mitigating XSS and data injection attacks.

Key Characteristics

  • Enforced by Browsers: Security headers are directives communicated from server to client and enforced by the browser.
  • Variety of Protections: They cover different aspects of security, from content type validation to resource loading restrictions.
  • Configurable: Headers can be tailored to suit the specific security needs of the application.

Comparison

HeaderPurposeCurrent Status
X-Content-Type-OptionsPrevents MIME type sniffingActive
X-Frame-OptionsDefends against clickjackingActive
HSTSEnforces HTTPSActive
Referrer-PolicyControls referrer informationActive
Permissions-PolicyManages browser feature permissionsActive
X-XSS-ProtectionLegacy XSS protectionDeprecated
CSPMitigates XSS and data injectionActive

Real-World Example

The CVE-2019-11043 vulnerability in PHP-FPM was mitigated using CSP and HSTS headers to prevent exploitation by ensuring secure resource loading and forcing HTTPS.

Detection & Prevention

  • Test using httpx or browser DevTools to verify active headers.
  • Use OWASP ZAP or Burp Suite for comprehensive security header analysis.
  • Regularly review and update headers according to security best practices.

Common Misconceptions

  • Security Headers Replace Firewalls: They complement, not replace, other security measures.
  • HSTS is Optional: Lack of HSTS can lead to vulnerabilities in HTTPS implementation.
  • CORS and Security Headers are the Same: CORS handles resource sharing, not threats directly.

Related Terms

Keywords

what are Security HeadersSecurity Headers explainedSecurity Headers detectionHTTP securityweb security headersCSPHSTSX-Frame-Options

Ready to scan your site?

AttackVector uses AI agents to find vulnerabilities before attackers do. Start a free scan now.

Start Free Scan