Skip to content

Search/CSRF token uses Math.random() instead of a CSPRNG #2181

Description

@felladrin

Surfaced by a role-based review; verified against current code (docs/security.md already flags the weakness).

Problem: server/searchToken.ts:26 generates the token with Math.random().toString(36).substring(2) — a non-cryptographic PRNG yielding ~11 low-entropy chars. This token is the CSRF/auth gate for the SearXNG proxy and /inference.

Fix: Use crypto.randomBytes(32).toString("hex") (or crypto.randomUUID()) — a drop-in change.

Files: server/searchToken.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions