Skip to content

Phase 2: Security Baseline + Dockerfile (Week 2) #36

Description

@Number531

Overview

Two parallel workstreams: Security hardening (helmet, CORS, env validation, 529 retry, credential rotation) and container setup (Dockerfile, .dockerignore, DB pool config).

Execution Plan: docs/pending-updates/deploy-week-2.md
Reference: docs/pending-updates/deployment-guide.md — Sections 2.8-2.9, 4.1-4.6, 7.1-7.2

Stream A: Security Hardening

  • A1 Add helmet security headers (CSP, HSTS, X-Frame-Options) — DEFERRED (CSP complexity, 50+ inline styles need browser validation)
  • A2 CORS lockdown — DEFERRED (SSE writeHead conflict at line 936, needs atomic commit with frontend)
  • A3 Environment validation on startup — fail fast if ANTHROPIC_API_KEY missing ✅ d790714
  • A4 Anthropic 529 retry with exponential backoff — DEFERRED (async iterator complexity, duplicate tool execution risk)
  • A5 🔴 Credential rotation — ALL keys in committed .env must be rotated immediately
  • A6 Migrate API keys out of query strings — DESCOPED (upstream APIs don't support header auth)
  • A7 Request size limits — DEFERRED (current 50MB works; reducing is behavioral change)

Stream B: Container Setup

  • B1 Dockerfile with node:22-slim, pandoc, typst, non-root user + package.json engines >=22.0.0d790714
  • B2 .dockerignore — exclude tests, docs, .env, coverage ✅ d790714
  • B3 .nvmrc (value: 22) ✅ d790714
  • B4 Configurable DB pool: max: 5Number(process.env.PG_POOL_MAX || 10)d790714
  • B5 Update .env.example with ALLOWED_ORIGINS, PG_POOL_MAXd790714

Progress

  • Implemented (6/12): A3, B1, B2, B3, B4, B5 — merged to main via deploy-week-2 branch (2026-03-11)
  • Deferred (4/12): A1, A2, A4, A7 — documented in CHANGELOG, not required for deployment
  • Descoped (1/12): A6 — upstream APIs don't support header auth
  • Remaining (1/12): A5 credential rotation — operational task, not code change
  • Test baseline: 37 suites / 1160 tests passing (zero regressions)
  • Version: v4.5.0

Effort

~2 days (2 developers, 1 per stream)

Depends On

Blocks

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical priority — must fix before launchdeploymentProduction deployment readinessroadmapPlanned feature on the project roadmapsecuritySecurity-related changes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions