Security Headers Checker avatar

Security Headers Checker

Pricing

$0.01 / actor start

Go to Apify Store
Security Headers Checker

Security Headers Checker

Pricing

$0.01 / actor start

Rating

0.0

(0)

Developer

Eichan Jolly

Eichan Jolly

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

13 days ago

Last modified

Categories

Features

Limited permissions

Share

Actor slug: security-headers-checker
Apify Store categories (declare on listing): DEVELOPER_TOOLS
Suggested price: $0.002 per result (one dataset item per run; recommendation only, not configured).
Audience: Web developers, site maintainers, QA engineers, and small security teams.

What it does

Fetches only the first HTTP response for one public HTTP or HTTPS URL and reports presence/absence and public values of six headers:

  • Strict-Transport-Security (HTTPS only)
  • Content-Security-Policy
  • X-Content-Type-Options
  • X-Frame-Options
  • Referrer-Policy
  • Permissions-Policy

This is a presence check, not a full audit of header directives or site security. HTTP responses with any status code, including 3xx/4xx/5xx, are inspected. Redirects are never followed; a Location is not fetched. A header absent on the response is marked missing, except HSTS on HTTP, which is marked not applicable.

Tiny example input

{
"url": "https://example.com/"
}

Example output (illustrative, from the included local test fixture)

{
"url": "https://example.com/",
"status_code": 200,
"is_https": true,
"headers_present": [
"strict-transport-security",
"content-security-policy",
"x-content-type-options",
"referrer-policy"
],
"headers_missing": ["x-frame-options", "permissions-policy"],
"headers_not_applicable": [],
"header_values": {
"strict-transport-security": "max-age=31536000",
"content-security-policy": "default-src 'self'",
"x-content-type-options": "nosniff",
"x-frame-options": null,
"referrer-policy": "strict-origin-when-cross-origin",
"permissions-policy": null
},
"error": null
}

The live example.com site may return different headers. Every run produces exactly one item with these fields. Failure items have error as a plain-English string; HTTP-specific fields remain null or empty lists when unknown.

Limits and security

  • Exactly one URL, maximum 2,048 characters, scheme http or https only; default port 80 or 443 (explicit public ports are permitted).
  • Only DNS and the specified URL are contacted. No login, no passwords, no cookies, no following redirects, no body download, no write to the target, no crawling additional endpoints.
  • Resolves the hostname once and pins the outbound socket to a resolved public IP. Rejects any DNS resolution containing a non-global/private/loopback address, and rejects embedded URL credentials. Allows only public IP destinations.
  • 8-second connection timeout; one attempt; no proxy rotation, retries, or bypass of access controls.
  • HTTPS certificate validation is enabled. Certificates that fail verification produce a plain-language error item.
  • Headers show presence, not security correctness: e.g. Content-Security-Policy may exist but still be permissive. Header values are truncated at 1,000 characters.
  • No third-party packages or Apify SDK. requirements.txt intentionally has no dependencies.

Run locally

From the Actor folder, provide input through either ACTOR_INPUT_JSON or storage/key_value_stores/default/INPUT.json, then execute the script:

$ACTOR_INPUT_JSON='{"url":"https://example.com/"}' python src/main.py

Or create the file storage/key_value_stores/default/INPUT.json:

{"url":"https://example.com/"}

Then run python src/main.py. The local dataset item is stored under storage/datasets/default/000000001.json (or an incremented filename). Set APIFY_LOCAL_STORAGE_DIR to choose another local storage folder.

On Apify, the Actor reads the default input key-value store and posts one item to its own default dataset using the platform-provided APIFY_TOKEN. No visitor/customer credentials are requested or used. This token is only for Apify storage I/O, never for a target website. No event billing, publication, or price configuration is included.

Reproducible verification

python tests/run_smoke.py
python -m unittest discover -s tests -p 'test_*.py' -v

The smoke runner really executes python src/main.py with valid JSON, runs a local TLS fixture with example.com test certificate, checks the created dataset JSON, and writes verification/script-mode-smoke.txt and verification/dataset-item.json. A test-only sitecustomize.py routes the test endpoint to a loopback fixture; it is not shipped in the Docker image. No live example.com request is claimed in this offline test.

See tests/ for all rerunnable test code and fixture certificate. For real production verification, build and run on Apify with the prefilled input; cloud build and live networking were not tested here.