# HTTP Security Headers Grader (`afkdigital/http-security-headers-grader`) Actor

Audit HTTP response headers for authorized HTML URLs with versioned scores, redirect evidence and explicit coverage limits.

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

## Pricing

$1.00 / 1,000 completed url assessments

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

## HTTP Security Headers Grader

Check an agency or MSP portfolio of authorized public HTML pages. Each input produces a dataset row with the final status, observed header values, redirect chain and the contribution of each scoring rule. Use the results to review header changes with site owners. A score measures the explicit controls recognized by this profile. It cannot certify security, demonstrate exploitability or replace a penetration test.

### Start a run

Use `{"urls":["https://example.com/"],"scoringProfile":"html-baseline","timeoutSeconds":10,"maxRedirects":3,"maxUrls":50}`. Alternatively supply `urlsFile` with the public HTTPS address of a UTF-8 text file containing one URL per line. Clear the URLs field when using a file. Inputs, final URLs and redirects appear in storage. Supply URLs without sensitive query parameters.

Limits: up to 200 unique input strings per run, 2,000 raw entries, up to five redirects, 1–20 seconds per complete chain, one chain at a time. Duplicates are removed after trimming and the first maxUrls entries are processed. The file uses one additional chain with a 64 KiB body cap. Page GETs stop after response headers (32 KiB header cap). Only HTTP/HTTPS default ports and public IPv4 destinations are supported. Public DNS answers are validated and pinned separately on each hop. The client does not use proxies, cookies, browser execution, attack payloads or automatic retries.

### HTML baseline 1.0.0

| Rule | Points | Condition |
| --- | ---: | --- |
| HSTS | 20 | HTTPS DNS hostname, recognized syntactically valid first STS field. Positive max-age below one year earns 10; at least one year earns 20. HTTP, IP literals, disabled or invalid policies earn zero. |
| Script CSP | 30 | At least one enforced policy restricts both script elements and attributes through their directives, script-src or default-src. Recognized lists are a lone 'none' or a list of 'self' and explicit HTTPS hosts. Nonce/hash-only lists may also include 'strict-dynamic'; nonce randomness and reuse require application review. Report-only is evidence only. |
| Framing | 20 | Explicit enforced frame-ancestors using the recognized source subset. Without that directive, consistent DENY or SAMEORIGIN XFO earns credit. default-src does not supply a framing fallback. |
| MIME sniffing | 10 | First option is nosniff. |
| Referrer | 10 | Last recognized explicit policy is no-referrer, same-origin, strict-origin or strict-origin-when-cross-origin. |
| Permissions | 10 | All three of camera, microphone and geolocation explicitly denied in a valid Structured Fields dictionary. One or two earns 5. |

The weights and thresholds are editorial choices. Scores favor explicit controls. Browser defaults, nonce/hash policies, interactions across complex policies, feature delegation and browser support need manual review. Some restrictive policies fall outside the recognized subset and earn zero. A full score does not assess script behavior, framing by a specific parent, MIME correctness, TLS quality or site-wide coverage. Deprecated X-XSS-Protection and HPKP carry no weight.

Only HTTP 200 HTML responses receive scores. Error responses, recognizable challenge headers, other media types and transport failures receive a null score. An unmarked 200 intermediary page can resemble the origin. Check evidence before comparing results. Header values are recorded as separate fields in wire order where available. Only the seven scoped header names are exported.

### Dataset and billing

Inspect inputUrl, finalUrl, httpStatus, checkedAt, headersObserved, findings, score, scoreVersion, evidence and limitations. An empty header array means the field was absent in the observed response. A null score is never a zero score. Under pay-per-event pricing the sole custom event is `url-assessment`, one per completed scored URL, with no per-finding, redirect or retry fee. Unscored rows are diagnostic.

### Workflow examples

- **n8n**: Schedule Trigger → HTTP Request (POST the Actor runs endpoint with JSON input and a stored Bearer credential) → poll the returned run ID until SUCCEEDED → GET the default dataset items → IF score is numeric and below 60 → create a review task.
- **Make**: Run an Actor with a client URL list → wait for success → Get Dataset Items → filter on numeric score and scoreVersion → upsert by inputUrl into a client worksheet.
- **Clay**: Use an HTTP API enrichment to start a batch run, then import its dataset JSON or CSV after completion. Match rows by inputUrl, retain checkedAt, and send null scores to a coverage-review column.

API routes: POST /v2/acts/afkdigital~http-security-headers-grader/runs, GET /v2/actor-runs/{runId}, GET /v2/datasets/{defaultDatasetId}/items?clean=true. Store tokens in connection credentials.

### Rule references

[RFC 6797](https://www.rfc-editor.org/rfc/rfc6797), [CSP Level 3](https://www.w3.org/TR/CSP3/), [HTML framing processing](https://html.spec.whatwg.org/multipage/document-lifecycle.html#the-x-frame-options-header), [Fetch nosniff](https://fetch.spec.whatwg.org/#x-content-type-options-header), [Referrer Policy](https://www.w3.org/TR/referrer-policy/), [Permissions Policy](https://www.w3.org/TR/permissions-policy-1/).

# Actor input Schema

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

Authorized HTTP(S) documents, one URL per entry.

## `urlsFile` (type: `string`):

Public HTTPS plain text file, one URL per line, maximum 64 KiB. Choose this or URLs.

## `timeoutSeconds` (type: `integer`):

Total seconds per redirect chain.

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

Maximum redirect hops.

## `maxUrls` (type: `integer`):

Maximum unique inputs.

## `scoringProfile` (type: `string`):

Explicit HTML response controls.

## Actor input object example

```json
{
  "urls": [
    "https://example.com/"
  ],
  "timeoutSeconds": 10,
  "maxRedirects": 3,
  "maxUrls": 50,
  "scoringProfile": "html-baseline"
}
```

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

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/http-security-headers-grader").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://example.com/"] }

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/http-security-headers-grader").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://example.com/"
  ]
}' |
apify call afkdigital/http-security-headers-grader --silent --output-dataset

```

## MCP server setup

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

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/J07NDuMdyHKWSLZHE/builds/1bLaIEL7oOGXP8kaq/openapi.json
