Harden data access, document uploads, and secret handling
From the PR description
Summary
This PR implements a focused security hardening pass across the backend, frontend, migrations, and dependency locks.
What changed
- Locks Supabase app data tables behind backend service-role APIs and adds a cleanup migration for invalid tabular cells.
- Replaces direct frontend
user_profilesaccess with safe backend profile APIs. - Encrypts user LLM API keys at rest and only returns
has_*_api_keybooleans to the browser. - Requires dedicated
DOWNLOAD_SIGNING_SECRETandUSER_API_KEYS_ENCRYPTION_KEYsecrets. - Validates uploaded PDF/DOC/DOCX bytes and DOCX structure before storage/conversion.
- Tightens tabular-review document authorization, project-review access, direct-share edit behavior, and chat project scoping.
- Removes sensitive raw LLM/document logging and unused frontend server-secret utilities.
- Updates vulnerable frontend/backend dependencies and adds targeted backend security tests.
Validation
backend:npm testpassed, 9 tests.backend:npm run buildpassed.frontend:npm run buildpassed with placeholder public env values.backend+frontend:npm audit --jsonreports 0 vulnerabilities.- Local smoke test:
- Backend
/healthreturned 200. - Protected backend routes returned 401 without auth.
- Browser smoke verified
/loginand/signuprender, protected routes redirect to/login, and no Next error overlays or material console errors appeared.
- Backend
Notes
Authenticated Supabase/R2 flows were not smoke-tested locally because this workspace only has example env files, not real local secrets.
Our analysis
Security hardening pass across backend, frontend, and migrations — read the full analysis →
Think the analysis missed something the PR description covers?
Capture this PR into my fork
Download a Markdown prompt that tells Claude how to port every
commit in this PR into your working tree. Run it via
claude -p < capture-pull-42.md from
inside the repo you want the changes in.