Web SecurityWeb Security · Lesson 09
Security Headers, TLS & Cookies
Hardening the transport and browser layer.
Video tutorialTrack course · freeCodeCamp
Speed
Transcript & captions
7/7
| Header | Purpose |
|---|---|
| Content-Security-Policy | Restricts script/style/frame sources - kills most XSS |
| Strict-Transport-Security | Forces HTTPS for future visits |
| X-Content-Type-Options: nosniff | Stops MIME sniffing |
| Referrer-Policy | Prevents URL leakage to third parties |
| Permissions-Policy | Disables camera, mic, geolocation by default |
| frame-ancestors | Blocks clickjacking via framing |
A reasonable starting CSPjs
Content-Security-Policy: default-src 'self';
script-src 'self';
style-src 'self' 'unsafe-inline';
img-src 'self' data: https:;
frame-ancestors 'none';
base-uri 'self';- Serve everything over TLS 1.2+ and redirect HTTP to HTTPS.
- Cookies: Secure, HttpOnly, SameSite, minimal scope and lifetime.
- Disable weak ciphers and keep certificates renewed automatically.
- Do not leak server versions in headers or error pages.
Knowledge check
0/2 answeredWhich header most directly reduces XSS impact?
HSTS does what?