☼
⌃
☰

HTTP Security Headers

Table of Contents

HTTP response headers instruct the browser on how to handle content, origins, and resources. Missing or misconfigured security headers are low-friction findings on every web pentest — they are quick to identify, straightforward to report, and have clear remediations. On the PT1 exam each missing header is a discrete finding with its own severity and remediation.

Related: Web Application Testing Methodology CORS CORS Misconfigurations XSS Web Security Session Management Testing

1. Enumeration

Always start by pulling the full response header set. Do this on the root path and on at least one authenticated endpoint — headers sometimes differ.

SHELL
# Full headers from root
curl -sI http://$IP/

# Authenticated endpoint
curl -sI http://$IP/api/v1/profile \
  -H "Authorization: Bearer $TOKEN"

# Follow redirects (important — HTTPS redirect may drop headers)
curl -sIL http://$IP/

In Burp Suite: send any request to Repeater, observe the Response headers tab. Check both HTTP and HTTPS responses — headers on the HTTP response are separate from the HTTPS response.

2. Headers Reference

2.1 Content-Security-Policy (CSP)

Controls which sources the browser may load scripts, styles, images, and other resources from. The primary defence against XSS.

Missing CSP: No restriction on resource loading — XSS payloads can load external scripts freely.

Weak CSP patterns to note:

Pattern Issue
script-src 'unsafe-inline' Inline scripts allowed — defeats XSS protection
script-src 'unsafe-eval' eval() allowed — widens XSS surface
script-src * Any origin allowed — no restriction
default-src 'none' only Good baseline — check other directives
SHELL
curl -sI http://$IP/ | grep -i "content-security-policy"

Secure example:

Content-Security-Policy: default-src 'self'; script-src 'self';
  object-src 'none'; frame-ancestors 'none'

Severity if absent: Medium (High if XSS is also present — the two chain into a more severe finding; note the dependency in your report).

2.2 Strict-Transport-Security (HSTS)

Instructs the browser to only communicate with the server over HTTPS for a defined period. Prevents SSL stripping attacks.

SHELL
curl -sI https://$IP/ | grep -i "strict-transport-security"

Secure example:

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Directive Purpose
max-age Seconds the browser enforces HTTPS (1yr = 31536000)
includeSubDomains Applies to all subdomains
preload Browser hardcodes HTTPS before first visit

Weak patterns:

  • max-age below 180 days — too short to be effective
  • Missing includeSubDomains — subdomains can still be stripped

Severity if absent: Low–Medium. Escalates if the app transmits credentials over HTTP.

2.3 X-Frame-Options

Prevents the page from being loaded in an iframe — the primary defence against clickjacking.

SHELL
curl -sI http://$IP/ | grep -i "x-frame-options"
Value Meaning
DENY No framing permitted from any origin
SAMEORIGIN Framing only from the same origin
ALLOW-FROM Deprecated — not supported by modern browsers

Note: CSP frame-ancestors supersedes X-Frame-Options in modern browsers. If CSP is present with frame-ancestors 'none', X-Frame-Options absence is less critical — note this in severity justification.

Severity if absent: Low–Medium. Higher if the application handles sensitive actions (payments, account settings) that could be exploited via clickjacking.

2.4 X-Content-Type-Options

Prevents the browser from MIME-sniffing a response away from the declared Content-Type. Stops certain content injection attacks where an attacker uploads a file that the browser executes as a different type.

SHELL
curl -sI http://$IP/ | grep -i "x-content-type-options"

Correct value — only one valid option:

X-Content-Type-Options: nosniff

Severity if absent: Low. Escalates if the application allows file uploads.

2.5 Referrer-Policy

Controls how much referrer information the browser includes in requests. Without it, navigating from an authenticated page may leak the full URL (including tokens in query strings) to external resources.

SHELL
curl -sI http://$IP/ | grep -i "referrer-policy"
Value Behaviour
no-referrer No referrer sent — most restrictive
strict-origin Origin only, HTTPS → HTTP sends nothing
strict-origin-when-cross-origin Full path same-origin, origin only cross-origin
unsafe-url Full URL always sent — avoid

Severity if absent: Low. Higher if tokens or sensitive IDs appear in URLs.

2.6 Permissions-Policy (formerly Feature-Policy)

Restricts which browser features (camera, microphone, geolocation, payment) the page and embedded iframes can access.

SHELL
curl -sI http://$IP/ | grep -i "permissions-policy"

Secure restrictive example:

Permissions-Policy: camera=(), microphone=(), geolocation=()

Severity if absent: Low — informational on most assessments unless the application has no legitimate need for those features.

2.7 Cache-Control on Sensitive Endpoints

Authenticated API responses should not be cached by browsers or intermediaries. If Cache-Control is missing or permissive on sensitive endpoints, responses may be stored in browser cache or CDN and accessible to subsequent users of a shared system.

SHELL
curl -sI http://$IP/api/v1/profile \
  -H "Authorization: Bearer $TOKEN" \
  | grep -i "cache-control\|pragma\|expires"

Secure value for authenticated endpoints:

Cache-Control: no-store, no-cache, must-revalidate

Severity if absent on authenticated endpoints: Medium.

3. Automated Check

Run all checks in one pass and parse the output:

SHELL
TARGET="http://$IP"

echo "=== Security Header Audit: $TARGET ==="
HEADERS=$(curl -sIL "$TARGET")

for header in \
    "content-security-policy" \
    "strict-transport-security" \
    "x-frame-options" \
    "x-content-type-options" \
    "referrer-policy" \
    "permissions-policy"; do
    result=$(echo "$HEADERS" | grep -i "$header")
    if [ -z "$result" ]; then
        echo "MISSING: $header"
    else
        echo "PRESENT: $result"
    fi
done

Also worth running: https://securityheaders.com (paste the URL — gives an instant graded report useful for validating your manual findings).

4. Severity and Priority Summary

Header Missing Severity Notes
Content-Security-Policy Medium High if XSS present
HSTS Medium Low if app is HTTP-only (no TLS at all)
X-Frame-Options Medium Low if CSP frame-ancestors present
X-Content-Type-Options Low Medium if file upload present
Referrer-Policy Low Medium if tokens in URLs
Permissions-Policy Low / Info Context-dependent
Cache-Control (auth) Medium On authenticated endpoints only

5. Reporting Template

Finding: Missing Security Headers

Severity: Low–Medium (per header, per context above)

Description: The application does not set the following HTTP security headers in its responses: [list headers]. The absence of these headers weakens the browser-level security posture of the application. [For each: one sentence on the specific risk.]

Evidence:

HTTP/1.1 200 OK
Server: Apache/2.4.41
Content-Type: text/html; charset=UTF-8
# No Content-Security-Policy
# No X-Frame-Options
# No X-Content-Type-Options

Remediation: Add the following headers to all HTTP responses via the web server or application configuration:

Content-Security-Policy: default-src 'self'; object-src 'none'; frame-ancestors 'none'
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin

Tips

  • Check headers on both the root path and authenticated API endpoints — they are often configured differently
  • Group all missing headers into a single finding unless the exam specifically asks for individual findings; one finding titled "Missing HTTP Security Headers" with a table listing each is cleaner and more realistic
  • CSP is the highest-value header to understand deeply — knowing what makes a policy weak (unsafe-inline, wildcard sources) is more useful than knowing it exists
  • On a SPA, the Content-Security-Policy on the HTML shell and the API responses are separate — check both; API responses rarely have CSP and rarely need it, but the HTML response should
  • HSTS only appears on HTTPS responses — check with curl -sIL https:// not http://