0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/plugins/discourse-subscriptions/assets
Alan Guo Xiang Tan 168dcc5bb8 SECURITY: Fixes for discourse-subscriptions [backport 2026.1]
Backport of #593 to release/2026.1.

This PR combines two security fixes for the discourse-subscriptions plugin.

## Commits

### 1. `1ca9255da2` — SECURITY: Fix unauthorized group access via subscription finalize

The `/s/finalize` endpoint accepted client-supplied `plan` and
`transaction` parameters that determined which group a user would be
added to after completing a Stripe payment. During the 3D Secure
authentication flow, an authenticated user could complete a cheap
subscription in `SubscribeController#create` but supply a premium plan
ID when calling `#finalize`, granting themselves access to a higher-tier
group they never paid for.

This commit fixes the vulnerability by linking the two endpoints
server-side using `server_session`. When `#create` produces a
transaction requiring 3D Secure authentication (`incomplete` or `open`
status), it stores the transaction ID and plan ID in the server session.
`#finalize` then reads exclusively from the session instead of accepting
client parameters, and clears the entry after successful finalization.

On the frontend, `Transaction.finalize()` no longer sends any
parameters to the server.

(from #434)

---

### 2. `bc79b23e34` — SECURITY: Use per-request Stripe API key instead of global state

Replace `set_api_key` (which mutated global `::Stripe.api_key`) with
`set_stripe_api_key` (which stores the key in an instance variable).
All Stripe API calls now receive `{ api_key: @stripe_api_key }` as
the per-request opts parameter, following the stripe gem's documented
per-request configuration pattern. This prevents API key leakage
across concurrent requests in multi-threaded environments.

(from #590)

---

**Security Advisory:** https://github.com/discourse/discourse/security/advisories/GHSA-f866-8fcp-fgvv

---

**Security Advisory:** https://github.com/discourse/discourse/security/advisories/GHSA-9vg5-mp49-xghh
2026-03-31 15:12:50 +01:00
..
javascripts/discourse SECURITY: Fixes for discourse-subscriptions [backport 2026.1] 2026-03-31 15:12:50 +01:00
stylesheets DEV: Apply latest stylelint autofixes (#36294) 2025-11-27 18:07:22 +01:00