Zero-dependency HTTP security-header auditor. Point it at any URL and get a securityheaders.com-style grade (A+ β¦ F) for the site's response headers, with a line-by-line list of exactly what's missing and the exact header value to fix it.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
hdrscope β security header audit
target : https://github.com
status : HTTP 200
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
SCORE 77/100 GRADE [ B ] 5/9 checks pass
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
HEADER CHECKS
β HSTS 15/15 max-age=31536000; includeSubDomains
β Content-Security-Policy 20/20 no unsafe script sources detected
β X-Content-Type-Options 10/10 nosniff
β Clickjacking protection 10/10 DENY (CSP frame-ancestors also set)
β Referrer-Policy ...
β Cross-Origin-Opener-Policy 0/5 absent
β Add: Cross-Origin-Opener-Policy: same-origin
...
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
HTTP response headers are the cheapest, highest-leverage hardening control you
own: CSP kills XSS payload delivery, HSTS kills protocol downgrade SSL-stripping,
X-Content-Type-Options: nosniff kills MIME confusion attacks, and cookie
attributes kill session hijacking. Every web-audit checklist starts here
(OWASP Secure Headers Project, Mozilla Observatory) β and it's the first
thing an attacker's recon script checks too.
The usual workflow is a browser tab on a SaaS scanner, which doesn't fit
automation: you can't run securityheaders.com in CI, can't diff grades between
deploys, and can't audit 60 origins before a standup. hdrscope is the missing
CLI: one file of pure-stdlib Python, no plugins, no daemon, no API key.
pip install . && hdrscope https://example.comExit codes double as a CI gate, JSON output feeds your dashboards, and every failing check prints the copy-pasteable header fix.
- 9 graded checks + 4 advisories covering HSTS, CSP (incl.
unsafe-inline,unsafe-eval, wildcard-source detection inside script contexts), MIME sniffing, clickjacking (X-Frame-Options or CSPframe-ancestors), Referrer-Policy, Permissions-Policy, COOP/CORP, and cookie flags (Secure/HttpOnly/SameSite) β plus unscored advisories for version disclosure, tech disclosure, legacy headers, and caching. - Weighted scoring & letter grades close in spirit to the big scanners: CSP carries the most weight because XSS does the most damage.
- Real-world parser quirks handled β comma-separated Referrer-Policy lists,
multiple
Set-Cookielines,frame-ancestorsin CSP vs legacy XFO, redirect chains (audits the final response). - Text + JSON output, exits 0/1/2 for clean CI gating on
--min-grade. - Zero runtime dependencies. Python β₯ 3.9 standard library only.
From a clone of this repo:
git clone https://github.com/mehulpatel23b-pixel/hdrscope.git
cd hdrscope
pip install . # installs the `hdrscope` entry pointor run it straight from source without installing anything:
PYTHONPATH=src python3 -m hdrscope https://example.comRequirements: Python 3.9+ and nothing else. There is no requirements.txt
to satisfy because the standard library is the dependency list.
hdrscope URL [URL...] [--json] [--timeout N] [--min-grade GRADE]
| Flag | Meaning |
|---|---|
URL |
one or more targets; https:// is assumed if you omit the scheme |
--json |
machine-readable report on stdout (text report goes to stderr-free stdout otherwise) |
--timeout N |
per-request timeout in seconds (default 15) |
--min-grade GRADE |
fail (exit 1) if any target grades below GRADE; one of A+ A B C D F |
| Code | Meaning |
|---|---|
0 |
all reachable targets graded at or above --min-grade |
1 |
at least one reachable target graded below --min-grade |
2 |
at least one target could not be reached at all |
# quick human-readable audit
hdrscope https://myapp.example.com
# gate a deploy: anything below a B fails the build
hdrscope https://staging.example.com --min-grade B
# whole estate before a standup
hdrscope https://a.example.com https://b.example.com https://c.example.com
# JSON for dashboards / diffing
hdrscope https://myapp.example.com --json > today.json
jq '.results[0].grade, .results[0].score' today.json- name: Security header regression gate
run: |
pip install .
hdrscope ${{ env.STAGING_URL }} --min-grade BFail the pipeline when a middleware refactor silently drops HSTS or your
CSP loses default-src. Pair with a daily cron job and you get alerted the
moment a deploy downgrades your header posture.
| Check | Header(s) | Weight | Full points when |
|---|---|---|---|
| HSTS | Strict-Transport-Security |
15 | max-age β₯ 15552000 (180 days; recommend 31536000) |
| Content-Security-Policy | Content-Security-Policy |
20 | present, no unsafe-inline/unsafe-eval/wildcard in script contexts |
| MIME sniffing | X-Content-Type-Options |
10 | exactly nosniff |
| Clickjacking | X-Frame-Options / CSP frame-ancestors |
10 | DENY/SAMEORIGIN or frame-ancestors present |
| Referrer-Policy | Referrer-Policy |
10 | no-referrer, same-origin, strict-origin, or strict-origin-when-cross-origin |
| Permissions-Policy | Permissions-Policy |
5 | present |
| COOP | Cross-Origin-Opener-Policy |
5 | same-origin (or equivalent) |
| CORP | Cross-Origin-Resource-Policy |
5 | same-origin/same-site/cross-origin |
| Cookie flags | Set-Cookie |
10 | every cookie has Secure, HttpOnly, SameSite (not None without Secure); no cookies = n/a |
Score = points earned Γ· points possible. Grades: A+ β₯ 97, A β₯ 90, B β₯ 75,
C β₯ 60, D β₯ 40, F below. Advisories (Server version disclosure,
X-Powered-By, legacy X-XSS-Protection, missing no-store) never affect
the score but are worth fixing.
flowchart LR
A[CLI<br/>urls + flags] --> B[fetch.py<br/>urllib GET<br/>follows redirects]
B -->|headers dict| C[audit.py<br/>rule engine<br/>9 weighted checks]
C --> D[scoring + grading]
D --> E{text or JSON}
E --> F[exit code 0 / 1 / 2]
ββββββββββββββββ GET (final hop) βββββββββββββββββββββββββββββββ
β cli.py β βββββββββββββββββββββΊ β fetch.py β
β argparse, β response headers β normalize_url, urllib, β
β exit codes β βββββββββββββββββββββ β redirect follow, error map β
ββββββββ¬ββββββββ ββββββββββββββββ¬βββββββββββββββ
β report β {header: [values]}
βΌ βΌ
ββββββββββββββββ Check(status, weight, earned) βββββββββββββββββββββββ
β text/json β ββββββββββββββββββββββββββββββββ β audit.py β
β rendering β AuditResult(score, grade) β pure functions, β
ββββββββββββββββ β unit-testable β
βββββββββββββββββββββββ
The rule engine is deliberately pure: it consumes a plain {header: [values]} map,
so every check, weight and grade boundary is tested without any network
(python -m unittest spins up throwaway local HTTP servers for the two
end-to-end paths). Fetching is isolated in fetch.py so the evaluation logic
never touches sockets.
- Pre-launch hardening β run against staging the week before launch and burn down the fix list before the world (and its bots) arrive.
- CI regression gate β
--min-grade Bmakes "the load balancer started stripping HSTS" a build failure instead of a pentest finding six months later. - Estate audits β loop your 50 hostnames through one command; JSON output gives you a sorted, diffable posture snapshot.
- Cookie flag verification β confirm
Secure/HttpOnly/SameSiteactually made it into production after that session-cookie refactor. - Header parity checks β diff grades or
--jsonoutput between dev, staging and prod to catch config drift in reverse proxies and CDNs. - Pentest triage prep β walk into an engagement with the obvious client-side findings already documented, so paid time goes deeper.
- Security awareness demos β the A+ to F scale makes an instantly understandable demo for teaching developers why headers matter.
β οΈ hdrscope is a defensive auditing tool. It performs a single plain GET request per target β nothing more invasive than visiting the page in a browser. Use it only against systems you own or are explicitly authorized to test (your own sites, your employer's estate under the applicable rules of engagement, an engagement with written scope). Scanning third-party systems without permission is unlawful in most jurisdictions even with a harmless request. The tool never attempts exploitation, credential access, bypass, or scanning β one GET, header analysis, report. If you're looking for a weapon you're in the wrong repo; hdrscope is a seatbelt, not a crowbar.
git clone https://github.com/mehulpatel23b-pixel/hdrscope.git
cd hdrscope
PYTHONPATH=src python3 -m unittest discover -s tests # 26 tests, no networkTest layout: tests/test_hdrscope.py covers the grading scale, every check's
good/warn/missing boundary conditions (including comma-policy and multi-cookie
quirks), URL normalization, and two end-to-end audits against disposable local
HTTP servers.
MIT Β© Mehul Patel β see LICENSE.