What security headers should a web application return?
Short answer
Key headers: Strict-Transport-Security (force HTTPS), Content-Security-Policy (limit where scripts and content load from), X-Content-Type-Options: nosniff, X-Frame-Options / CSP frame-ancestors (stop clickjacking), Referrer-Policy and Permissions-Policy — plus secure cookie flags. ZAP's baseline scan flags missing ones.
Recommended values
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Content-Security-Policy: default-src 'self'; script-src 'self'; frame-ancestors 'none'
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
Set-Cookie: session=...; Secure; HttpOnly; SameSite=Lax
Setting them centrally (Nginx / Ingress)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
server_tokens off;
For ingress-nginx, use a configuration-snippet annotation or global ConfigMap headers; for Spring use Spring Security headers; for Express use helmet.
Caution
A strict CSP can break the front end — roll it out with Content-Security-Policy-Report-Only first.
What to say in the interview
"HSTS, CSP, nosniff, frame protection, Referrer-Policy and Permissions-Policy, plus Secure, HttpOnly and SameSite cookies. We set most of them centrally at the Ingress or reverse proxy, roll out CSP in report-only first, and ZAP baseline verifies they're present."