Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Webhook.construct_event accepts signatures made with an empty endpoint secret

オープン 初心者向け
#1,936 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, security

調査の方向性

stripe.Webhook.construct_event エントリポイントから開始し、署名検証中に指定された secret がどのように使用されるかを追跡します。空の secret と空白文字だけの secret のカバレッジを追加し、それらの設定が署名計算前に拒否される場合に行われる処理を検討するとともに、有効な secret では引き続きイベントを検証できることを確認します。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
2.1k
フォーク
539
平均マージ
3日 5時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stripe/stripe-python のほかの issue

stripe/stripe-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。