Core Security Features
Content Security Policy (CSP)
OSINT Hub implements a strict Content Security Policy to prevent cross-site scripting (XSS) attacks and unauthorized content injection. Configuration (osint_hub/settings.py:186-234):csp.middleware.CSPMiddleware) is active in the middleware stack (line 44) and enforces these policies on every response.
CSP_REPORT_ONLY is set to
False by default, meaning violations are blocked. Monitor your browser’s console during development to identify legitimate resources that may need to be whitelisted.HTTP Strict Transport Security (HSTS)
In production mode (whenDEBUG=False), OSINT Hub enforces HTTPS connections through HSTS headers:
- Forces browsers to use HTTPS for 1 year
- Applies to all subdomains
- Qualifies for browser HSTS preload lists
Cross-Site Request Forgery (CSRF) Protection
Django’s CSRF middleware (django.middleware.csrf.CsrfViewMiddleware) is enabled (line 43) to prevent unauthorized state-changing requests.
Key configurations:
Set the
CSRF_TRUSTED_ORIGINS environment variable to a comma-separated list of trusted domains when deploying (e.g., "https://osinthub.example.com,https://www.osinthub.example.com").Clickjacking Protection
X-Frame-Options protection prevents the application from being embedded in frames:XFrameOptionsMiddleware (line 47) sets the X-Frame-Options: DENY header on all responses in production.
Additional Security Headers
In production mode, additional security headers are automatically set:- X-XSS-Protection: Enables browser XSS filtering
- X-Content-Type-Options: Prevents MIME type sniffing
Input Validation & Sanitization
Email Validation
Email inputs are validated using regex patterns before processing (email_holehe/views.py:19-23):Username Validation
Username inputs are validated through Django forms with strict character whitelisting (UsernameSearch/forms.py:21-34):Command Injection Prevention
External tools are invoked using subprocess with explicit argument lists (never shell=True):Timeout Protection
Task Timeouts
Celery tasks have strict time limits to prevent resource exhaustion:Request Timeouts
External tool invocations include timeout protection:Password Security
Django’s built-in password validators ensure strong password policies (osint_hub/settings.py:86-99):- Password must not be similar to user attributes
- Minimum length requirements
- Protection against common passwords
- Prevention of all-numeric passwords
Secret Management
Environment Variables
Sensitive configuration is loaded from environment variables using python-decouple:Production Security Checklist
Before deploying to production:- Set DEBUG=False - Disables debug mode and activates security features
- Configure SECRET_KEY - Use a strong, random secret key
- Set ALLOWED_HOSTS - List all valid hostnames for your deployment
- Configure CSRF_TRUSTED_ORIGINS - List all trusted domains
- Enable SSL/TLS - Configure HTTPS and update
CSRF_COOKIE_SECUREto True - Review CSP policies - Ensure all legitimate resources are whitelisted
- Secure Redis - Configure authentication for Celery’s Redis broker
- Database security - Use strong credentials and restrict network access
Security Monitoring
Monitor your application for:- CSP violation reports in browser console
- Failed authentication attempts
- Unusual task execution patterns
- Timeout errors that may indicate DoS attempts
Consider implementing centralized logging and monitoring tools to track security events across your deployment.
