Content Security Policy & HTTP Security Headers Analyzer
A blazing-fast Rust tool for analyzing security headers and detecting misconfigurations in web applications. Perfect for security audits, CI/CD integration, and compliance checks.
- Content Security Policy (CSP): Detects unsafe-inline, unsafe-eval, wildcards, and missing directives
- CORS: Identifies dangerous wildcard origins, credential misconfigurations, and overly permissive policies
- HSTS: Validates max-age, checks for includeSubDomains and preload directives
- X-Frame-Options: Prevents clickjacking with proper frame control analysis
- Cookie Security: Validates Secure, HttpOnly, and SameSite flags
- Additional Headers: Checks X-Content-Type-Options, Referrer-Policy, Permissions-Policy, and more
- Fast: Async I/O powered by Tokio
- Beautiful Output: Color-coded severity levels with clear recommendations
- Multiple Formats: Pretty CLI output, JSON for automation, or minimal mode
- Bulk Scanning: Scan multiple URLs from a file
- Export Results: Save findings to file for reporting
git clone https://github.com/alhamrizvi-cloud/cspy.git
cd CSPy
cargo build --releaseThe binary will be at target/release/cspy
cargo install --path .cspy https://example.comcspy -i urls.txtcspy https://example.com --output jsoncspy https://example.com -f report.json --output jsoncspy https://example.com --silentcspy https://example.com -A "MyScanner/1.0"Usage: cspy [OPTIONS] [URL]
Arguments:
[URL] Target URL to scan
Options:
-i, --input <FILE> Input file containing URLs (one per line)
-o, --output <FORMAT> Output format [default: pretty] [possible values: pretty, json, minimal]
-f, --output-file <FILE> Save results to file
-s, --silent Silent mode (minimal output)
-r, --redirect Follow redirects [default: true]
--max-redirects <NUM> Maximum redirects to follow [default: 10]
-t, --timeout <SECONDS> Request timeout in seconds [default: 10]
-A, --user-agent <STRING> Custom User-Agent
-h, --help Print help
-V, --version Print version
______ ______ ______ __ __
/\ ___\ /\ ___\ /\ == \ /\ \_\ \
\ \ \____ \ \___ \ \ \ _-/ \ \____ \
\ \_____\ \/\_____\ \ \_\ \/\_____\
\/_____/ \/_____/ \/_/ \/_____/
Content Security Policy & HTTP Security Headers Analyzer
By Security Researcher | v0.1.0
โ https://example.com
Status: 200
โ Issues found:
2 High
3 Medium
1 Low
[HIGH] CSP: CSP allows 'unsafe-inline'
โ Remove 'unsafe-inline' and use nonces or hashes for inline scripts/styles
[MEDIUM] HSTS: Missing Strict-Transport-Security header
โ Add 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' to enforce HTTPS
[MEDIUM] X-Frame-Options: Missing X-Frame-Options header
โ Add 'X-Frame-Options: DENY' or use CSP 'frame-ancestors 'none'' to prevent clickjacking
Checks for:
- โ Missing CSP header
- โ
unsafe-inlineorunsafe-eval - โ Wildcard sources in
script-src - โ Missing
default-srcorobject-src - โ Unsafe
base-uriorform-action
Best Practice:
Content-Security-Policy: default-src 'self'; script-src 'self' cdn.example.com; object-src 'none'; base-uri 'self'Checks for:
- โ Wildcard origin with credentials (CRITICAL)
- โ Null origin allowed
- โ HTTP origins
- โ Wildcard methods or headers
Best Practice:
Access-Control-Allow-Origin: https://trusted.example.com
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Credentials: trueChecks for:
- โ Missing HSTS header
- โ
max-ageless than 6 months - โ Missing
includeSubDomains - โ Missing
preloaddirective
Best Practice:
Strict-Transport-Security: max-age=31536000; includeSubDomains; preloadChecks for:
- โ Missing
Secureflag - โ Missing
HttpOnlyflag - โ Missing
SameSiteattribute - โ Invalid
__Host-or__Secure-prefix usage
Best Practice:
Set-Cookie: sessionid=abc123; Secure; HttpOnly; SameSite=Strict; Path=/โ
Security Audits: Quickly scan applications for header misconfigurations
โ
CI/CD Integration: Automate security checks in your pipeline
โ
Compliance: Validate PCI-DSS, SOC2, and other security requirements
โ
Bug Bounty: Find low-hanging fruit in header configurations
โ
DevSecOps: Shift-left security testing
cspy/
โโโ src/
โ โโโ main.rs # CLI and entry point
โ โโโ scanner.rs # HTTP client and orchestration
โ โโโ output.rs # Output formatting
โ โโโ checks/
โ โโโ mod.rs # Shared types
โ โโโ csp.rs # CSP analyzer
โ โโโ cors.rs # CORS analyzer
โ โโโ hsts.rs # HSTS analyzer
โ โโโ xframe.rs # X-Frame-Options analyzer
โ โโโ cookies.rs # Cookie security analyzer
โโโ Cargo.toml
โโโ README.md
cargo testcargo build --releaseCreate a urls.txt file:
https://example.com
https://api.example.com
https://admin.example.com
https://checkout.example.com
Then scan:
cspy -i urls.txt -f results.json --output jsonContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- OWASP for security best practices
- Mozilla for web security guidelines
- The Rust community for amazing tools
- WAF detection
- Technology fingerprinting
- HTTP/2 support
- Comparative analysis (HTTP vs HTTPS)
- Custom rule engine
- PDF report generation
- Web UI dashboard
Made with โค๏ธ and Rust
For security researchers, by security researchers