Technical Tip: HSTS enforcement
Description
This article describes how to enable HSTS for the admin login page.
The remote HTTPS server is not enforcing HTTP Strict Transport Security (HSTS).
The lack of HSTS allows downgrade attacks, SSL-stripping man-in-the-middle attacks, and weakens cookie-hijacking protections.
Scope
From version 6.2.6.
Solution
Â
FortiOS CLI:
config system global
   set admin-hsts-max-age {integer}
endMinimum: 0 (seconds)
Maximum: 2147483647, approximately 68.1 years.
Default: 63072000, exactly 730 days (2 years).
Note:Â If the command is not available, it is necessary to enable HTTPS redirect as follows
config sys global
  set admin-https-redirect enable
set admin-hsts-max-age {integer}
endÂ
The HTTPS Strict-Transport-Security header max-age value is the number of seconds the client should honor the HSTS setting. Browsers should only register this value if received over a secure and trusted TLS connection.
A value of 0 will reset any HSTS records in the browser, effectively disabling HSTS security for the domain.
When admin-https-redirect is disabled, the header max-age was previously 0. However, on current FortiOS versions such as v7.4, the HSTS header max-age is 63072000 when admin-https-redirect is disabled. This issue is under investigation and scheduled for enhancement in FortiOS v7.6.9 and v8.0.3.
Verification:
Â
When the browser initiates the connection to the FortiGate, the unit will respond with the HSTS header for internal redirection.

Â
If the server uses the default port 443, use the SSL Server Test to verify the HSTS enforcement.
Â

Â
Enable HSTS for the VIP object:
Enabling it will add an HSTS header to each HTTP response.
Note:
This is only available when the VIP operates as a Load Balance server object and is set to listen on port 443.
Â
config firewall vip
  edit <name>
    set ssl-hsts enable
    set ssl-hsts-age {integer}
    set ssl-hsts-include-subdomains enable
next
endMinimum value: 60
Maximum value: 157680000
Default value: 5184000
SSL VPN:
When performing a third-party security scan, the results of the scan might show that the HSTS setting is not being honored, and the scan will fail.
With the following changes to the configuration, the HSTS should be enforced, and the security scan should pass.
Â
config vpn ssl settings
  set hsts-include-subdomains enable
endÂ
If all the configurations are verified, check if the ACME protocol for certificate provisioning and the Let's Encrypt certificate are configured on FortiGate, which might cause the security scan to fail.
Technical Tip: Acme on the FortiGate causes Security Compliance Checks to FailÂ
Â
Additional information:
HSTS Enforcement will also work on non-standard HTTPS ports (ports other than 443). Enforcement will occur based on the port configured in the VIP.
