You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use a cryptographic random source for new document slugs #442
A new document's slug comes from Math.random(), which is not a cryptographic source. Its output can be predicted. The first signed-in focus or edit on an ownerless document claims ownership (CONTEXT.md §Document access, Open document). So someone who predicts a fresh slug can open it first and own another person's new document.
apps/webapp/src/proxy.ts:13 — the same expression for the new. host redirect.
apps/webapp/src/proxy.ts:36 also uses Math.random(), for log sampling only. Leave it.
Constraint
Root CLAUDE.md §Settled (Next product APIs) says "Do not edit src/proxy.ts". Changing line 13 needs maintainer approval. If refused, change sanitizeDocumentSlug.ts only and have proxy.ts import that helper in a later approved change.
Fix plan
In sanitizeDocumentSlug.ts, build the random slug from crypto.getRandomValues (available in the browser, in Bun and in the Next.js edge runtime). Keep the same alphabet (0-9a-z) and a length of at least 11 characters.
With approval, make proxy.ts:13 call the same helper instead of repeating the expression.
Acceptance criteria
No slug generator uses Math.random().
New slugs keep the current format, and /new and the new. host still open a fresh document.
Verify
grep -rn "Math.random" apps/webapp/src/utils/sanitizeDocumentSlug.ts apps/webapp/src/proxy.ts shows only the log-sampling line.
Open /new twice and check two different slugs of the expected length.
Activity
fix(webapp): harden chat avatars, pasted nodes and new slugs
docs(repo): record the 9 Oct security and email batch in the changelo…
HMarzban commentedon Oct 9, 2026
Fixed and live.
cda1150e4bbdaae66c(production run 37976785981, green).new.host inproxy.ts, use an 11-character slug fromcrypto.getRandomValues.