zod probed Function("") on its first object schema, which the production CSP
(no unsafe-eval) reported on every boot. Schema code now imports z from
src/contracts/zod.ts, enforced by a dependency-cruiser rule, and the CSP smoke
drops its init-script workaround.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.7 KiB
Browser security boundary
The browser bundle is public. Secrets, token lifecycle, raw HTML injection, dynamic code execution, untrusted script URLs, and public production source maps are prohibited defaults.
config/hosting/security-headers.json is the declared header set. Hosting
verification compares that declaration with live responses. CSP deliberately
omits unsafe-inline and unsafe-eval; production code and built assets must
remain compatible with that baseline. tests/e2e/production-csp.spec.ts (part of
test:e2e, FE-GATE-008) serves the build with these headers and fails on a
securitypolicyviolation event or console error (review 13-08). zod probes
Function("") on its first object schema, which the policy would report on
every boot. src/contracts/zod.ts sets jitless to skip that probe, and every
module that builds a schema imports z from there, so the setting is applied
before the first schema whatever order the bundler evaluates chunks in.
z.config in the entry module would be too late. Import z from
src/contracts/zod.ts, not from zod, in new schema code. Features that are off by
default need CSP additions when a project selects them; see step 9 in
optional adapter recipes.
connect-src 'self' https: lets script reach any HTTPS origin. Narrowing it to
the runtime config's API_BASE_URL and TELEMETRY_ENDPOINT origins needs a
header generated per environment at deploy time, because those values are set
per deployment (scripts/generate-runtime-config.ts). That generator does not
exist yet; a project that deploys should add it with its provider adapter.
Route guards are UX hints and client validation does not replace backend authorization or validation.