Skip to content

Full code-review remediation: security (P0–P1), maintainability (P2), quality systems (P3) - #13

Merged
myself-aas merged 1 commit into
mainfrom
arena/01a0544f-catalystlab
Sep 2, 2026
Merged

Full code-review remediation: security (P0–P1), maintainability (P2), quality systems (P3)#13
myself-aas merged 1 commit into
mainfrom
arena/01a0544f-catalystlab

Conversation

@arena-ai-coding-agent

Copy link
Copy Markdown

Summary

Implements the complete remediation roadmap from the full-codebase technical audit (review artifacts in CODE_REVIEW.md). All 5 Criticals, 12 Majors, and the P3 quality-system items are closed, plus the pre-review design-system fixes and the Unsplash→Pexels codemod with its hardened, tested scripts/replace_images.py.

Phase 0 — Stop the bleeding

  • C3: GitHub webhook HMAC verified with crypto.timingSafeEqual over the raw body; unknown repoIds rejected (no auto-provisioning); demo secret moved to env.
  • C2: client-supplied plan/superadmin headers no longer trusted; cat_live_ API keys validated against a constant-time env allowlist.
  • C1: /api/payments/verify fails closed (503); both payment webhooks verify HMAC signatures.
  • C4: /api/state/sync* return 401 without a verified token supplying ownerId.
  • C5: SSRF guard pins DNS in the request agent (anti-rebinding), fails closed, rejectUnauthorized: true.

Phase 1 — Structural hardening

  • C2 (full): firebase-admin ID-token verification middleware (src/lib/serverAuth.ts); tiers derived server-side from verified identity + Firestore entitlements only.
  • CSP: inline-script hashing drops 'unsafe-inline' in production; 'unsafe-eval' removed; frame-ancestors allowlisted.
  • Per-route body limits (256 KB default, 2 MB state-sync only) + zod schemas for telemetry/engine/state payloads; JSON-LD < escaping.
  • React error boundaries (root + route variants) with recovery UI.

Phase 2 — Maintainability

  • : 2,958-line server.ts monolith decomposed into server/app.ts + 11 server/routes/* + server/core/* modules.
  • : dependency cleanup — duplicate animation libs, dead editor stack, orphaned components removed.
  • : strict: true compiles with 0 tsc errors.

Phase 3 — Quality systems

  • : structured logging — server pino (request IDs, credential-header redaction, stdSerializers) + client src/lib/logger.ts facade batching redacted/deduped errors to a validated, rate-limited /api/client-logs sink; 43 files off raw console.*.
  • : server-route test suite covering all five Critical flows; v8 coverage gate on server/** (72% lines, 94% functions). Found and fixed a live webhookSecret leak in the GitHub repos list/connect responses.
  • : real README, docs/ARCHITECTURE.md, docs/ENGINES.md (incl. the python-engines/ decision record and Firebase-public-config note).
  • : bundle-budget ratchet (npm run check:bundle) + Lighthouse CI config.

Verification

  • tsc --noEmit (strict): 0 errors · ESLint: 0 warnings · vitest: 168/168 · vite build: ~12s · bundle budgets: all ✓
  • Live boot smoke: 18-endpoint matrix green (webhooks 401/404/200, payments 503, state-sync 401, spoofed superadmin → visitor, JSON 404s, x-request-id issuance, no secret echo).

Notes

  • ⚠️ One follow-up commit is pending push: .github/workflows/ci.yml (CI gate with the hard tsc typecheck + bundle-budget step) and .github/workflows/lighthouse.yml — the GitHub App token needs the workflows permission to push workflow files. The commit is authored and ready; it will land on this branch and update this PR automatically once the connection is re-granted.
  • api/* serverless twins remain dormant (Express server is canonical) per the M4 decision.
  • Follow-up candidates tracked in CODE_REVIEW.md: noUncheckedIndexedAccess ramp, initial-chunk splitting (entry ~1 MB), hashed persisted API keys.

… maintainability, quality systems)

Implements the complete remediation roadmap from the technical audit in
CODE_REVIEW.md (all 5 Criticals, 12 Majors, P3 quality systems), plus the
pre-review design-system fixes and the Unsplash->Pexels codemod.

Phase 0 — Stop the bleeding:
- C3: GitHub webhook HMAC (timing-safe, raw body); unknown repoIds rejected
- C2: client identity headers untrusted; constant-time cat_live_ API-key allowlist
- C1: /api/payments/verify fails closed; payment webhooks HMAC-verified
- C4: /api/state/sync* 401 without a verified token
- C5: SSRF DNS pinning (anti-rebinding), fail-closed, TLS verification on

Phase 1 — Structural hardening:
- firebase-admin ID-token verification; tiers server-derived only
- CSP: production drops 'unsafe-inline' (inline-script hashing), no 'unsafe-eval'
- per-route body limits + zod validation (telemetry/engines/state)
- root + route error boundaries; JSON-LD escaping

Phase 2 — Maintainability:
- server.ts (2,958 lines) decomposed into server/app.ts + routes/* + core/*
- dependency cleanup (dup animation libs, dead editor stack, orphans)
- strict: true with 0 tsc errors

Phase 3 — Quality systems:
- pino structured logging + request IDs + redaction (server); client
  logger facade -> validated /api/client-logs sink; 43 files off console.*
- server-route suite: 168 tests total incl. all Critical flows;
  coverage gate server/** >=70% lines (72.06%), 94% functions;
  fixed webhookSecret leak found by the suite (toPublicRepo redaction)
- README + docs/ARCHITECTURE.md + docs/ENGINES.md (python-engines
  decision record; Firebase web config public-by-design note)
- bundle-budget ratchet (check:bundle) + Lighthouse config

NOTE: .github/workflows/* (CI gate with hard tsc typecheck + Lighthouse
job) are authored locally and will follow in an immediate follow-up
commit — the GitHub App token requires the 'workflows' permission to
push workflow files.

Verification: tsc strict 0 | eslint 0 warnings | vitest 168/168 |
build ~12s | bundle budgets green | 18-endpoint live smoke green.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
catalystlab Ready Ready Preview Sep 2, 2026 2:48pm UTC

@myself-aas
myself-aas merged commit 51ac455 into main Sep 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant