Stripe webhook accepts events when no webhook secret is configured

未关闭 适合新手
#6,404 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
django, python

调研方向

阅读 contentcuration/contentcuration/settings.py 以及 contentcuration/contentcuration/views/subscription.py 中的 stripe_webhook 视图。为配置的 secret 为空,以及设置了 secret 时事件签名正确这两种情况添加测试;确认空 secret 请求返回 4xx,且不会更改订阅数据,同时有效的签名事件仍能正常工作。缺少 secret 时记录错误,并确保没有 Stripe 变量时应用仍能启动。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
212
派生
321
平均合并
1 天 7 小时
30 天内合并 PR
14

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

learningequality/studio 的其他 Issue

查看 learningequality/studio 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。