<!-- SPDX-FileCopyrightText: 2026 Science Against Authoritarianism Contributors -->
<!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->

# Security Policy — Pharos (*Science Against Authoritarianism*)

Pharos is built as a **zero-backend, offline-reproducible scientific portal and CLI**.
Its primary security and safety boundary is documented in [THREAT_MODEL.md](THREAT_MODEL.md):
**"Watch power, not people."**

## Security Architecture & Invariants

1. **Zero Backend, Zero Telemetry, Zero Trackers**
   - The static web portal (`site/`) makes **zero third-party network requests**, sets **zero cookies**, stores **zero analytics/telemetry**, and loads all scripts, stylesheets, charts, and datasets strictly from `'self'`.
   - Every outgoing reference link uses `rel="noopener noreferrer"` and `<meta name="referrer" content="no-referrer">` prevents leaking reader navigation paths to external servers.
2. **Strict Content Security Policy & HTTP Hardening**
   - Both `site/index.html` and static deployment headers (`site/public/_headers`) enforce a strict `Content-Security-Policy` (`default-src 'self'`, `object-src 'none'`, `form-action 'none'`, `frame-ancestors 'none'`), `X-Frame-Options: DENY`, `X-Content-Type-Options: nosniff`, `Strict-Transport-Security`, `Cross-Origin-Opener-Policy: same-origin`, `Cross-Origin-Resource-Policy: same-origin`, and restrictive `Permissions-Policy`.
   - Frontend Markdown/citation rendering passes all URLs through a strict scheme allowlist (`https:` and repo-relative paths only; `javascript:`, `data:`, `vbscript:`, protocol-relative `//`, and control characters are rejected) and escapes all HTML interpolation.
3. **Offline-First & Hardened Data Ingestion**
   - Routine verification (`make verify-offline`) runs with **zero network access** against SHA-256-pinned snapshots (`data/snapshots/manifest.json`) using Python's standard library only (zero third-party `pip` supply-chain dependencies).
   - Live snapshot refreshes (`make snapshot`, run only intentionally by maintainers) enforce **HTTPS-only transport**, **HTTPS-only redirects**, **SSRF blocking** of loopback/private/link-local/metadata IP literals and local hostnames, a **256 MiB response cap**, and **CSV formula-injection neutralization** (`=`, `+`, `@`, `-`, `\t`, `\r`).
4. **Local Development Server Containment**
   - `site/vite.config.js` resolves requested files via `fs.realpathSync()` against the repository root (preventing symlink escapes), blocks dotfiles (`.git`, `.env`, etc.) and non-allowlisted file types, and attaches hardening headers on dev and preview responses.
5. **Automated Enforcement (`Audit #11`)**
   - `python3 -m pharos.audit_security` (run in `make dashboard`, `make verify-offline`, and `make security`) continuously verifies CSP/headers, `noopener noreferrer`, zero unsafe Python/JS sinks, zero cleartext `http://` URLs, zero leaked secrets, and Vite symlink containment.
   - `python3 -m pharos.audit_threat_model` (`Audit #6`) enforces the data-granularity boundary (ISO-3 country/territory level only).

## Scope of Vulnerability Reports

We welcome security and safety reports covering:

- Cross-site scripting (XSS), HTML injection, open redirects, or CSP bypasses in the static portal (`site/`).
- Path traversal, symlink escape, SSRF, or unsafe deserialization/execution in Python CLI, indicator fetchers, or build tooling (`src/pharos/`, `site/vite.config.js`).
- Privacy, de-anonymization, or threat-model regressions that drop below the country/territory granularity ceiling (`THREAT_MODEL.md`).
- Supply-chain integrity issues in `site/package-lock.json`, `Dockerfile`, or `data/snapshots/manifest.json`.
- Accidental secret, credential, or personal-identity exposure.

## How to Report a Vulnerability

- **Current status:** The scrubbed, zero-telemetry static observatory is published anonymously at **[`https://pharos-observatory.pages.dev`](https://pharos-observatory.pages.dev)** while the underlying source repository remains private (see [docs/PUBLIC_IDENTITY_AND_RELEASE.md](docs/PUBLIC_IDENTITY_AND_RELEASE.md)).
- Once a neutral, project-scoped public source mirror is opened, security issues may also be reported privately via repository Security Advisories rather than opening a public issue.
- Please include: affected file/URL, reproduction steps or proof-of-concept, potential impact, and any suggested patch.
- **No exploit testing against third-party upstream APIs** (World Bank, OWID, V-Dem, Open Ownership, GI-TOC, UNODC); verify locally offline against committed snapshots.

## Verification

Anyone can audit the security posture locally with zero network access:

```bash
make security
make dashboard
make verify-offline
```
