# Security Headers Checker – Bulk HSTS, CSP & Cookie Audit (`adamplaenitz/security-headers-checker`) Actor

Audit HTTP security headers of many URLs: HSTS, CSP (unsafe-inline/eval), X-Frame-Options, nosniff, Referrer- and Permissions-Policy, COOP/COEP/CORP, server leaks, cookie flags, HTTP→HTTPS redirect. Documented A+ to F grade with fixes.

- **URL**: https://apify.com/adamplaenitz/security-headers-checker.md
- **Developed by:** [Adam Plänitz](https://apify.com/adamplaenitz) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 url checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Security Headers Checker – Bulk HSTS, CSP & Cookie Audit

**Check the HTTP security headers of hundreds of URLs in one run and get a grade from A+ to F – with a fully documented scoring, the exact missing headers and a fix for every issue.** Covers HSTS, Content-Security-Policy (including `unsafe-inline` / `unsafe-eval` detection), X-Frame-Options / frame-ancestors, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP / COEP / CORP, server information leaks, cookie flags and the HTTP → HTTPS redirect. Export as JSON, CSV or Excel, or connect to Google Sheets, Slack, Make, Zapier, n8n or webhooks.

### What does it do?

For every URL the Actor sends a normal `GET` request (redirects are followed, the response body is not downloaded) and analyses the headers of the final page:

- **HSTS:** present, `max-age` (in seconds and days), `includeSubDomains`, `preload`.
- **Content-Security-Policy:** enforcing or report-only, directives, `'unsafe-inline'` without nonce/hash, `'unsafe-eval'`, wildcard script sources (`*`, `https:`, `data:`), nonces/hashes, `'strict-dynamic'`, `frame-ancestors`, `object-src 'none'`, `base-uri`, `upgrade-insecure-requests`. If several CSP headers are sent, the strictest one decides (as in browsers).
- **Clickjacking:** `X-Frame-Options` (DENY / SAMEORIGIN) or CSP `frame-ancestors`.
- **X-Content-Type-Options**, **Referrer-Policy** (effective value, unsafe values flagged), **Permissions-Policy** (deprecated Feature-Policy flagged), **COOP / COEP / CORP**, deprecated **X-XSS-Protection**.
- **Information leakage:** version numbers in `Server`, `X-Powered-By`, `X-AspNet-Version`, `X-AspNetMvc-Version`, `X-Generator`.
- **Cookies:** for every `Set-Cookie` on any hop: **name only** plus `Secure`, `HttpOnly`, `SameSite`. Cookie values are never stored.
- **HTTP → HTTPS:** one extra request to the `http://` version of the URL (same path) – does it redirect to HTTPS?
- **Certificate:** whether the HTTPS certificate is valid (details: use the companion SSL Certificate Checker).

### How the grade works (100 points)

| Area | Max | Rules |
|---|---|---|
| Strict-Transport-Security | 25 | max-age ≥ 1 year: 25 · ≥ 180 days: 20 · shorter: 10 · missing / `max-age=0`: 0 |
| Content-Security-Policy | 25 | enforcing CSP present: 10 · scripts restricted without `'unsafe-inline'` and without wildcard sources: +10 (+5 if only `'unsafe-eval'` remains) · at least two of `frame-ancestors`, `object-src 'none'`, `base-uri`: +5 · report-only CSP only: 5 |
| Clickjacking protection | 15 | `X-Frame-Options: DENY/SAMEORIGIN` or CSP `frame-ancestors` (not `*`) |
| X-Content-Type-Options | 10 | `nosniff` |
| Referrer-Policy | 10 | safe value (`no-referrer`, `same-origin`, `strict-origin`, `strict-origin-when-cross-origin`, `origin`, `origin-when-cross-origin`): 10 · missing (browser default applies): 5 · `unsafe-url` / `no-referrer-when-downgrade`: 0 |
| Permissions-Policy | 5 | present: 5 · only deprecated Feature-Policy: 2 |
| HTTP → HTTPS redirect | 10 | redirects to HTTPS, or no plain-HTTP service at all: 10 · serves the page over HTTP: 0 (switched off in the input: 10) |
| Deductions | −10 | software versions disclosed: −5 · cookies without `Secure` (or `SameSite=None` without `Secure`) on HTTPS: −5 |

**Grades:** A ≥ 85 · B ≥ 70 · C ≥ 55 · D ≥ 40 · F < 40. **A+** needs ≥ 95 points **and** HSTS ≥ 1 year with `includeSubDomains`, an enforcing CSP that restricts scripts without `'unsafe-inline'`, `'unsafe-eval'` or wildcards, a valid certificate and no critical or high issue.
**Caps:** a page served over plain HTTP is always **F** (HSTS is ignored over HTTP); an invalid TLS certificate caps the grade at **D**.
COOP/COEP/CORP and X-XSS-Protection are reported but not scored.

### Who is it for?

- **Web agencies and developers:** check all client sites after a launch or a server change.
- **Security and compliance teams:** a quick, repeatable baseline across many web properties (e.g. as evidence for ISO 27001, TISAX or customer questionnaires – as a technical indicator, not a certification).
- **Monitoring:** schedule a weekly run and alert on grade drops.

### Input

| Field | Default | Description |
|---|---|---|
| URLs or domains | – | `https://example.com/login`, `example.com` (checked as `https://example.com/`, falls back to `http://` if HTTPS is unavailable). Duplicates are removed. |
| Check HTTP → HTTPS redirect | on | One extra request per URL. |
| Maximum redirects | 10 | Headers of the final page are analysed. |
| User-Agent | Actor UA | Optional custom User-Agent. |
| Parallel checks | 10 | 1–50. |
| Timeout per request | 15 s | Connection resets are retried. |

### Output example (shortened)

```json
{
  "input": "https://github.com",
  "url": "https://github.com/",
  "finalUrl": "https://github.com/",
  "statusCode": 200,
  "grade": "A+",
  "score": 95,
  "topIssues": "none",
  "issueCount": 2,
  "https": true,
  "certificateValid": true,
  "httpToHttps": true,
  "missingHeaders": ["Permissions-Policy"],
  "hsts": { "present": true, "maxAge": 31536000, "maxAgeDays": 365, "includeSubDomains": true, "preload": true },
  "csp": { "present": true, "unsafeInline": false, "unsafeEval": false, "wildcardScriptSources": [], "usesNonceOrHash": true, "frameAncestors": "'none'", "objectSrcNone": true, "baseUri": "'self'", "value": "default-src 'none'; base-uri 'self'; …" },
  "xFrameOptions": "deny",
  "xContentTypeOptions": "nosniff",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "crossOriginOpenerPolicy": null,
  "xXssProtection": "0",
  "server": "github.com",
  "informationLeaks": [],
  "cookies": [
    { "name": "_gh_sess", "secure": true, "httpOnly": true, "sameSite": "Lax" },
    { "name": "_octo", "secure": true, "httpOnly": false, "sameSite": "Lax" }
  ],
  "issues": [
    { "severity": "low", "header": "Permissions-Policy", "code": "permissions_policy_missing", "message": "No Permissions-Policy header.", "recommendation": "Disable unused browser features, e.g. \"Permissions-Policy: camera=(), microphone=(), geolocation=()\"." },
    { "severity": "low", "header": "Set-Cookie", "code": "cookie_not_httponly", "message": "Cookies readable by JavaScript (no HttpOnly): _octo.", "recommendation": "Set HttpOnly on session and authentication cookies." }
  ],
  "scoreBreakdown": { "hsts": 25, "csp": 25, "clickjacking": 15, "contentTypeOptions": 10, "referrerPolicy": 10, "permissionsPolicy": 0, "httpsRedirect": 10, "deductions": 0 },
  "responseTimeMs": 97,
  "error": null
}
```

The **Overview** table shows URL, grade, score, critical/high issues, missing headers, HTTPS, certificate, HTTP→HTTPS, status, final URL, server and cookie count.

### Pricing and speed

See the **Pricing** tab. You pay per checked URL; **rows for URLs that cannot be reached at all (DNS error, timeout, connection refused, invalid input) are free**. Duplicates are removed before checking.

A check needs one request per redirect hop plus one for the HTTP → HTTPS test, typically 0.2–1 second; hosts that do not answer wait for the timeout. In a cloud test with the default 10 parallel checks, the Tranco top 1,000 domains (about 30 % of them infrastructure domains without a reachable website) took 4.5 minutes. For large lists, raise *Parallel checks* or lower the timeout. The Actor runs with 256 MB memory. You can set a maximum cost per run – the Actor stops cleanly when it is reached.

### Privacy and responsible use

- **Passive check:** normal page requests like a browser visit, without downloading the body. No port scanning, no vulnerability probing, no form submissions, no login attempts.
- **Please check only sites you own or are allowed to assess.** The result is a technical indicator of the response headers, **not a security certification or penetration test**.
- **No personal data:** only cookie names and flags are stored, never cookie values. Private, loopback and internal addresses are refused.

### Limits

- Some sites answer automated clients with a bot-protection or error page (e.g. status 403) whose headers can differ from the real page – check `statusCode`. You can set a custom User-Agent.
- Only response headers are evaluated; CSP set via `<meta>` tags is not analysed.
- HTTP/1.1 is used; sites that send different headers over HTTP/2 or HTTP/3 are rare but possible.

Questions or feature requests? Please open an issue in the **Issues** tab.

# Actor input Schema

## `urls` (type: `array`):

One per line. Bare domains are checked as https://domain/ (with a fallback to http:// if HTTPS is not available); full URLs keep their path. Duplicates are removed. Only check sites you own or are allowed to assess.

## `checkHttpRedirect` (type: `boolean`):

Makes one extra request to the plain http:// version of each URL and checks that it redirects to HTTPS (scored with 10 points).

## `maxRedirects` (type: `integer`):

Redirects are followed and the headers of the final page are analysed. Cookies set on any hop are included.

## `userAgent` (type: `string`):

Leave empty to identify as 'security-headers-checker/0.1 (Apify Actor; passive header check)'. Some sites answer non-browser clients with a block page – the status code shows this.

## `concurrency` (type: `integer`):

How many URLs are checked at the same time (1–50).

## `timeoutSecs` (type: `integer`):

Maximum time for each HTTP request (connection + response headers). Connection resets are retried automatically.

## Actor input object example

```json
{
  "urls": [
    "https://apify.com",
    "https://github.com",
    "https://www.wikipedia.org",
    "https://example.com"
  ],
  "checkHttpRedirect": true,
  "maxRedirects": 10,
  "concurrency": 10,
  "timeoutSecs": 15
}
```

# Actor output Schema

## `results` (type: `string`):

One item per URL with grade, score breakdown, header details, cookie flags and prioritised issues with recommendations.

## `summary` (type: `string`):

Grade distribution, errors, duplicates and charged results.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://apify.com",
        "https://github.com",
        "https://www.wikipedia.org",
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("adamplaenitz/security-headers-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [
        "https://apify.com",
        "https://github.com",
        "https://www.wikipedia.org",
        "https://example.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("adamplaenitz/security-headers-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://apify.com",
    "https://github.com",
    "https://www.wikipedia.org",
    "https://example.com"
  ]
}' |
apify call adamplaenitz/security-headers-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,adamplaenitz/security-headers-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ecTWU6PIdh1ATEfPz/builds/rTmeetgcPvhODtawc/openapi.json
