harden the reference backend: write bounds + CORS

The @pcbjam/backend-example server had a 1 GiB body limit, no per-owner/per-lib
quotas, bound to 0.0.0.0, and reflected any origin with credentials when
CORS_ORIGIN is *. Bound the write surface (5 MiB body cap, per-owner lib and
per-lib item quotas), bind 127.0.0.1 by default (opt in via HOST), and force
credentials off for a wildcard CORS origin. Refactor main() into an exported
buildApp() and add web/backend/test/security.test.ts (inject-based).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Istvan Matejcsok 2026-07-16 12:46:17 +02:00
commit 21e6f4c2d5
6 changed files with 192 additions and 25 deletions

3
web/pnpm-lock.yaml generated
View file

@ -39,6 +39,9 @@ importers:
typescript:
specifier: ^5.7.3
version: 5.9.3
vitest:
specifier: ^3.2.6
version: 3.2.6(@types/node@22.19.19)(jiti@1.21.7)(tsx@4.22.4)
pcbjam-shared:
dependencies: