Files

55 lines
4.7 KiB
Markdown

# Security
Server-side authorization and service boundaries protect data. Scanners check known vulnerabilities and selected risky patterns; they do not replace business-flow checks or an audit.
## Checks
From the repository root:
```sh
make -C security install
make -C security test check
make -C security images
```
| Tool | Current scope |
| --- | --- |
| Trivy filesystem | Repository dependencies, lockfiles and configuration |
| Gitleaks | Tracked and non-ignored files, complete available Git history |
| govulncheck | Use of vulnerable code in `backend/` |
| Semgrep | Local rules for `frontend/src/` and `ml/src/` |
| Trivy images | Exact local backend, frontend and ML image IDs |
These checks do not include separate runner/labd Go modules or images. The backend Go linter also runs gosec. Image checks need Docker; installation needs network access, Python, uv and Go. Tools are installed locally, and current versions are recorded with reports.
Trivy `HIGH`/`CRITICAL` findings, including unfixed vulnerabilities, block the check. Other scanner findings and tool errors fail too. Incomplete Git history and missing or corrupt reports are not success. Reports in `security/reports/` are local and redact secret values; review before sharing.
CI calls the same Make targets. A workflow file does not prove a successful run on the current code; releases need evidence from the actual run. Images must be checked alongside source lockfiles: a static frontend image does not contain every development dependency.
## Exceptions
[Trivy ignore](../../security/trivy/ignore.yml) contains a specific exception for `CVE-2026-93687`, `braces@3.0.3` in the frontend lockfile, until 2026-10-19. It was accepted when no fix was available; maintainers must remove it after updating or review it before expiry. It does not exclude all package versions or images.
The [Gitleaks allowlist](../../security/gitleaks/gitleaks.toml) limits exceptions to exact test examples, paths and rules. Manual review is due on 2026-11-07; Gitleaks does not enforce that date. New exceptions require a specific finding, reason, owner and expiry. Do not disable scanners or hide every unfixed vulnerability to make CI pass.
## Data and network boundaries
- Authorization, company membership, consent, publication and contact grants are checked on the server at each access. A cache, snapshot or hidden button is not authorization.
- Passwords, session tokens, one-time codes, contacts, resume text and request bodies must not enter logs or metric labels. Verification mail sends the code only to its recipient; API errors do not disclose internal error text.
- SeaweedFS stays on a separate internal network; browsers receive neither S3 keys nor direct bucket access. Some internal interfaces do not enforce S3 authentication, so network membership is tightly limited.
- Secrets belong in the local environment or secret files, not Git. Nginx does not publish readiness, metrics or administration interfaces.
## Outbound requests and ML
GitHub checking is disabled by default. It accepts only public `https://github.com/<owner>/<repo>` links, calls the fixed `api.github.com` origin, and bounds redirects, time and response size. An arbitrary URL cannot become a network destination. README and metadata remain untrusted data; they are not executed or rendered as user HTML. Tokens stay out of jobs and logs.
Backend sends ML only the allowed card and hiring-need projections, without contacts or private profiles. Every ML route except `/healthz` and `/readyz` requires a bearer token; without one, the service accepts loopback clients only. `/metrics` uses the same token, but the current Prometheus ML scrape does not yet send it. Restrict ML port access across hosts: a token does not encrypt HTTP traffic.
Model files are pinned by SHA-256 and loaded locally; remote model code and pickle are not executed. Model output is data, not an instruction to run a command, use a tool or change permissions.
## Code runner VM
Production runs the runner in a dedicated VM. Inside it, nsjail restricts programs through namespaces, seccomp, cgroup v2 and no network. The VM receives no database, mail, storage or identity secrets, shared directories or Docker socket. TLS and a token protect the API; network ACLs restrict access and guest-initiated connections.
`make -C deploy check-runner-vm` checks configuration without starting a VM. Live VM and isolation checks run separately as described in [DEPLOYMENT.md](DEPLOYMENT.md) and [TESTING.md](TESTING.md). They do not establish that the kernel, hypervisor or nsjail has no vulnerabilities. A privileged development container is not the production boundary; automatic token rotation and VM monitoring are not connected yet.