Skip to content

About

High-performance async FastAPI backend for External Attack Surface Management (EASM). Deep TLS/SSL inspection, anti-SSRF, DNS hygiene, socket-level anti-rebinding, and OASIS SARIF 2.1.0 export.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Python FastAPI PostgreSQL

tests SARIF Docker license

Architecture · API · Quick start · License

 

🪄 About

SecuScan API is a high-performance backend for External Attack Surface Management (EASM). It evaluates the security posture of domains and hosts you own: TLS/SSL certificates, defensive HTTP headers, DNS security records (SPF, DMARC, DKIM), port scanning with DNS-rebinding protection, and passive subdomain discovery through Certificate Transparency (crt.sh). Every scan ends in a Security Posture Score (0–100, A+ to F) and an executive report in Markdown or SARIF 2.1.0.

Important

Scanning infrastructure you don't own is blocked by design: a domain must be verified with a DNS TXT record (_secuscan-challenge.<domain>) before any scan is authorized.

 

✨ Features

🔎 Passive subdomain discovery Public Certificate Transparency logs (crt.sh) map active subdomains without sending intrusive traffic to the target.
🔐 TLS / SSL deep inspection Obsolete protocols (TLS 1.0, TLS 1.1, SSLv3), expiry dates, self-signed certificates and weak signature algorithms.
🧱 Security headers Strict validation of Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options, X-Frame-Options and Referrer-Policy.
📧 Mail and DNS hygiene Syntax and policy checks for SPF (permissive ~all / ?all), DMARC (p=reject / quarantine / none) and DKIM selectors.
🚪 Async port scanning IP resolved first and connected to directly at socket level, which removes DNS-rebinding attacks from port scans (1–1024).
📊 Posture score A single 0–100 score with a risk grade: A+ (95–100), A (85–94), B (70–84), C/D (40–69), F (<40).
📄 Reports Executive Markdown (comparison tables, penalty factors, a prioritized action plan) and OASIS SARIF 2.1.0 for GitHub Code Scanning, GitLab Security Dashboard and DefectDojo.
🛡️ Production hardening Every HTTP 3xx hop is inspected (no redirects to 169.254.169.254 or private ranges), the container runs as non-root appuser (UID 1000), and PostgreSQL lives only on Docker's internal network.
What each grade means
Grade Score Meaning
A+ 95–100 Optimal defensive posture, complete headers and modern encryption
A 85–94 Solid posture with minor recommendations
B 70–84 Moderate warnings (missing secondary headers or a permissive SPF)
C / D 40–69 Exposed risk (no HSTS/DMARC, certificates close to expiry)
F <40 Critical risk (database/RDP ports exposed, expired certificate or broken protocols)

 

🏛️ Architecture

flowchart TD
    subgraph Client["Clients & integrations"]
        CLI["Web frontend / CI/CD pipeline / curl"]
    end
    subgraph Gateway["Authentication & access control"]
        AUTH["JWT Bearer auth<br/>(password hashing with Passlib)"]
        RATELIMIT["In-memory rate limiter<br/>(sliding window per user)"]
        VERIFY["Domain ownership verifier<br/>(random DNS TXT token)"]
    end
    subgraph TargetSecurity["Hardening & anti-abuse"]
        GUARD["Anti-SSRF target guard<br/>(blocks private IPs / metadata 169.254)"]
        REDIRECT["3xx redirect validator<br/>(hop-by-hop inspection)"]
        SOCKET["Socket bound to a pinned IP<br/>(anti DNS rebinding)"]
    end
    subgraph ScannerCore["Perimeter audit engine"]
        DNS["DNS scanner<br/>(A, AAAA, MX, NS, SPF, DMARC, DKIM)"]
        TLS["TLS/SSL scanner<br/>(protocols, chain, days to expiry)"]
        HDR["HTTP headers scanner<br/>(HSTS, CSP, X-Frame, X-Content-Type)"]
        PORTS["Async port scanner<br/>(critical ports 1-1024)"]
        SUBD["Passive subdomain discovery<br/>(Certificate Transparency crt.sh)"]
    end
    subgraph Analytics["Scoring & export"]
        SCORE["Security posture engine<br/>(score 0-100, grade A+ to F)"]
        REPORT["Report generator<br/>(executive Markdown & SARIF 2.1.0)"]
        DB[(PostgreSQL / history)]
    end
    CLI --> AUTH --> RATELIMIT --> VERIFY --> GUARD --> REDIRECT --> ScannerCore
    ScannerCore --> SCORE --> REPORT --> CLI
    SCORE --> DB
Loading

 

📡 API endpoints

Method Endpoint Description
POST /auth/register Register a user with a secure hash (bcrypt)
POST /auth/login Authenticate and issue a JWT Bearer token
POST /domains/verify/initiate Generate a random DNS TXT verification token
POST /domains/verify/check Resolve the TXT record and validate domain ownership
POST /scan/headers Security headers audit
POST /scan/tls TLS certificate and protocol inspection
POST /scan/dns SPF, DMARC and DKIM evaluation
POST /scan/ports TCP port range scan
POST /scan/subdomains Passive discovery through Certificate Transparency (crt.sh)
POST /scan/full Every module at once, plus the posture score
GET /scans Paginated scan history for the user
GET /scans/{id} Full findings per module
GET /scans/{id}/report Report export (format=markdown or format=sarif)

 

🚀 Quick start

Requirements: Python 3.12+, and Docker with Docker Compose for production (PostgreSQL).

git clone https://github.com/h3n-x/secuscan-api.git
cd secuscan-api
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
pytest tests/

With Docker Compose:

docker compose -f docker-compose.prod.yml up -d --build

 

Copyright © 2026 h3n-x

MIT License

About

High-performance async FastAPI backend for External Attack Surface Management (EASM). Deep TLS/SSL inspection, anti-SSRF, DNS hygiene, socket-level anti-rebinding, and OASIS SARIF 2.1.0 export.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages