Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Webhook.construct_event accepts signatures made with an empty endpoint secret

Aperta Adatta ai principianti
#1,936 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api, security

Direzione di ricerca

Inizia dal punto di ingresso stripe.Webhook.construct_event e traccia come viene utilizzato il secret fornito durante la verifica della firma. Aggiungi la copertura per i secret vuoti e composti solo da spazi bianchi, e considera il lavoro eseguito quando tali configurazioni vengono rifiutate prima del calcolo della firma, mentre i secret validi continuano a verificare gli eventi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: stripe-python 15.2.0

If the webhook endpoint secret is unset (e.g. STRIPE_WEBHOOK_SECRET missing, read with an empty-string default), passing "" as the secret makes stripe.Webhook.construct_event verify an HMAC keyed with the empty string. Anyone can then forge checkout.session.completed and similar events and they pass verification.

Reproduction

import hashlib, hmac, json, time, stripe

payload = json.dumps({"id": "evt_x", "object": "event", "type": "checkout.session.completed",
                      "data": {"object": {"metadata": {"tenant_id": "t"}}}})
ts = int(time.time())
sig = hmac.new(b"", f"{ts}.{payload}".encode(), hashlib.sha256).hexdigest()
event = stripe.Webhook.construct_event(payload, f"t={ts},v1={sig}", "")
print(event["type"])  # checkout.session.completed — accepted

Expected: an empty (or whitespace-only) secret is a configuration error, not a key. Suggest raising ValueError (or SignatureVerificationError) when secret is empty, before computing any signature.

Why it matters: a deployment that simply forgot to set the secret silently accepts forged events instead of rejecting them — e.g. activating or cancelling subscriptions. We found this in a security review and now refuse with 503 when the secret is unset, but the library failing closed would protect everyone who hasn't.

Lingua principale
Python
Stelle
2.1k
Fork
540
Merge medio
2g 18h
PR unite (30g)
27

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stripe/stripe-python

Tutte le issue di stripe/stripe-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.