Unit 3: Headers · Lesson 2 of 5 · 18 min

Security headers

A short list of headers that make the browser stricter, and how to review them.

mission

You are
The analyst reviewing the shop.
Situation
The shop's developers ask which security headers they are missing and what values to set.
Goal
Check the shop's pages against a known-good list.
Hand in
A gap list with the exact value to set for each header.

What each header defends

  1. Content-Security-PolicyWhich scripts and frames may run
  2. Strict-Transport-SecurityNever use plain HTTP for this site again
  3. X-Frame-Options or frame-ancestorsWho may put the page in a frame
  4. X-Content-Type-OptionsDo not guess file types
  5. Referrer-PolicyHow much of the URL leaks to other sites

The baseline

CommandWhat it does
Strict-Transport-SecurityHTTPS only for this site. Aim for max-age=31536000
Content-Security-PolicyWhere scripts, styles and frames may come from
X-Content-Type-Optionsnosniff: trust Content-Type, do not guess
X-Frame-OptionsDENY or SAMEORIGIN. CSP frame-ancestors is the modern form
Referrer-Policystrict-origin-when-cross-origin is a good default
ServerLess version detail gives scanners less to match
01

Read the shop page's security headers

learner@web-lab
curl -sI http://127.0.0.1:8000/shop | grep -iE '^(content-security|x-frame|referrer|x-content)'
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Referrer-Policy: no-referrer-when-downgrade
Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.example.com; object-src 'none'; frame-ancestors 'none'

you should see Four security headers. The Referrer-Policy is weaker than the baseline.

02

Read the home page

learner@web-lab
curl -sI http://127.0.0.1:8000/ | grep -ciE '^(content-security|x-frame|referrer)'
0

you should see 0. The home page has no policy, no framing rule and no referrer rule.

03

Look for HSTS

HSTS only counts on HTTPS responses. Over plain HTTP a browser ignores it.

learner@web-lab
curl -sI --cacert certs/shop-ca.crt https://shop.internal:8443/ | grep -i strict
Strict-Transport-Security: max-age=300

you should see max-age=300: five minutes instead of a year.

04

Check the help page too

learner@web-lab
curl -sI http://127.0.0.1:8000/help | grep -iE '^(content-security|x-frame|referrer|x-content)'
X-Content-Type-Options: nosniff
Content-Security-Policy: default-src 'self'; connect-src 'self' https://api.example-ai.com

you should see A CSP and nosniff, but no framing or referrer header. Headers are set per page, so check every page that matters.

Referrer-Policy

What /shop sends
Referrer-Policy: no-referrer-when-downgrade

Full URLs, query strings included, go to every HTTPS site you link to.

Baseline
Referrer-Policy: strict-origin-when-cross-origin

Other sites only learn the origin, never the path or query.

What a defender takes away

  1. 1Check security headers per route, starting with sign-in and personal pages.
  2. 2HSTS needs a long max-age to protect anything.
  3. 3Recommend exact values, not just header names.

Questions

0 of 3 solved

Answer each one from what you find on your lab machine.