Skip to content

Reject Stripe webhooks when no webhook secret is configured - #6427

Open
adibmbrk wants to merge 1 commit into
learningequality:hotfixesfrom
adibmbrk:fix-stripe-webhook-empty-secret
Open

adibmbrk wants to merge 1 commit into
learningequality:hotfixesfrom
adibmbrk:fix-stripe-webhook-empty-secret

Conversation

@adibmbrk

@adibmbrk adibmbrk commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

stripe_webhook verified events against STRIPE_WEBHOOK_SECRET even when it was empty, so anyone could send an event signed with an empty key and change a user's subscription storage.

The view now logs an error and returns 400 for every request while the secret is unset. The check sits at the top of the view, before signature verification. settings.py is unchanged, so Studio still starts without the Stripe variables and development and test environments keep working.

References

Fixes #6404

Reviewer guidance

Added StripeWebhookSignatureTest, which signs payloads with real HMAC rather than mocking construct_event:

  • empty secret, none configured: 400, error logged, subscription unchanged
  • secret configured, correctly signed: handled as before
  • secret configured, signed with the wrong (empty) secret: 400

To verify: pytest contentcuration/contentcuration/tests/views/test_subscription.py (all 21 pass). With the view change reverted, the empty-secret test fails.

AI usage

I used Claude Code to implement the change and write the tests, following the acceptance criteria in #6404. I reviewed the diff, kept the change to a single guard in the view, and confirmed the new empty-secret test fails without the fix and that the whole test file and pre-commit pass.

@adibmbrk
adibmbrk requested review from a team and leq-bot November 17, 2026 15:57
@learning-equality-bot

Copy link
Copy Markdown
Contributor

👋 Hi @adibmbrk, thanks for contributing!

For the review process to begin, please verify that the following is satisfied:

  • Contribution is aligned with our contributing guidelines

  • Pull request description has correctly filled AI usage section & follows our AI guidance:

    AI guidance

    State explicitly whether you didn't use or used AI & how.

    If you used it, ensure that the PR is aligned with Using AI as well as our DEEP framework. DEEP asks you:

    • Disclose — Be open about when you've used AI for support.
    • Engage critically — Question what is generated. Review code for correctness and unnecessary complexity.
    • Edit — Review and refine AI output. Remove unnecessary code and verify it still works after your edits.
    • Process sharing — Explain how you used the AI so others can learn.

    Examples of good disclosures:

    "I used Claude Code to implement the component, prompting it to follow the pattern in ComponentX. I reviewed the generated code, removed unnecessary error handling, and verified the tests pass."

    "I brainstormed the approach with Gemini, then had it write failing tests for the feature. After reviewing the tests, I used Claude Code to generate the implementation. I refactored the output to reduce verbosity and ran the full test suite."

📢✨ Before we assign a reviewer:

  • @rtibblesbot will pre-review this pull request. Its comments are generated by an LLM, and should be evaluated accordingly.
  • We'll also invite community pre-review. See the community review guidance for both authors and reviewers.

Also check that issue requirements are satisfied & you ran pre-commit locally.

Pull requests that don't follow the guidelines will be closed.

Reviewer assignment can take up to 2 weeks.

📎 We couldn't find an issue linked to this pull request. Please edit the description and link one under References, for example Fixes #123 or Closes #123. A plain #123 mention doesn't link the PR to the issue.

@rtibbles
rtibbles requested a review from rtibblesbot November 18, 2026 17:16
@learning-equality-bot

Copy link
Copy Markdown
Contributor

📢✨ Before we assign a reviewer, we'll turn on @rtibblesbot to pre-review. Its comments are generated by an LLM, and should be evaluated accordingly.

rtibblesbot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Waiting for changes

Outcome: skipped — rebased to c43c06d, no content changes

Last updated: 2026-11-25 09:38 UTC

@rtibbles rtibbles linked an issue Nov 18, 2026 that may be closed by this pull request
3 tasks

@rtibblesbot rtibblesbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #6427: two CI failures block merge, and neither comes from the code. The fix is correct. It meets the #6404 acceptance criteria.

  • blocking: Linting failed because pre-commit could not build typed-ast for black on Python 3.14. #6446 fixed that on hotfixes. Pre-commit passes locally on both files. Rebase onto hotfixes.
  • blocking: Check template ran against an earlier body. The current body has every section it reported missing. Re-run the check.
  • praise: see inline.

Next step: Needs a full code review by a human engineer.

  • The author is outside the team: confirm this should be built at all.

Written by rtibblesbot, an LLM-based coding agent.

Signed-off-by: adibmbrk <adibmbrk@gmail.com>
@adibmbrk
adibmbrk force-pushed the fix-stripe-webhook-empty-secret branch from abed64a to c43c06d Compare November 24, 2026 08:02
@adibmbrk
adibmbrk requested a review from rtibblesbot November 24, 2026 08:18
@learning-equality-bot

Copy link
Copy Markdown
Contributor

📢✨ Before we assign a reviewer, we'll turn on @rtibblesbot to pre-review. Its comments are generated by an LLM, and should be evaluated accordingly.

@rtibblesbot rtibblesbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch was rebased since my last review; HEAD is now c43c06d, with no content changes.


Written by rtibblesbot, an LLM-based coding agent.

@adibmbrk
adibmbrk requested a review from rtibblesbot November 25, 2026 07:20
@learning-equality-bot

Copy link
Copy Markdown
Contributor

📢✨ Before we assign a reviewer, we'll turn on @rtibblesbot to pre-review. Its comments are generated by an LLM, and should be evaluated accordingly.

@rtibblesbot rtibblesbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch was rebased since my last review; HEAD is now c43c06d, with no content changes.


Written by rtibblesbot, an LLM-based coding agent.

@adibmbrk

Copy link
Copy Markdown
Contributor Author

Hi @AlexVelezLl @rtibbles, I have addressed all the bot comments, can you PTAL and let me know if any further changes are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stripe webhook accepts events when no webhook secret is configured

2 participants