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

How to remediate – 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. It improves security by preventing protocol downgrade attacks and reducing the risk of man-in-the-middle attacks. This policy is typically applied to websites and web applications. A successful exploitation could lead to confidentiality, integrity, and availability compromise if an attacker can bypass or manipulate the HSTS policy.

2. Technical Explanation

  • Root cause: The server is configured with an HTTP Strict Transport Security policy.
  • Exploit mechanism: An attacker could attempt a man-in-the-middle attack if HSTS isn’t properly implemented or if the browser doesn’t enforce it due to misconfiguration.
  • Scope: Web servers and applications using HTTPS are affected.

3. Detection and Assessment

You can confirm an HSTS policy is in place by inspecting HTTP response headers. Thorough assessment involves checking subdomain coverage and preload list status.

  • Quick checks: Use your browser’s developer tools (Network tab) to inspect the response headers for a website. Look for the `Strict-Transport-Security` header.
  • Scanning: Nessus, OpenVAS, or Burp Suite can identify HSTS policies and potential misconfigurations. These are examples only.
  • Logs and evidence: Web server access logs may show HTTPS redirects enforced by HSTS.
curl -I https://example.com | grep Strict-Transport-Security

4. Solution / Remediation Steps

Ensure your web server is configured with a strong HSTS policy, including `max-age`, `includeSubDomains` and consider `preload`. Review the policy regularly for changes.

4.1 Preparation

  • Ensure you have access to modify the web server’s configuration files. Roll back by restoring the original configuration file if needed.
  • A change window may be required depending on your environment and approval process.

4.2 Implementation

  1. Step 1: Edit your web server’s configuration file (e.g., Apache `.htaccess`, Nginx `nginx.conf`).
  2. Step 2: Add the following header to enforce HTTPS: `Strict-Transport-Security: max-age=31536000; includeSubDomains; preload`.
  3. Step 3: Restart your web server to apply the changes.

4.3 Config or Code Example

Before

# No HSTS header configured

After

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

4.4 Security Practices Relevant to This Vulnerability

Secure headers are essential for protecting web applications. Regular configuration reviews and patch management help maintain a secure environment.

  • Practice 1: Implement strong security headers, including HSTS, X-Frame-Options, and Content-Security-Policy.
  • Practice 2: Regularly review your web server’s configuration to ensure it adheres to security best practices.

4.5 Automation (Optional)

# Example Ansible task to add HSTS header
- name: Add HSTS header to Nginx configuration
  lineinfile:
    path: /etc/nginx/nginx.conf
    regexp: '^add_header Strict-Transport-Security'
    line: 'add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";'
    state: present

5. Verification / Validation

  • Post-fix check: Use `curl -I https://example.com | grep Strict-Transport-Security` and verify the header is present with the correct settings.
  • Re-test: Clear your browser’s cache and attempt to access the website using `http://example.com`. It should automatically redirect to `https://example.com`.
  • Smoke test: Verify that all core web application functionality works as expected over HTTPS.
  • Monitoring: Check web server logs for any errors related to HSTS redirects or enforcement.
curl -I https://example.com | grep Strict-Transport-Security

6. Preventive Measures and Monitoring

Update security baselines with HSTS configuration requirements. Implement automated checks in your CI/CD pipeline to prevent misconfigurations. Maintain a regular patch cycle for web server software.

  • Baselines: Include HSTS settings in your organization’s web server security baseline.
  • Pipelines: Add SAST or DAST scans to identify missing or incorrectly configured HSTS headers during development and deployment.
  • Asset and patch process: Review web server configurations quarterly for compliance with the latest security standards.

7. Risks, Side Effects, and Roll Back

  • Risk or side effect 1: Misconfiguration may prevent access to the site if HTTPS fails.
  • Risk or side effect 2: Preloading requires careful validation and can be difficult to remove once submitted.
  • Roll back: Restore the original web server configuration file. Remove the HSTS header from your configuration. Restart the web service.

8. References and Resources

  • Vendor advisory or bulletin: N/A
  • NVD or CVE entry: N/A
  • Product or platform documentation relevant to the fix: https://hstspreload.org/
Updated on December 27, 2025

Was this article helpful?

Related Articles