Security findings register
Vulnerabilities and hardening items from the 2026-11-13 audit, with fixes, verification and remaining risk.
Audit date: 2026-11-13. Scope: API, sockets, console sign-in, attachments, scanner, webhooks, configuration, static sites, CI and deployment templates. Method: manual code review, targeted tests and dependency audits. This is not a penetration test. Earlier fixes are recorded in the 2026-11-12 review.
Severity reflects impact if exploited in the documented deployment. Status values match the implementation tracker.
SEC-01: Scanned attachments could be replaced before download
| Field | Value |
|---|---|
| Severity | High |
| Component | apps/api/src/modules/attachments/attachments.routes.ts, storage.ts |
| Root cause | The presigned PUT URL (valid 5 minutes) targeted the same object key that downloads used. After complete scanned and released the file, the uploader could PUT different bytes of the same size and type, and recipients downloaded unscanned content. |
| Fix | Uploads go to quarantine/<key>; completion scans those bytes and the server writes exactly the scanned buffer to <key>, then deletes the quarantine object (ADR 020). Retention deletes both keys; a lifecycle rule expires quarantine/ after a day. |
| Verification | New test re-uploading through the presigned URL after a clean scan cannot replace the file (apps/api/test/scanning.test.ts) fails on the old code and passes with the fix; attachment, scanning and review suites pass. |
| Remaining risk | Uploads in flight during the deploy must be retried. |
| External action | OpenTofu applies the lifecycle rules (infra/opentofu/platform/storage.tf). |
| Status | Completed (code); lifecycle rule Pending (external) |
SEC-02: Client IP could be spoofed through proxy headers
| Field | Value |
|---|---|
| Severity | Medium |
| Component | apps/api/src/lib/http.ts (console sign-in limits, LiveKit webhook limits, audit IPs) |
| Root cause | With TRUST_PROXY=true the API used the first present of CF-Connecting-IP, DO-Connecting-IP and the leftmost X-Forwarded-For entry. A client could send whichever header the ingress does not overwrite, a new value per request, to bypass per-IP sign-in limits and forge audit IPs. |
| Fix | Only the single header named by CLIENT_IP_HEADER (default do-connecting-ip) is read; for x-forwarded-for the last, proxy-appended entry is used. The App Platform template sets it explicitly. |
| Verification | apps/api/src/lib/http.test.ts: other headers are ignored, the last XFF entry is used, nothing is trusted without an ingress. |
| Remaining risk | The ingress must overwrite the configured header. The per-email limit (10/min) and the account lockout still apply. |
| External action | Confirm on staging that a client-supplied DO-Connecting-IP is replaced by App Platform; set CLIENT_IP_HEADER=cf-connecting-ip if Cloudflare proxies the API. |
| Status | Completed (code); ingress confirmation Pending |
SEC-03: Unbounded concurrent password hashing
| Field | Value |
|---|---|
| Severity | Medium |
| Component | packages/auth/src/password.ts |
| Root cause | Each scrypt derivation uses 128 MiB and a libuv worker thread. Sign-in attempts, including the unknown-account timing equalizer, ran in parallel without a cap, so a burst could exhaust memory or starve DNS/file I/O on the thread pool. |
| Fix | A FIFO concurrency limit of 2 derivations (256 MiB maximum). |
| Verification | concurrencyLimit unit test (peak 2, FIFO order); console-auth integration tests pass. |
| Remaining risk | Queued sign-ins slow down under a sustained flood; rate limits bound the queue. |
| Status | Completed |
SEC-04: API responses had no Content-Security-Policy
| Field | Value |
|---|---|
| Severity | Low |
| Component | apps/api/src/app.ts |
| Fix | secureHeaders now sends default-src 'none'; frame-ancestors 'none' on every response. |
| Verification | API test suite passes; JSON responses do not render. |
| Status | Completed |
SEC-05: Static sites lacked HSTS; docs lacked CSP
| Field | Value |
|---|---|
| Severity | Low |
| Component | apps/admin/public/_headers, apps/docs/public/_headers |
| Fix | HSTS (1 year, subdomains) on both; docs CSP with object-src 'none', frame-ancestors 'none', connect-src 'self'. The static export needs 'unsafe-inline' scripts. |
| Verification | Docs export served locally with the header: navigation and search work, no CSP violations. |
| Remaining risk | Console connect-src still allows any https: origin (SEC-11). |
| External action | Add the HSTS preload only after every subdomain serves HTTPS. |
| Status | Completed |
SEC-06: Scanner image was not built or scanned in CI
| Field | Value |
|---|---|
| Severity | Low |
| Component | .github/workflows/ci.yml |
| Fix | The image job is a matrix over api and scanner; both are built and Trivy-scanned (high/critical, fixable). |
| Verification | Workflow edited only; it has not run in hosted CI from this checkout. |
| Status | Partially Completed (needs a CI run) |
SEC-07: No statement or idle-transaction timeouts for the runtime role
| Field | Value |
|---|---|
| Severity | Low (availability) |
| Component | infra/opentofu/platform/files/database-grants.sql |
| Fix | ALTER ROLE lynkoria_app SET statement_timeout = '30s' and idle_in_transaction_session_timeout = '60s'. Role settings work through PgBouncer transaction pooling, where connection parameters would be rejected. |
| Verification | SQL reviewed; not applied to a managed database. |
| External action | Re-run the grants script on existing databases. |
| Status | Pending (external apply) |
SEC-08: Mutable ClamAV image tag
| Field | Value |
|---|---|
| Severity | Low (supply chain) |
| Component | infra/scanner/compose.yaml, infra/local/compose.yaml (clamav/clamav:1.4) |
| Fix | Not changed: the digest must be resolved and recorded by an operator. |
| External action | Pin clamav/clamav:1.4@sha256:… after reviewing the image. |
| Status | Pending |
SEC-09: Development-only esbuild advisory
| Field | Value |
|---|---|
| Severity | Informational |
| Component | drizzle-kit → @esbuild-kit/core-utils → esbuild@≤0.24.2 (GHSA-67mh-4wv8-2f99) |
| Assessment | The advisory concerns esbuild's development server; drizzle-kit generate only transpiles. Not in production dependencies. |
| Status | Completed: a pnpm override moves @esbuild-kit/core-utils to esbuild 0.25.12; pnpm audit reports no advisories |
SEC-10: Per-event socket revalidation cost
| Field | Value |
|---|---|
| Severity | Informational (performance) |
| Component | apps/api/src/sockets/setup.ts |
| Assessment | Every socket event re-reads the environment and suspension (two indexed lookups) so project disables take effect on the next event. Throttling would weaken that guarantee, so it was kept. Revisit with a cache invalidated by pub/sub when the API scales out. |
| Status | Not Applicable (deliberate) |
SEC-11: Console CSP allows any HTTPS connect target
| Field | Value |
|---|---|
| Severity | Low |
| Component | apps/admin/public/_headers |
| Assessment | connect-src 'self' https: exists because VITE_API_ORIGIN is chosen at build time. |
| External action | Replace https: with the deployed API origin in the Pages project's _headers. |
| Status | Pending |
Previously accepted risks (unchanged)
These are product or infrastructure decisions, tracked in blockers: self-hosted LiveKit cannot revoke an unexpired 5-minute token; one API instance by default (cross-instance fan-out and revocation now work, ADR 021); presence is tenant-wide; service keys are environment-wide trusted credentials; Fidescript media isolation needs a separate stack.