Skip to main content
MediumHeadersOWASP A02:2021CWE-319

How to fix: HSTS header missing includeSubDomains directive

The Strict-Transport-Security header is present but does not include includeSubDomains, leaving subdomains unprotected.

Why it matters

Without includeSubDomains, attackers can downgrade connections to subdomains over HTTP and set cookies (without Secure flag) that are sent to the main domain, a subdomain cookie injection attack.

includeSubDomains extends HSTS protection to all subdomains of the current domain.

How to fix it

  1. 1Add includeSubDomains to the HSTS header
  2. 2Ensure all subdomains are served over HTTPS before adding includeSubDomains
  3. 3Consider also adding preload for first-visit protection

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 strict-transport-security-include-subdomains, stable across every scan so you can filter or diff on it.

See every headers check

Questions

How severe is HSTS header missing includeSubDomains directive?
VulnRadar rates this medium 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 strict-transport-security-include-subdomains, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does HSTS header missing includeSubDomains directive 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 missing includesubdomains directive

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 missing includeSubDomains directive | VulnRadar