Stripe webhook accepts events when no webhook secret is configured

Offen Anfängerfreundlich
#6,404 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
django, python

Rechercherichtung

Lies contentcuration/contentcuration/settings.py und den View stripe_webhook in contentcuration/contentcuration/views/subscription.py. Ergänze Tests für ein leeres konfiguriertes Secret und ein korrekt signiertes Event, wenn ein Secret gesetzt ist; bestätige, dass Anfragen mit leerem Secret 4xx zurückgeben, ohne Abonnementdaten zu ändern, während gültige signierte Events weiterhin funktionieren. Protokolliere einen Fehler, wenn das Secret fehlt, und stelle sicher, dass die App ohne Stripe-Variablen starten kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
212
Forks
321
Ø Merge
1 T. 7 Std.
Gemergte PRs (30 T.)
14

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus learningequality/studio

Alle Issues in learningequality/studio

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.