π A comprehensive HTTP security headers analyzer for penetration testers and web developers.
- Overview
- Features
- Installation
- Usage
- Headers Analyzed
- Cookie Security Analysis
- Scoring System
- Output Examples
- Contributing
SecHeaderAudit is a powerful Python tool designed to analyze HTTP security headers of web applications. It provides a detailed assessment of security configurations with weighted scoring, visual feedback, and actionable recommendations for improving web application security.
- Comprehensive Header Analysis: Checks 7 critical security headers
- Weighted Scoring System: Prioritizes more important security headers
- Cookie Security Audit: Analyzes HttpOnly, Secure, and SameSite flags
- Visual Feedback: Color-coded results for quick assessment
- Actionable Recommendations: Specific guidance for security improvements
- Professional Reporting: Clean, formatted output suitable for client reports
- Python 3.6+
- pip package manager
pip install requests coloramasudo apt-get install figlet lolcat # Debian/Ubuntu
# or
brew install figlet lolcat # macOSgit clone https://github.com/OusH4x/SecHeaderAudit.git
cd SecHeaderAuditpython3 SecHeaderAudit.py -u https://example.comusage: SecHeaderAudit.py [-h] -u URL
SecHeaderAudit - HTTP Security Headers Analyzer
options:
-h, --help show this help message and exit
-u URL, --url URL URL to analyze| Header | Importance | Description | Weight |
|---|---|---|---|
| Strict-Transport-Security (HSTS) | π΄ Critical | Enforces HTTPS connections | 3.0 |
| Content-Security-Policy (CSP) | π΄ Critical | Prevents XSS attacks | 3.0 |
| X-Content-Type-Options | π High | Prevents MIME type sniffing | 2.0 |
| X-Frame-Options | π High | Prevents clickjacking attacks | 2.0 |
| Referrer-Policy | π High | Controls referrer information | 2.0 |
| Permissions-Policy | π High | Controls browser features | 2.0 |
| X-XSS-Protection | π‘ Medium | Legacy XSS protection | 1.0 |
The tool analyzes Set-Cookie headers for three critical security flags:
| Flag | Importance | Protection Against |
|---|---|---|
| HttpOnly | π΄ Critical | XSS attacks accessing cookies |
| Secure | π΄ Critical | Cookie transmission over HTTP |
| SameSite | π High | CSRF attacks |
SecHeaderAudit uses a weighted scoring system to prioritize more critical security headers:
- Critical Headers (3.0): HSTS, CSP, Cookies
- High Importance (2.0): X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy
- Medium Importance (1.0): X-XSS-Protection
Total Score = Ξ£(Header Score Γ Header Weight)
Maximum Score = Ξ£(Max Header Score Γ Header Weight)
Final Percentage = (Total Score / Maximum Score) Γ 100
- 90-100%: Excellent security posture
- 70-89%: Good, with minor improvements needed
- 50-69%: Fair, several security enhancements required
- Below 50%: Poor, significant security issues
$ python3 SecHeaderAudit.py -u https://example.com
____ _ _ _ _ _ _ _
/ ___| ___ ___| | | | ___ __ _ __| | ___ _ __ / \ _ _ __| (_) |_
\___ \ / _ \/ __| |_| |/ _ \/ _` |/ _` |/ _ \ '__/ _ \| | | |/ _` | | __|
___) | __/ (__| _ | __/ (_| | (_| | __/ | / ___ \ |_| | (_| | | |_
|____/ \___|\___|_| |_|\___|\__,_|\__,_|\___|_|/_/ \_\__,_|\__,_|_|\__|
Made by OusH4x
Analyzing security headers for: https://example.com
Security Headers Analysis for: https://example.com
================================================
Security Score: 15.5/19.0 (81.6%)
Header Analysis:
----------------
HSTS: β - max-age=31536000; includeSubDomains (2.0/2.0)
CSP: β - default-src 'self'; script-src 'self' 'unsafe-inline'... (1.0/1.0)
X-Content-Type-Options: β - nosniff (1.0/1.0)
X-Frame-Options: β - SAMEORIGIN (1.0/1.0)
X-XSS-Protection: β - 1; mode=block (1.0/1.0)
Referrer-Policy: β - strict-origin-when-cross-origin (1.0/1.0)
Permissions-Policy: β - geolocation=(), microphone=()... (1.0/1.0)
Cookie Analysis:
-----------------
Set-Cookie: sessionId=abc123; Secure; HttpOnly; SameSite=Strict
HttpOnly: β
Secure: β
SameSite: β
Cookie Security Score: 3.0/3.0
Recommendations:
----------------
- Improve HSTS: includeSubDomains and max-age>=31536000
Security Score: 7.0/19.0 (36.8%)
Header Analysis:
----------------
HSTS: β - Missing (0.0/2.0)
CSP: β - Missing (0.0/1.0)
X-Content-Type-Options: β - Missing (0.0/1.0)
X-Frame-Options: β - DENY (1.0/1.0)
X-XSS-Protection: β - Missing (0.0/1.0)
Referrer-Policy: β - Missing (0.0/1.0)
Permissions-Policy: β - Missing (0.0/1.0)
Cookie Analysis:
-----------------
Set-Cookie: session=abc123; path=/
HttpOnly: β
Secure: β
SameSite: β
Cookie Security Score: 0.0/3.0
Recommendations:
----------------
- Implement HSTS to enforce HTTPS connections
- Add Content Security Policy to prevent XSS attacks
- Set X-Content-Type-Options to 'nosniff'
- Enable X-XSS-Protection for legacy browsers
- Set Referrer-Policy to control referrer information
- Implement Permissions-Policy for feature control
- Add HttpOnly flag to cookies to prevent XSS access
- Add Secure flag to cookies for HTTPS-only transmission
- Implement SameSite attribute for CSRF protection
We welcome contributions! Please feel free to submit pull requests, report bugs, or suggest new features.
- Batch scanning of multiple URLs
- JSON/CSV export functionality
- Comparison with OWASP security standards
- Integration with CI/CD pipelines
- Historical tracking of security improvements
SecHeaderAudit - Because security headers shouldn't be an afterthought.