Stripe webhook accepts events when no webhook secret is configured

Abierto Apto para principiantes
#6,404 1 comentario 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
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
django, python

Línea de trabajo

Lee contentcuration/contentcuration/settings.py y la vista stripe_webhook en contentcuration/contentcuration/views/subscription.py. Añade cobertura para un secreto configurado vacío y un evento firmado correctamente cuando hay un secreto establecido; confirma que las solicitudes con el secreto vacío devuelven 4xx sin cambiar los datos de la suscripción, mientras que los eventos firmados válidos siguen funcionando. Registra un error cuando falta el secreto y asegúrate de que la aplicación pueda iniciarse sin variables de Stripe.

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

Descripción

DEV: backend good first issue help wanted

🙂 Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:

  • Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
  • Confirm that you’ve read the guidelines in your comment.

Overview

STRIPE_WEBHOOK_SECRET defaults to an empty string when its environment variable is unset, and stripe_webhook then verifies events against that empty key. On a deployment without the variable, anyone can send a webhook signed with the empty key and change a user's subscription storage.

Complexity: Low
Target branch: hotfixes

Context
  • settings.py reads STRIPE_LIVE_WEBHOOK_SECRET or STRIPE_TEST_WEBHOOK_SECRET with a default of "".
  • stripe_webhook passes that value to stripe.Webhook.construct_event unchecked.
  • Reproduced under the test settings: a customer.subscription.updated event signed with an empty secret was accepted and set the user's subscription_disk_space.
The Change
  • stripe_webhook should reject every event when the webhook secret is empty, and log an error saying the secret isn't configured.
  • Studio should still start without the Stripe variables, so development and test environments keep working.
Acceptance Criteria
General
  • With an empty webhook secret, every webhook request returns 4xx and changes no subscription.
  • With a webhook secret set, correctly signed events are handled as before.
Testing
  • Tests cover an event signed with an empty secret while none is configured, and a correctly signed event while one is.

AI usage

I chose which audit findings belong in #6398 and set the access pattern. Claude Code found and reproduced this gap and drafted this issue.

Lenguaje dominante
Python
Estrellas
212
Forks
321
Merge medio
1 d 7 h
PR fusionados (30 d)
14

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 learningequality/studio

Todos los issues de learningequality/studio

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.