# Security Headers and robots.txt Check: graded, in bulk (`examsens.ai/security-headers-check`) Actor

Checks many URLs for HSTS, CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy and Permissions-Policy, grades each from A to F, tests the HTTP to HTTPS redirect and cookie flags, and fetches and parses the site's robots.txt.

- **URL**: https://apify.com/examsens.ai/security-headers-check.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** Developer tools, SEO tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $18.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 and robots.txt Check: graded, in bulk

Give it a list of URLs and it returns, for each one, the security headers the server sends, what each value means, a score out of 100 with a grade from A to F, whether the plain `http://` address moves visitors to HTTPS, how the page's cookies are flagged, and the site's robots.txt parsed into rules.

### What is checked

The URL is requested with redirects followed, and the final page's headers are read. Only the headers are read; the page body is not downloaded.

- Strict-Transport-Security: present, `max-age`, `includeSubDomains`, `preload`. A header sent over plain HTTP is reported and scores 0.
- Content-Security-Policy: the directives it sets, and weaknesses in `script-src` (or `default-src` when there is no `script-src`): `'unsafe-inline'` without a nonce, hash or `'strict-dynamic'`, `'unsafe-eval'`, and wildcard or scheme sources such as `*` or `https:`. A report-only policy is listed separately.
- X-Frame-Options: `DENY` or `SAMEORIGIN`. A CSP `frame-ancestors` directive counts in its place.
- X-Content-Type-Options: `nosniff`
- Referrer-Policy: the policy that applies, the last known one in the list
- Permissions-Policy: present, and the features it names
- HTTPS: whether the final page is HTTPS, and whether the `http://` address of an HTTPS URL ends on HTTPS
- Cookies: name, `Secure`, `HttpOnly` and `SameSite` for each `Set-Cookie` header. Cookie values are never stored.
- Disclosure: the `Server`, `X-Powered-By`, `X-AspNet-Version`, `X-AspNetMvc-Version` and `X-Generator` headers, with an issue when one carries a version number
- Other headers, listed without scoring: `Cross-Origin-Opener-Policy`, `Cross-Origin-Embedder-Policy`, `Cross-Origin-Resource-Policy`, `X-XSS-Protection`

### The grade

The six headers share 100 points.

| Header | Full points | Partial points |
| --- | --- | --- |
| Strict-Transport-Security | 25 with a `max-age` of one year (31,536,000 seconds) or more | 15 with a shorter `max-age` above 0 |
| Content-Security-Policy | 25 when enforced with none of the weaknesses above | 15 when enforced with a weakness, 5 when report-only |
| X-Frame-Options | 15 for `DENY`, `SAMEORIGIN` or a CSP `frame-ancestors` directive | n/a |
| X-Content-Type-Options | 10 for `nosniff` | n/a |
| Referrer-Policy | 15 for `no-referrer`, `same-origin`, `strict-origin`, `strict-origin-when-cross-origin`, `origin` or `origin-when-cross-origin` | 5 for `unsafe-url` or `no-referrer-when-downgrade` |
| Permissions-Policy | 10 when present | n/a |

A missing header scores 0. The grade follows the score: A from 90, B from 75, C from 60, D from 40, and F below 40. A page whose final URL is not HTTPS is graded F whatever its score. Cookie flags and disclosure headers are reported as issues but do not change the score.

### robots.txt

The robots.txt file of the final URL's host is fetched and parsed into groups of user agents with their `allow` and `disallow` rules and crawl delay, plus the sitemaps it names and any lines it does not recognize. For each user agent you list (default `*`, `Googlebot`, `Bingbot` and `GPTBot`) you get whether that crawler is allowed to fetch the URL and the rule that decides it.

Matching follows RFC 9309: user agents match without regard to case, groups for the same agent are combined, the longest matching rule wins, `allow` wins a tie, `*` matches any characters and `$` anchors the end \[1]. A 4xx answer means crawlers are free to fetch everything, and a 5xx answer means they must treat the whole site as disallowed \[1]. Issues flag a robots.txt that disallows the whole site for all crawlers, answers with an HTML page, names no sitemap, has lines that are not recognized, or is larger than 500 KiB, the smallest parsing limit RFC 9309 allows \[1].

### Input

- URLs (required). An address without `http://` or `https://` is checked as `https://`.
- Fetch and parse robots.txt (default on) and the user agents to test
- Check the HTTP to HTTPS redirect (default on)
- Timeout per request (default 20 seconds), URLs checked at once (default 10), user agent

### Output

Dataset: one item per URL with `url`, `ok`, `status`, `finalUrl`, `redirectCount`, `https`, `httpRedirectsToHttps`, `httpRedirectError`, `grade`, `score`, `scoreBreakdown`, `headers` (one entry per scored header with its value and findings), `otherHeaders`, `disclosure`, `cookies`, `cookieIssues`, `issues`, `issueCount`, `robotsTxt` and `checkedAt`. A URL that cannot be reached gets an item with `ok` false and the reason in `error`. Export as JSON, CSV or Excel, or read it over the API.

### Pricing

Pay per event: one event per URL checked. URLs that cannot be reached and entries that are not valid URLs are reported and not charged.

### Scope and conduct

It makes at most three requests per URL: the page, its `http://` address, and robots.txt. It sends no forms, tries no attacks and does not log in.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

### References

\[1] RFC 9309, Robots Exclusion Protocol, sections 2.2.1, 2.2.2, 2.2.3, 2.3.1.3, 2.3.1.4 and 2.5. https://www.rfc-editor.org/rfc/rfc9309.html

# Actor input Schema

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

Pages to check, one per line. An address without http:// or https:// is checked as https://. Redirects are followed and the final page's headers are graded.

## `checkRobotsTxt` (type: `boolean`):

Read robots.txt from the final URL's host and test the URL against the user agents below.

## `robotsUserAgents` (type: `array`):

For each one, robots.txt is checked to see whether that crawler may fetch the URL. \* stands for any crawler without its own group.

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

Also request the http:// version of each HTTPS URL and report whether it ends on HTTPS.

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

How long to wait for each response.

## `maxConcurrency` (type: `integer`):

How many URLs are checked at the same time.

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

The User-Agent header sent with every request. Leave empty to send Mozilla/5.0 (compatible; SecurityHeadersCheck/1.0).

## Actor input object example

```json
{
  "urls": [
    "https://github.com",
    "https://example.com",
    "apify.com"
  ],
  "checkRobotsTxt": true,
  "robotsUserAgents": [
    "*",
    "Googlebot",
    "Bingbot",
    "GPTBot"
  ],
  "checkHttpRedirect": true,
  "timeoutSecs": 20,
  "maxConcurrency": 10
}
```

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

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/security-headers-check").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://github.com",
        "https://example.com",
        "apify.com",
    ] }

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

```

## MCP server setup

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

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/ducj3bwRbsqLM5qsI/builds/dVPMvntEuKyaly9xY/openapi.json
