<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pravin Gyawali</title>
    <description>The latest articles on DEV Community by Pravin Gyawali (@pypravin).</description>
    <link>https://dev.to/pypravin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2992656%2Fbcf0a1f6-affb-485d-84da-62eb05f8d9cc.jpeg</url>
      <title>DEV Community: Pravin Gyawali</title>
      <link>https://dev.to/pypravin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pypravin"/>
    <language>en</language>
    <item>
      <title>What security headers actually stop (and which ones don't matter much)</title>
      <dc:creator>Pravin Gyawali</dc:creator>
      <pubDate>Sun, 09 Aug 2026 16:27:15 +0000</pubDate>
      <link>https://dev.to/pypravin/what-security-headers-actually-stop-and-which-ones-dont-matter-much-13j5</link>
      <guid>https://dev.to/pypravin/what-security-headers-actually-stop-and-which-ones-dont-matter-much-13j5</guid>
      <description>&lt;p&gt;Six HTTP response headers get recommended in almost every "harden your site" checklist, usually as a flat list with no explanation of what each one actually defends against. Some of them close a real, exploitable gap. A couple are closer to defense-in-depth. Here's what each one does, concretely, and what it doesn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strict-Transport-Security (HSTS)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it stops:&lt;/strong&gt; SSL-stripping. Without HSTS, every visit to your site starts as a plain HTTP request that your server then redirects to HTTPS — and that first request is interceptable on a hostile network (open WiFi, a compromised router). An attacker in that position can strip the redirect and keep the victim on HTTP indefinitely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it doesn't do:&lt;/strong&gt; protect the very first visit, unless you've submitted the domain to browsers' HSTS preload list — &lt;code&gt;max-age&lt;/code&gt; only kicks in after the browser has already seen the header once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reference: &lt;a href="https://datatracker.ietf.org/doc/html/rfc6797" rel="noopener noreferrer"&gt;RFC 6797&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Content-Security-Policy (CSP)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it stops:&lt;/strong&gt; the &lt;em&gt;execution&lt;/em&gt; half of XSS. Even if an attacker manages to inject a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag or an inline event handler into your page, a well-scoped CSP stops the browser from running it, because the injected content doesn't come from an allow-listed origin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it doesn't do:&lt;/strong&gt; stop the injection itself — CSP is a blast-radius control, not an input-sanitization substitute. It's also the header most likely to break something in production if you deploy it without a &lt;code&gt;Report-Only&lt;/code&gt; phase first.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy" rel="noopener noreferrer"&gt;MDN — Content-Security-Policy&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  X-Frame-Options
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it stops:&lt;/strong&gt; clickjacking — an attacker embedding your login/payment/admin page in an invisible iframe on their own site and tricking a user into clicking something that actually submits on your page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it doesn't do:&lt;/strong&gt; anything CSP's &lt;code&gt;frame-ancestors&lt;/code&gt; directive can't already do better (allow-list specific origins instead of an all-or-nothing rule). X-Frame-Options is the older, blunter tool, but it's still worth sending since &lt;code&gt;frame-ancestors&lt;/code&gt; support isn't universal.&lt;/p&gt;

&lt;p&gt;Reference: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options" rel="noopener noreferrer"&gt;MDN — X-Frame-Options&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  X-Content-Type-Options
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it stops:&lt;/strong&gt; MIME-sniffing — some browsers historically inspected response bytes and guessed the content type even when the server's &lt;code&gt;Content-Type&lt;/code&gt; disagreed, which let an uploaded "image" get reinterpreted and executed as HTML/JS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it doesn't do:&lt;/strong&gt; matter as much as it used to. Modern browsers sniff far less aggressively. It's still a one-line, zero-downside header with no legitimate reason to skip.&lt;/p&gt;

&lt;h2&gt;
  
  
  Referrer-Policy
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it stops:&lt;/strong&gt; leaking your URLs (which often carry session tokens, search terms, or internal IDs in the query string) to third-party sites and analytics tools via the &lt;code&gt;Referer&lt;/code&gt; header.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it doesn't do:&lt;/strong&gt; matter much if your URLs never carry sensitive query-string data in the first place — but you usually can't guarantee that across every page and every future contributor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Permissions-Policy
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What it stops:&lt;/strong&gt; a compromised third-party script or malicious iframe ad from invoking a permission prompt (camera, microphone, geolocation) for a capability your page never intended to use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it doesn't do:&lt;/strong&gt; fix a vulnerability directly — it's defense-in-depth, which is also why it's usually the lowest-severity item on a scan report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking your own site
&lt;/h2&gt;

&lt;p&gt;I maintain &lt;a href="https://nivaronix.com" rel="noopener noreferrer"&gt;Nivaronix&lt;/a&gt;, a free scanner that checks all six of these (plus SSL/TLS, DNS/DNSSEC/CAA, and SPF/DMARC) and tells you exactly which are missing and why. No signup needed for a single scan. Full breakdown of each header, with server config snippets for Nginx/Apache/Cloudflare, is in the &lt;a href="https://nivaronix.com/guides/security-headers" rel="noopener noreferrer"&gt;security headers guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To be clear about what it &lt;em&gt;isn't&lt;/em&gt;: it's a configuration/posture checker, not a penetration test, and it doesn't do vulnerability/CVE scanning or malware detection. If you want that, you want a different tool — this one's scope is "is your config missing the stuff that stops these specific, well-understood attack classes."&lt;/p&gt;

&lt;p&gt;What's on your own header checklist that I didn't cover here?&lt;/p&gt;

</description>
      <category>backend</category>
      <category>security</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
