easm.chUnderstanding your external attack surface

Security headers

Short instructions from your web server to the browser – they protect visitors against clickjacking, injected scripts and unencrypted connections.

1 min read · in plain words and for experts

Diagram
  1. Web server
  2. Headers in the response
  3. Browser enforces rules
  4. Visitors protected

What eam.ch checks

HeaderSeverityRecommendation
Strict-Transport-Securitymediummax-age=31536000, includeSubDomains only when all subdomains have HTTPS
Content-Security-Policymediumenforcing; Report-Only does not count as set
Cookies without Secure/HttpOnlymediumSecure; HttpOnly; SameSite=Lax
X-Frame-Options or CSP frame-ancestorslowDENY or 'none'/'self'
X-Content-Type-Optionslownosniff
Referrer-Policylowstrict-origin-when-cross-origin
Server/X-Powered-By with versionlowhide the version

A website served under several names results in one finding per header (the other names are listed in the evidence). Names with a wrong certificate and mta-sts. are not checked for headers.

Example nginx

add_header Strict-Transport-Security "max-age=31536000" always;
add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
server_tokens off;

PHP: expose_php = Off. Apache: ServerTokens Prod, Header always set … (mod_headers). In Plesk, the “HSTS” switch in SSL It! sets the first header; the others go under “Apache & nginx Settings” → “Additional nginx directives”. Webmail runs separately in Plesk.

Introducing CSP

  1. Start with Content-Security-Policy-Report-Only and evaluate the browser console or a report-to endpoint.
  2. Move inline scripts and styles into files or allow them with a nonce/hash; avoid 'unsafe-inline'.
  3. Then switch to enforcing. Reference: OWASP Secure Headers Project, MDN.

In short

  • Security headers are instructions to the browser.
  • HSTS and CSP are the most important; introduce CSP in monitoring mode first.
  • Hiding version details makes it harder to search for gaps.
  • A few lines of configuration are usually enough.

Check it yourself

Commands to verify on Linux or macOS. Replace ihre-domain.ch with your domain and only check your own systems.

curl -sI https://www.ihre-domain.ch | grep -iE 'strict-transport|content-security|x-frame|x-content-type|referrer-policy'