Address High/Medium findings from the web app security assessment
CI / build (push) Has been cancelled

Fixes the two High-severity findings from Isaac Hague's 19/08/2026 review
(F-01, F-02) plus F-03 through F-09:

- F-01: content writes are now sanitised server-side (sanitize-html) as the
  real security boundary — the browser-side sanitiser is UX, not enforcement,
  and a direct API write bypassed it entirely. Also closes the javascript:
  href gap in sanitiseInline().
- F-02: refusing the factory admin password no longer depends on NODE_ENV;
  it's the unconditional default now, with an explicit ALLOW_DEV_PASSWORD=1
  opt-in for local dev.
- F-03: adds CSP (report-only — the legacy inline onclick="" handlers would
  break under enforcement) and HSTS, in both server/index.mjs and vercel.json.
- F-04/F-05: rate-limits /api/leads and rotates leads.jsonl past 5MB; CSV
  export neutralises leading =+-@ so exports can't carry live formulas.
- F-06: sessions drop from 12h to 4h and are tied to a per-boot random epoch,
  so a restart now actually revokes outstanding tokens.
- F-07/F-08/F-09: generic messages on 5xx, fixed-length password comparison
  (no more length disclosure via the short-circuit), periodic throttle-map
  cleanup.

F-10 (dependency advisories): applied the two non-breaking patches (nanoid,
postcss); the vite/react-router-dom major bumps are left for a separate pass,
per the report's own recommendation. F-11 (PDF Content-Disposition) and a
CAPTCHA/honeypot on the enquiry form are deliberately left open — both are
product/UX calls, not pure security fixes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 18:08:24 +05:00
co-authored by Claude Sonnet 5
parent 5570eb0a9d
commit 28d0addfc0
8 changed files with 366 additions and 60 deletions
+7 -4
View File
@@ -13,15 +13,18 @@ ADMIN_PASSWORD='…' npm start # serves dist/ + the API on port 8787
| Variable | Default | Purpose |
| --- | --- | --- |
| `ADMIN_PASSWORD` | `blackdice` | Password for `/admin`. **Set this** — the server logs a warning while it is unset. |
| `ADMIN_SECRET` | derived from the password | Signs session tokens. Set it to invalidate all sessions independently of the password. |
| `ADMIN_PASSWORD` | — | Password for `/admin`. **Required** — the server refuses to start without it (or with the factory password `blackdice`). |
| `ALLOW_DEV_PASSWORD` | unset | Local development only: accept the factory password `blackdice` instead of requiring `ADMIN_PASSWORD`. Never set in a real deployment. |
| `ADMIN_SECRET` | derived from the password | Signs session tokens. Set it to invalidate all sessions independently of the password (a server restart also invalidates every session, regardless of this setting). |
| `PORT` | `8787` | Listen port. |
| `CONTENT_DIR` | `./content` | Published content, uploads, snapshots, enquiries. Put this on persistent storage. |
| `DIST_DIR` | `./dist` | The built site. |
| `SITE_URL` | `https://www.blackdice.ai` | Canonical origin used in `sitemap.xml`. |
Sessions last 12 hours. Failed logins are throttled at 10 per IP per 15 minutes.
Uploads are capped at 32MB and limited to images, MP4/WebM and PDF.
Sessions last 4 hours. Failed logins are throttled at 10 per IP per 15 minutes;
enquiry submissions at 8 per IP per 10 minutes. Uploads are capped at 32MB and
limited to images, MP4/WebM and PDF. `leads.jsonl` rolls over to a `.bak` file
once it passes 5MB rather than growing without bound.
## What lives where