# Security Headers Checker - Bulk HSTS, CSP, security.txt (`extas_corp/security-headers-checker`) Actor

Grade the HTTP security headers of many sites in one run: HSTS, CSP, clickjacking, nosniff, referrer and permissions policy, cookie flags, version leaks, plus an RFC 9116 security.txt check. A to F score and a fix list per URL. No login, no browser, no proxy.

- **URL**: https://apify.com/extas_corp/security-headers-checker.md
- **Developed by:** [Extas Corp](https://apify.com/extas_corp) (community)
- **Categories:** Developer tools, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Flags & security.txt Grade

Paste a list of sites and get, for each one, an **A to F grade** for its HTTP security headers and a **list of what to fix**. It also reads the `security.txt` file (RFC 9116) that tells researchers how to report a vulnerability. One request per site, plus the security.txt lookup: it reads only what the server sends to any browser.

- **Headers graded**: `Strict-Transport-Security` (max-age, includeSubDomains), `Content-Security-Policy` (missing, `'unsafe-inline'` without nonce/hash, `'unsafe-eval'`, wildcard sources), clickjacking protection (`X-Frame-Options` or CSP `frame-ancestors`), `X-Content-Type-Options`, `Referrer-Policy`, `Permissions-Policy`, `Cross-Origin-Opener-Policy`.
- **Information leaks**: `Server` with a version number, `X-Powered-By`, `X-AspNet-Version`.
- **Cookie flags**: every `Set-Cookie` of the response is checked for `Secure`, `HttpOnly`, `SameSite`.
- **security.txt**: looks in `/.well-known/security.txt` then `/security.txt`; reports Contact, Expires, Policy, and problems (no Contact, no Expires, expired, bad date).
- Redirects are followed and the **final** page is graded (`http://` and `www` variants end up where a visitor ends up).
- Findings have a severity (`high`, `medium`, `low`) and a plain message.
- Errors are reported per URL, they never stop the run.
- **Safe by design**: URLs that resolve to private, local or link-local addresses are refused (also after a redirect).
- **Free during launch**: no per-URL fee at the moment, you only pay Apify platform usage (covered by the Free plan's monthly credit for normal use).

### Input example

```json
{
  "urls": ["github.com", "example.com", "https://www.mozilla.org"],
  "checkSecurityTxt": true
}
```

A bare domain is checked over HTTPS. Duplicates are checked once.

### Example output

`example.com` (real run):

```json
{
  "url": "https://example.com",
  "finalUrl": "https://example.com",
  "status": 200,
  "grade": "F",
  "score": 0,
  "error": null,
  "findings": [
    {"severity": "high", "header": "strict-transport-security", "message": "missing: browsers may be downgraded to HTTP"},
    {"severity": "high", "header": "content-security-policy", "message": "missing: no browser-side defence against script injection"},
    {"severity": "medium", "header": "x-frame-options", "message": "no clickjacking protection (X-Frame-Options or CSP frame-ancestors)"},
    {"severity": "medium", "header": "x-content-type-options", "message": "missing or not \"nosniff\""}
  ],
  "headers": {"server": "cloudflare"},
  "securityTxt": {"found": false}
}
```

(findings shortened here: the real row also lists `referrer-policy`, `permissions-policy` and `cross-origin-opener-policy`.)

`github.com` (real run) scores 80, grade B: HSTS and CSP are present, the findings are `permissions-policy` and `cross-origin-opener-policy` missing, and one cookie without `HttpOnly`; its `securityTxt.found` is `true`.

### How the grade works

The score starts at 0 and adds points for each good header: HSTS 20 (10 if max-age is under 6 months), CSP 25 (minus points for `'unsafe-inline'` without nonce/hash or a wildcard source), clickjacking protection 15, `nosniff` 10, `Referrer-Policy` 10, `Permissions-Policy` 10, `Cross-Origin-Opener-Policy` 10. Grades: A from 85, B from 70, C from 50, D from 30, F below. A site with any `high` finding cannot be better than C. Cookie flags and version leaks are reported as findings but do not change the score.

### Pricing

**Free during launch**: no per-URL fee, only Apify platform usage. A price per checked URL may be introduced later, with advance notice.

### Limits

- It grades the headers of **one response** (the page you give, after redirects). Other pages or API routes of the same site can send different headers.
- The grade is a **checklist of well-known headers, not a security audit**. A good grade does not mean a site is secure, and a poor one does not mean it is vulnerable.
- It does not execute JavaScript, so headers added by a browser-only layer are not seen. Sites that block automated clients (Cloudflare challenge, 403) are reported with their HTTP status and the headers of that block page.
- The CSP check is a set of simple rules (missing, `'unsafe-inline'`, `'unsafe-eval'`, wildcards). It does not evaluate a full policy.
- Only `Set-Cookie` headers of that single response are checked; cookies set later by scripts are not.
- `Expires` in security.txt is compared with today's date; signed (PGP) files are read as plain text, the signature is not verified.
- It sends normal GET requests with a clear User-Agent. Only check sites you are allowed to look at; it does not probe, scan ports or test for vulnerabilities.

# Actor input Schema

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

One per line. A bare domain (example.com) is checked over HTTPS; redirects are followed and the final page's headers are graded. Duplicates are checked once.

## `checkSecurityTxt` (type: `boolean`):

Also read /.well-known/security.txt (RFC 9116) and report Contact, Expires and problems.

## Actor input object example

```json
{
  "urls": [
    "github.com",
    "example.com",
    "https://www.mozilla.org"
  ],
  "checkSecurityTxt": true
}
```

# Actor output Schema

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

No description

# 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": [
        "github.com",
        "example.com",
        "https://www.mozilla.org"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("extas_corp/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": [
        "github.com",
        "example.com",
        "https://www.mozilla.org",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("extas_corp/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": [
    "github.com",
    "example.com",
    "https://www.mozilla.org"
  ]
}' |
apify call extas_corp/security-headers-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,extas_corp/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/k9Tz4tzdHWOhOc3qd/builds/ChW8ra4nMgNiYmlwx/openapi.json
