Skip to main content
LowHeadersOWASP A02:2021CWE-319

How to fix: HSTS header has weak directives (missing preload and/or low max-age)

The Strict-Transport-Security header is present but is missing the preload directive, has a max-age below the 1-year minimum, or both. The finding's evidence text states which of the two conditions actually applies.

Why it matters

Without preload and inclusion in the browser HSTS preload list, first-time visitors who type the domain without https:// may connect over HTTP before being redirected, exposing that first request to interception. A max-age below one year means browsers stop enforcing HTTPS-only access sooner than recommended, reopening the downgrade window earlier than necessary.

The preload directive enables submission to browser preload lists so the domain is always loaded over HTTPS, even on the first visit. max-age should be at least 31536000 (1 year) so HSTS enforcement doesn't lapse between visits.

How to fix it

  1. 1Set your HSTS header to: max-age=63072000; includeSubDomains; preload
  2. 2Ensure max-age is at least 31536000 and includeSubDomains is present
  3. 3Submit to the preload list at hstspreload.org

Code examples

Next.js

JavaScript
// next.config.mjs
export default {
  async headers() {
    return [{ source: "/(.*)", headers: [{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" }] }];
  },
};

Nginx

nginx
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;

Apache

APACHE
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"

References

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

See every headers check

Questions

How severe is HSTS header has weak directives (missing preload and/or low max-age)?
VulnRadar rates this low severity in the headers 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 hsts-no-preload, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does HSTS header has weak directives (missing preload and/or low max-age) map to?
It maps to CWE-319. In the OWASP Top 10 it falls under A02: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 header has weak directives (missing preload and/or low max-age)

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 header has weak directives (missing preload and/or low max-age) | VulnRadar