Security Guide
This page summarises the security practices that the project documents in SECURITY.md and README.md. It is the canonical reference for how we protect credentials, handle disclosures and harden a deployment of Crisis-Monitor.
Reporting a vulnerability
Report suspected vulnerabilities privately. Use GitHub Security Advisories for this repository or email the maintainers listed in CONTRIBUTING.md. Do not open a public issue for exposed secrets or implementation weaknesses. When in doubt, send a short message describing the component that looks suspicious and a maintainer will coordinate a fix.
Protecting secrets and configuration
The application never stores live credentials in the repository. Follow these steps when preparing an environment:
- Copy
.env.exampleto.envfor local development only. Do not commit the file. Generate high-entropy values for
SECRET_KEY, API tokens and service passwords withpython -c "import secrets; print(secrets.token_hex(32))"and store them in a managed secret vault (AWS Secrets Manager, Google Secret Manager, Vault, &c.).import secrets len(secrets.token_hex(32)) 64
Inject secrets via environment variables at runtime. Production deployments should rely on the hosting platform or container orchestrator to provide the values securely.
- Set
APP_ENV=productionin production environments so the correct configuration and logging settings load automatically. The deprecatedFLASK_ENVvariable is ignored on purpose.
Mail credentials, webhook tokens and third-party API keys are optional but should be supplied through the same mechanism. The admin UI exposes a /admin section that lets superusers verify that background tasks and notifications are configured correctly once the secrets are present.
Public read-only mode
Set PUBLIC_READ_ONLY_MODE=true only when the public dashboards and incident pages should open without a login prompt. The anonymous identity receives only incident-view permissions. The request boundary rejects non-safe HTTP methods, mixed GET/POST form routes, state-changing GET endpoints and all /admin surfaces. Staff authentication remains available at /login and restores the normal role and permission model for that session.
Do not replace this mode with an automatic admin login. Public requests must never inherit an operator ID, API token, saved filters or write permissions.
Dependency audit policy
Security advisories are not suppressed in the production dependency gate. WeasyPrint is constrained to 69.x or newer within the supported major line, which includes the upstream fix for CVE-2026-49452. The compromised deep-translator package is not allowed in production; translation uses QazCompute first and the configured DeepSeek-compatible API only as fallback through services/translation_service.py.
Hardening checklist
Use the quick checks below when deploying or reviewing an instance:
- Run
flask --app app:create_app db upgradebefore the first start to ensure the database schema is up to date. - Start the service with
python run.pyso that custom flags such as--reset,--seed,--hostand--portare available and the background scheduler can initialise correctly. - Review the cron jobs recommended in the README to run
backup.py, execute log cleanup and send reminder emails whenAPP_ENV=production. The built-in scheduler is meant for development only. - Enable HTTPS for all public endpoints, especially
/api/v1/*routes, and setSESSION_COOKIE_SECURE=truein production to prevent cookies from being sent over HTTP. - Monitor the
/admin/monitoringdashboard or the Prometheus endpoints exposed byservices/monitoringto confirm that periodic health checks succeed.
Dependency hygiene
Automated checks keep the dependency stack healthy:
- CI executes
pip-auditagainstrequirements.txtandrequirements-dev.txtand runsnpm audit --productionfor the frontend bundle. - Dependabot opens weekly pull requests for Python packages, npm dependencies, Docker images and GitHub Actions workflows. Review the changelog that it links, rebuild the environment with
./setup-dev.shandnpm ci, and run the full test suite before merging. - Local developers can mirror the CI checks with
tox -e lint,mypy,make coverage,npm run test:frontendandnpm run buildbefore pushing.
Staying on top of these automated checks and following the secret-handling process drastically reduces the risk of introducing exploitable vulnerabilities.