The Complete Production SOP: How to Deploy and Run HTTP Strict Transport Security (HSTS) Preload in Autonomous AI Agents
Deploy the HSTS Preload header hardening skill across Codex, Claude Code, and Cursor. Enforce HTTPS, stop SSL stripping, and automate preload checks.
Technical Overview & Architectural Context
Autonomous coding agents frequently make subtle but catastrophic mistakes when configuring HTTP Strict Transport Security (HSTS). Typical failure modes include applying the header to raw HTTP listeners rather than HTTPS endpoints, omitting the 'includeSubDomains' directive before verifying whether internal subdomains have active certificates, or configuring inadequate max-age values that fail Chromium preload requirements (minimum 31536000 seconds / 1 year). In complex multi-service repositories, agents often emit 302 temporary redirects instead of permanent 301 redirects on port 80, inadvertently blocking eligibility for browser-level preload lists. The 'hsts-preload-header-hardening' skill eliminates these non-deterministic failure patterns by establishing unambiguous operational guardrails. It forces agents to follow a 4-step sequence: enforce a strict 301 canonical redirect on unencrypted ingress, guarantee certificate validation across the root and all child subdomains, inject the RFC 6797 compliant 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' header exclusively on TLS listeners, and perform automated linting against the official Chromium preload submission criteria before reporting task completion.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the skill manifest into your agent runtime's global or workspace-level skill directory.
To inject the deterministic security SOP into Codex, Claude Code, Cursor, or Windsurf, place the SKILL.md file inside the canonical agent configuration path. For Claude Code, this resides in '.claude/skills/' or '~/.agents/skills/'. When an agent reads user input matching 'configure hsts header' or 'submit domain to hsts preload', it parses the frontmatter triggers and activates strict execution boundaries.
mkdir -p .claude/skills/hsts-preload-header-hardening && cat <<'EOF' > .claude/skills/hsts-preload-header-hardening/SKILL.md
---
name: "hsts-preload-header-hardening"
description: "Force HTTPS connections and eliminate SSL stripping attacks with HSTS Preload."
metadata:
author: "Chromium HSTS"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "configure hsts header"
- "submit domain to hsts preload"
- "prevent ssl stripping hsts"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# HTTP Strict Transport Security (HSTS) Preload
Configures HTTP Strict Transport Security: Strict-Transport-Security: max-age=31536000; includeSubDomains; preload, testing eligibility, and submitting domains to the global HSTS Preload list.
## When to Invoke
Invoke this skill whenever you need to:
- configure hsts header
- submit domain to hsts preload
- prevent ssl stripping hsts
## Execution SOP & Rules
1. Set header: Strict-Transport-Security: max-age=31536000; includeSubDomains; preload.
2. Ensure the initial HTTP connection immediately redirects to HTTPS with a 301 response.
3. Verify all subdomains possess valid, unexpired SSL/TLS certificates.
4. Submit the validated root domain to the Chromium HSTS preload list for permanent browser pinning.
## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
EOF---
name: "hsts-preload-header-hardening"
description: "Force HTTPS connections and eliminate SSL stripping attacks with HSTS Preload."
metadata:
author: "Chromium HSTS"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "configure hsts header"
- "submit domain to hsts preload"
- "prevent ssl stripping hsts"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Place this skill at the project root under '.cursor/rules/' or '.claude/skills/' to avoid injecting global agent configurations, keeping context memory strictly isolated per repository.
Ensure 'permissions.fs_write' is restricted to 'workspace'. Providing unrestricted root writes allows misconfigured agents to overwrite host-level web server files outside the repository boundary.
Reverse Proxy & Middleware Hardening
Direct the agent to apply the hardened HSTS preload header to your production web server or edge configuration.
Instruct the agent to modify the web gateway configuration (e.g., Nginx, Next.js, or Cloudflare Workers) strictly ensuring the header is served over TLS (port 443) and that port 80 issues an immediate 301 redirect. The agent must verify that the header contains all three mandatory components: max-age >= 31536000, includeSubDomains, and preload.
test -f nginx.conf && nginx -t || test -f next.config.js && npm run lint# Redirect HTTP (Port 80) to HTTPS (Port 443)
server {
listen 80;
listen [::]:80;
server_name example.com *.example.com;
return 301 https://$host$request_uri;
}
# Secure HTTPS Server (Port 443)
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate /etc/ssl/certs/example.com.crt;
ssl_certificate_key /etc/ssl/private/example.com.key;
# Enforce RFC 6797 HSTS Preload Directive
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "DENY" always;
}Always append the 'always' parameter in Nginx configurations so that HSTS headers are returned on error responses (4xx/5xx) as well as successful responses (2xx).
Do not send 'Strict-Transport-Security' on HTTP (port 80) responses. RFC 6797 Section 7.2 explicitly states clients must ignore HSTS headers delivered over plain HTTP, and preload submission checkers will flag this as a critical warning.
Intent Matching & Deterministic Trigger Invocation
Trigger the agent using frontmatter-aligned phrases to engage deterministic SOP compliance.
Run an agent command referencing the skill's triggers. Claude Code or Codex reads the repository context, indexes the active triggers ('configure hsts header', 'prevent ssl stripping hsts'), and initiates the rule set outlined in SKILL.md without deviating into partial implementations.
claude "Audit our ingress configuration to configure hsts header and prevent ssl stripping hsts for preload submission"Use precise triggers from the YAML frontmatter in your initial agent prompt to achieve immediate rule matching without intermediate reasoning overhead.
Avoid fuzzy instructions like 'make my site secure', which causes LLMs to hallucinate ad-hoc header formats or set low test values like max-age=300.
Verification, Linting & Output Quality Gate
Verify the live headers and run syntax and compliance checks against Chromium preload standards.
Before committing changes generated by the autonomous agent, run validation commands to assert that the response header matches exact specification syntax and redirects behave deterministically with a 301 status code.
curl -sI https://localhost:8443 | grep -i "Strict-Transport-Security"#!/usr/bin/env bash
set -euo pipefail
TARGET_URL="${1:-https://localhost}"
HEADER=$(curl -sIk "$TARGET_URL" | tr -d '\r' | grep -i "^Strict-Transport-Security:")
echo "Inspecting Header: $HEADER"
if [[ "$HEADER" =~ max-age=([0-9]+) ]]; then
AGE="${BASH_REMATCH[1]}"
if [ "$AGE" -lt 31536000 ]; then
echo "ERROR: max-age is $AGE, must be >= 31536000" >&2
exit 1
fi
else
echo "ERROR: Missing max-age directive" >&2
exit 1
fi
if ! echo "$HEADER" | grep -q "includeSubDomains"; then
echo "ERROR: Missing includeSubDomains directive" >&2
exit 1
fi
if ! echo "$HEADER" | grep -q "preload"; then
echo "ERROR: Missing preload directive" >&2
exit 1
fi
echo "SUCCESS: HSTS Preload criteria verified."Incorporate the 'verify-hsts.sh' verification check directly into your continuous integration workflow to prevent regressions during future agent refactors.
Testing against an unpinned staging hostname (e.g., 'staging.example.com') without wildcard certificates will cause child subdomains to fail preload validation.
Real-World Scenario: Automating Production Ingress Hardening for Chromium HSTS Preload Eligibility
“Please configure hsts header on our Nginx edge proxy, ensure redirect conforms to preload requirements, and prevent ssl stripping hsts across all subdomains.”
Runtime Troubleshooting & Failure Modes
Root Cause: The 'includeSubDomains' flag forces all subdomains (e.g., mail.example.com, internal.example.com) to load over HTTPS. If any child subdomain lacks a valid SSL/TLS certificate, users will experience hard connection failures.
# Verify all DNS subdomains have valid certificates before applying header:
for sub in $(cat subdomains.txt); do
curl -sIv --connect-timeout 3 "https://$sub.example.com" 2>&1 | grep -q "SSL certificate verify ok" || echo "Fix cert for: $sub.example.com"
doneRoot Cause: The agent used an idiomatic or default redirect mechanism in framework middleware (such as Next.js redirect() or standard Express res.redirect()) which defaults to HTTP 302 or 307 temporary redirects.
// Next.js next.config.js fix
module.exports = {
async redirects() {
return [
{
source: '/:path*',
has: [{ type: 'header', key: 'x-forwarded-proto', value: 'http' }],
destination: 'https://example.com/:path*',
permanent: true // Enforces 301 status code required for HSTS preload
}
];
}
};Frequently Asked Questions (HTTP Strict Transport Security (HSTS) Preload SOP)
Q:Can I use HTTP Strict Transport Security (HSTS) Preload across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification supported across all modern agent runtimes. You can mount it in project-level configurations such as '.cursor/rules', '.claude/skills', or Codex root manifests.
Q:How does HTTP Strict Transport Security (HSTS) Preload prevent context window overflow during long agent sessions?
By establishing concise procedural boundaries and deterministic validation gates rather than polluting system prompts with redundant rules, keeping agent token overhead minimal while preventing hallucinated header configurations.
Q:Does this skill require escalated root or container permissions?
No. It is audited with a security score of 98/100 and runs safely within workspace-scoped sandboxes with 'net_access: false' and 'shell_exec: false' by default, operating purely via repository file modifications.
Ready to equip your autonomous agent with HTTP Strict Transport Security (HSTS) Preload?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.