fix(security): include webhook endpoint secrets in encryption key rotation

Abierto
#764 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
77/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
next.js, typescript

Línea de trabajo

Start with src/lib/crypto/rotation.ts and its tests; trace how the existing sealed tables are read, re-encrypted, and counted, then inspect webhookEndpointSecretAad in src/lib/data/webhook-endpoints.ts. Add coverage for rotating an endpoint secret and delivering with only the new key, and update the Key rotation section of docs/operations/deploy.md to list every sealed table. Done means the rotation counts and re-encrypts endpoint secrets and the documented table list is complete.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area: security bug impact: medium priority: P2 size: S

Context

Found by the Fable pre-production review on 2026-12-02 (main at cedc1914; every line reference below re-checked on main at cde5aa3b). Source: security and privacy readiness report, new issue 4.

npm run keys:rotate re-encrypts only two tables: sealedTables covers connection_credentials and notification_destination_secrets (src/lib/crypto/rotation.ts:43-111). Per-connection webhook endpoint secrets are sealed with the same key (sealSecret, src/lib/data/webhook-endpoints.ts:107-109) and are not rotated. An unreadable secret logs webhook_endpoint.secret_unreadable and returns null (webhook-endpoints.ts:209-212), which the webhook route answers with 404 (src/lib/webhooks/receive.ts:163-167). The procedure removes the old key once the script reports nothing remaining (docs/operations/deploy.md:294-300).

Impact: after a rotation and removal of the old key, every Polar, Resend, and GitLab per-connection delivery gets 404 and the script output shows nothing wrong; the timeline silently stops receiving those events until each connection's webhook is set up again. After a rotation prompted by a compromise, those secrets stay sealed under the compromised key.

Plan

  1. Add webhook_endpoints to sealedTables, with the same read, re-encrypt, and count steps as the other two, using its associated data (webhookEndpointSecretAad).
  2. Count it in "remaining", so the script never reports done while an endpoint secret is under an old key.
  3. List every sealed table in deploy.md "Key rotation".

Acceptance criteria

  • npm run keys:rotate re-encrypts webhook_endpoints secrets and counts them in "remaining".
  • A test rotates an endpoint secret, removes the old key, and verifies a delivery under the new key only.
  • deploy.md "Key rotation" lists every sealed table.
  • Playwright e2e: none needed, no screen changes.

Files and areas

src/lib/crypto/rotation.ts, its tests, docs/operations/deploy.md (Key rotation).

Non-goals: rotating other secrets, the incident runbook (separate issue).

Verification

npm run typecheck, npm run lint, npx vitest run src/lib/crypto src/lib/data.


Branch: <issue-number>-rotate-webhook-secrets

Model: anthropic/claude-opus-5-5 | Reasoning effort: unknown

Lenguaje dominante
TypeScript
Estrellas
13
Forks
2
Merge medio
5 h 20 min
PR fusionados (30 d)
287

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de eddiejaoude/StackDash

Todos los issues de eddiejaoude/StackDash

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.