Skip to main content
LowSSLOWASP A05:2021CWE-319

How to fix: HSTS declared in a meta tag, where browsers ignore it

The page carries a <meta http-equiv="Strict-Transport-Security"> tag, which browsers ignore. HSTS is only honoured as a real HTTP response header; the meta form has never been implemented by any browser.

Why it matters

The site has no HSTS policy at all, while appearing in a code review to have one. Visitors who type the bare hostname, follow an http:// link, or use an old bookmark still make a cleartext request that an on-path attacker can intercept and strip, which is exactly the first-request window HSTS exists to close.

RFC 6797 section 8.5 is explicit: a UA must ignore an HSTS policy delivered anywhere other than the response header field, precisely because a policy that arrives inside the document body could be injected by the same attacker HSTS is defending against. The meta form appears because http-equiv works for a few other headers (Content-Type, Content-Security-Policy, refresh) and it is reasonable to assume it generalises. It does not.

How to fix it

  1. 1Send Strict-Transport-Security as a real response header from the web server, CDN, or application.
  2. 2Start with a short max-age, confirm nothing on any subdomain still needs plain HTTP, then raise it to 31536000 with includeSubDomains.
  3. 3Remove the meta tag once the header is in place, so nobody later assumes it was doing something.
  4. 4Consider the preload list only after the header has been serving includeSubDomains with a long max-age for a while, since preloading is difficult to reverse.

Code examples

Nginx: HSTS as a header

nginx
server {
    listen 443 ssl;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}

Next.js: HSTS from next.config

JavaScript
module.exports = {
  async headers() {
    return [{
      source: '/:path*',
      headers: [{
        key: 'Strict-Transport-Security',
        value: 'max-age=31536000; includeSubDomains',
      }],
    }];
  },
};

References

Detected automatically by VulnRadar. The check id is ssl-hsts-meta-tag-ineffective, stable across every scan so you can filter or diff on it.

See every ssl check

Questions

How severe is HSTS declared in a meta tag, where browsers ignore it?
VulnRadar rates this low severity in the ssl category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id ssl-hsts-meta-tag-ineffective, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does HSTS declared in a meta tag, where browsers ignore it map to?
It maps to CWE-319. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for hsts declared in a meta tag, where browsers ignore it

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

HSTS declared in a meta tag, where browsers ignore it | VulnRadar