Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Test HTTP Strict Transport Security
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-14 | ✗→✓ | ▲ Improved | 81% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 86% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 80% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 81% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 170% | 0% |
WSTG-CONF-07
Test HTTP Strict Transport Security (HSTS)
HTTP Strict Transport Security (HSTS) is a security mechanism that forces browsers to communicate with websites only over HTTPS. When properly implemented, HSTS protects against protocol downgrade attacks, SSL stripping, and cookie hijacking. This test verifies that the HSTS header is present, properly configured, and includes appropriate directives.
| Directive | Description | Recommended | | ------------------- | -------------------------------- | -------------------- | | max-age | Time in seconds to enforce HTTPS | >= 31536000 (1 year) | | includeSubDomains | Apply HSTS to all subdomains | Yes | | preload | Include in browser preload lists | Recommended |
bash# Check for HSTS header curl -sI https://target.com | grep -i strict-transport-security # Full header analysis curl -sI https://target.com | grep -iE 'strict-transport|content-security|x-frame|x-content' # Check specific values curl -sI https://target.com | grep -i strict-transport-security | \ grep -oP 'max-age=\d+'
bash#!/bin/bash TARGET=$1 echo "=== HSTS ANALYSIS ===" echo "Target: $TARGET" # Get HSTS header hsts=$(curl -sI "https://$TARGET" | grep -i "strict-transport-security" | tr -d '\r') if [ -z "$hsts" ]; then echo "[FAIL] HSTS header not present!" exit 1 fi echo "Header: $hsts" # Check max-age max_age=$(echo "$hsts" | grep -oP 'max-age=\K\d+') if [ -z "$max_age" ]; then echo "[FAIL] max-age not specified" elif [ "$max_age" -lt 31536000 ]; then echo "[WARN] max-age is less than 1 year ($max_age seconds)" else echo "[PASS] max-age: $max_age seconds" fi # Check includeSubDomains if echo "$hsts" | grep -qi "includesubdomains"; then echo "[PASS] includeSubDomains present" else echo "[WARN] includeSubDomains not present" fi # Check preload if echo "$hsts" | grep -qi "preload"; then echo "[PASS] preload directive present" else echo "[INFO] preload not present (optional)" fi
bash# Check that HTTP redirects to HTTPS curl -sI http://target.com | head -10 # Should return 301/302 redirect to HTTPS # HSTS header should NOT be sent over HTTP curl -sI http://target.com | grep -i strict-transport
bash# If includeSubDomains is set, verify all subdomains support HTTPS subdomains=("www" "api" "mail" "app" "admin") for sub in "${subdomains[@]}"; do host="${sub}.target.com" echo "=== $host ===" # Check HTTPS works https_status=$(curl -s -o /dev/null -w "%{http_code}" "https://$host" 2>/dev/null) echo "HTTPS Status: $https_status" # Check HSTS on subdomain curl -sI "https://$host" 2>/dev/null | grep -i strict-transport done
bash# Check if domain is in HSTS preload list # Visit: https://hstspreload.org/?domain=target.com # Or use API curl -s "https://hstspreload.org/api/v2/status?domain=target.com" | jq
Strict-Transport-Security| Tool | Description | Usage | | -------------- | -------------- | ------------------------------ | | curl | HTTP client | curl -sI https://target.com | | testssl.sh | SSL/TLS tester | testssl.sh --hsts target.com | | sslyze | SSL analyzer | sslyze --hsts target.com |
| Tool | URL | Purpose | | ---------------- | ------------------- | ---------------------- | | SSL Labs | ssllabs.com/ssltest | Comprehensive SSL test | | HSTS Preload | hstspreload.org | Preload list check | | Security Headers | securityheaders.com | Header analysis |
bash# Install testssl.sh git clone https://github.com/drwetter/testssl.sh.git # Run HSTS check ./testssl.sh --hsts target.com # Full test ./testssl.sh target.com
bash# Install pip install sslyze # Run scan sslyze --hsts target.com
bash# Check for missing HSTS nuclei -u https://target.com -t http/misconfiguration/http-missing-security-headers.yaml
apache# In httpd.conf or .htaccess <IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" </IfModule>
nginx# In server block add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
xml<system.webServer> <httpProtocol> <customHeaders> <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains; preload" /> </customHeaders> </httpProtocol> </system.webServer>
preload directiveincludeSubDomains is presentmax-age is at least 31536000 (1 year)Missing HSTS
| Metric | Value | Description | | ------------------- | -------- | -------------------------- | | Attack Vector | Network | Remote attack | | Attack Complexity | High | Requires MITM position | | Privileges Required | None | No auth needed | | User Interaction | Required | User visits site | | Confidentiality | High | Session hijacking possible |
| Finding | Severity | Description | | ------------------------- | -------- | -------------------------- | | HSTS not implemented | Medium | SSL stripping possible | | Low max-age value | Low | Reduced protection window | | Missing includeSubDomains | Low | Subdomain attacks possible | | Not in preload list | Info | First visit vulnerable |
| CWE ID | Title | Description | | ----------- | ----------------------------------------------- | ------------------------------ | | CWE-319 | Cleartext Transmission of Sensitive Information | Missing encryption enforcement | | CWE-523 | Unprotected Transport of Credentials | Credential exposure risk | | CWE-16 | Configuration | Security misconfiguration |
[ ] HSTS header checked on HTTPS response
[ ] max-age value verified (>= 31536000)
[ ] includeSubDomains directive checked
[ ] preload directive checked
[ ] HTTP to HTTPS redirect verified
[ ] HSTS not sent over HTTP
[ ] Subdomain HTTPS support verified
[ ] Preload list status checked
[ ] Mixed content issues checked
[ ] Browser testing completed
[ ] Findings documentedOther measured skills in the registry, with their headline benchmark lift.