1. Home
  2. Web App Vulnerabilities
  3. How to remediate – Permissive HTTP Strict Transport Security Policy Detected

How to remediate – Permissive HTTP Strict Transport Security Policy Detected

1. Introduction

HTTP Strict Transport Security (HSTS) is a web server directive that tells browsers to only connect via HTTPS. A permissive HSTS policy, meaning one with a short max-age or missing subdomain coverage, weakens security because it doesn’t enforce HTTPS for long enough or across all related domains. This can allow attackers to intercept traffic using man-in-the-middle attacks. Affected systems are typically web servers and content delivery networks (CDNs). A successful attack could compromise confidentiality of data in transit.

2. Technical Explanation

The vulnerability occurs when an HSTS header is present but configured with insufficient protection. Specifically, the max-age value is too low or the includeSubDomains directive is absent. This allows browsers to accept insecure HTTP connections after a short period, or for subdomains not covered by the policy. An attacker could exploit this by intercepting traffic before the browser enforces HTTPS, potentially stealing credentials or sensitive data.

  • Root cause: Incorrectly configured HSTS header in web server settings.
  • Exploit mechanism: An attacker intercepts initial HTTP requests and downgrades them to plain text, then captures user data.
  • Scope: Web servers (e.g., Apache, Nginx, IIS) and CDNs serving HTTPS content.

3. Detection and Assessment

You can confirm a vulnerable HSTS policy by inspecting the HTTP response headers from your web server. A thorough assessment involves checking all subdomains for consistent policy application.

  • Quick checks: Use browser developer tools (Network tab) to view the Strict-Transport-Security header when accessing your website via HTTPS.
  • Scanning: Security scanners like OWASP ZAP or Burp Suite can identify weak HSTS configurations.
curl -I https://example.com | grep Strict-Transport-Security

4. Solution / Remediation Steps

Fix the issue by configuring your web server with a strong HSTS policy. This involves setting an appropriate max-age value and including subdomains. Only include steps that apply to this vulnerability.

4.1 Preparation

  • Ensure you have access to modify the web server’s configuration file. A roll back plan is to restore the original configuration file and restart the service.
  • Changes may require a full cache clear on CDNs. Approval from the security team might be needed.

4.2 Implementation

  1. Step 1: Edit your web server’s configuration file (e.g., Apache’s httpd.conf, Nginx’s nginx.conf).
  2. Step 2: Add or modify the HSTS header to include max-age=31536000 and includeSubDomains.
  3. Step 3: Save the configuration file.
  4. Step 4: Restart your web server for the changes to take effect.

4.3 Config or Code Example

Before

Strict-Transport-Security: max-age=60

After

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

4.4 Security Practices Relevant to This Vulnerability

Several security practices help prevent this issue. Secure headers are crucial for protecting web traffic. A patch cadence ensures timely updates and mitigates known vulnerabilities.

  • Practice 1: Implement secure HTTP headers, including HSTS, Content-Security-Policy, and X-Frame-Options.
  • Practice 2: Maintain a regular patch cadence to apply security updates promptly.

4.5 Automation (Optional)

If using configuration management tools like Ansible, you can automate the HSTS header update across multiple servers.

# Example Ansible task
- name: Configure HSTS header
  lineinfile:
    path: /etc/nginx/nginx.conf
    regexp: 'Strict-Transport-Security:'
    line: 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload'
    state: present
  notify: Restart Nginx

5. Verification / Validation

Confirm the fix by checking the HSTS header after applying the changes. Verify that the max-age is set to at least 31536000 seconds and that subdomains are included. A simple service smoke test involves accessing your website via HTTPS from multiple browsers.

  • Post-fix check: Run curl -I https://example.com | grep Strict-Transport-Security and confirm the output shows max-age=31536000; includeSubDomains; preload.
  • Re-test: Re-run the initial curl command to verify the header is now correctly configured.
  • Smoke test: Access your website via HTTPS from Chrome, Firefox, and Edge to ensure it loads without errors or warnings.
curl -I https://example.com | grep Strict-Transport-Security

6. Preventive Measures and Monitoring

Update security baselines to include strong HSTS configurations. Add checks in CI/CD pipelines to validate header settings during deployment. A sensible patch or config review cycle helps catch misconfigurations.

  • Baselines: Update your web server security baseline to enforce a minimum max-age of 31536000 seconds and require the includeSubDomains directive.

7. Risks, Side Effects, and Roll Back

  • Risk or side effect 1: Incorrect HSTS configuration may prevent access from older browsers that don’t support it.
  • Risk or side effect 2: Changes might require a full CDN cache clear, potentially causing temporary service disruption.
  • Roll back: Restore the original web server configuration file and restart the service.

8. References and Resources

Updated on December 27, 2025

Was this article helpful?

Related Articles