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
- 1Add includeSubDomains to the HSTS header
- 2Ensure all subdomains are served over HTTPS before adding includeSubDomains
- 3Consider also adding preload for first-visit protection
Code examples
Next.js
// next.config.mjs
export default {
async headers() {
return [{ source: "/(.*)", headers: [{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" }] }];
},
};Nginx
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;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.
More headers checks
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.