Introduction
Websites face many risks from hackers trying to steal data or cause damage. HTTP security headers help protect websites by telling browsers how to behave safely when handling web pages and data.
Jump into concepts and practice - no test required
Imagine a security guard at a building entrance who checks visitors' IDs, only lets in trusted people, prevents strangers from sneaking in through windows, and controls what information visitors can share about the building. HTTP security headers act like this guard for websites.
┌───────────────────────────────┐ │ HTTP Security Headers │ ├───────────────┬───────────────┤ │ Header Name │ Purpose │ ├───────────────┼───────────────┤ │ CSP │ Allow trusted │ │ │ content only │ ├───────────────┼───────────────┤ │ HSTS │ Force HTTPS │ ├───────────────┼───────────────┤ │ X-Frame-Options│ Block framing │ ├───────────────┼───────────────┤ │ X-Content-Type│ Trust file │ │ -Options │ types │ ├───────────────┼───────────────┤ │ Referrer-Policy│ Control info │ │ │ sharing │ └───────────────┴───────────────┘
Content-Security-Policy: default-src 'self'; img-src https://images.example.com;https://cdn.example.com/pic.jpg?X-Content-Type-Options: nosniff but users report some images are not displaying. What is the most likely cause?