gristlabs_grist-core/app/server
Leslie H 24ce54b586
Improve session ID security (#1059)
Follow-up of #994. This PR revises the session ID generation logic to improve security in the absence of a secure session secret. It also adds a section in the admin panel "security" section to nag system admins when GRIST_SESSION_SECRET is not set.

Following is an excerpt from internal conversation.

TL;DR: Grist's current implementation generates semi-secure session IDs and uses a publicly known default signing key to sign them when the environment variable GRIST_SESSION_SECRET is not set. This PR generates cryptographically secure session IDs to dismiss security concerns around an insecure signing key, and encourages system admins to configure their own signing key anyway.

> The session secret is required by expressjs/session to sign its session IDs. It's designed as an extra protection against session hijacking by randomly guessing session IDs and hitting a valid one. While it is easy to encourage users to set a distinct session secret, this is unnecessary if session IDs are generated in a cryptographically secure way. As of now Grist uses version 4 UUIDs as session IDs (see app/server/lib/gristSessions.ts - it uses shortUUID.generate which invokes uuid.v4 under the hood). These contain 122 bits of entropy, technically insufficient to be considered cryptographically secure. In practice, this is never considered a real vulnerability. To compare, RSA2048 is still very commonly used in web servers, yet it only has 112 bits of security (>=128 bits = "secure", rule of thumb in cryptography). But for peace of mind I propose using crypto.getRandomValues to generate real 128-bit random values. This should render session ID signing unnecessary and hence dismiss security concerns around an insecure signing key.
2024-06-25 15:43:25 -04:00
..
declarations (core) disentangle some server tests, release to core, add GRIST_PROXY_AUTH_HEADER test 2022-03-24 15:11:32 -04:00
lib Improve session ID security (#1059) 2024-06-25 15:43:25 -04:00
utils (core) sanitizing redis errors 2023-06-06 10:51:17 +02:00
companion.ts (core) Customizable stripe plans. 2024-05-19 09:09:19 +02:00
declarations.d.ts (core) Faster builds all around. 2022-07-04 10:42:40 -04:00
devServerMain.ts (core) support for bundling custom widgets with the Grist app 2023-10-27 17:00:10 -04:00
generateCheckpoint.ts (core) get all tests working under python3/gvisor 2021-10-18 17:44:15 -04:00
generateInitialDocSql.ts (core) Add optional telemetry to grist-core 2023-06-07 12:00:51 -04:00
localization.ts only offer languages that have been marked as substantially complete (#466) 2023-03-28 10:59:17 -04:00
mergedServerMain.ts (core) add a sandbox check to admin panel, and start reconciling boot and admin pages 2024-04-29 20:52:39 -04:00
tsconfig.json (core) Simple localization support and currency selector. 2021-08-26 13:36:49 -07:00