Arbitrary Stripe priceId accepted at three checkout endpoints → Pro entitlement bypass
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- nextjs, typescript
調査の方向性
packages/utils/src/constants/plans.ts から始め、3つの checkout エントリーポイント、guest-checkout、subscribe、desktop root の各ルートを比較します。apps/web/app/api/v1/[...route]/route.ts にある既存のバリデーションを読み、userIsPro、isProSubscription、Stripe webhook の処理を追跡します。これらのパス全体で、許可されたプラン、上限付きの数量、ゲスト認証、権限チェックが一貫してカバーされれば作業は完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
priceId and quantity are taken directly from client-supplied JSON and passed into
stripe.checkout.sessions.create with no allowlist, at three separate endpoints, despite
STRIPE_PLAN_IDS (packages/utils/src/constants/plans.ts) existing for exactly this purpose:
apps/web/app/api/settings/billing/guest-checkout/route.ts:9,26no auth at all.apps/web/app/api/settings/billing/subscribe/route.ts:14,68authenticated, but no allowlist.apps/web/app/api/desktop/[...route]/root.ts:702-791(POST /api/desktop/subscribe, used by
desktop + mobile) authenticated viawithAuth, butpriceIdis only validated as
z.string(), no enum againstSTRIPE_PLAN_IDS.
For contrast, apps/web/app/api/v1/[...route]/route.ts:4402-4409 does this correctly: it
derives the price itself from STRIPE_PLAN_IDS[environment][payload.interval] and never
trusts a client-supplied price id.
Why this grants full Pro
Entitlement is checked by status, not by price:
userIsPro(packages/utils/src/lib/stripe/subscriptions.ts) only checks
stripeSubscriptionStatus/thirdPartyStripeSubscriptionId.isProSubscriptionis a deny-list it excludes only SSO and signed-BAA subscriptions.- In the Stripe webhook (
apps/web/app/api/webhooks/stripe/route.ts:110-124,601-610),
checkout.session.completedspecial-cases only SSO and signed-BAA subscriptions via
isSsoSubscription/isSignedBaaSubscription. Every other subscription i.e. any other live
recurring price on the account — falls into the generic path that sets
stripeSubscriptionStatus: subscription.statusandinviteQuotafrom the line-item quantity,
with no price check at all.
So completing checkout with any other live recurring price in Cap's Stripe account (a
retired/legacy tier, an internal test price, anything not SSO/BAA) grants full Pro status.
allow_promotion_codes: true widens this further, and on subscribe/route.ts and
guest-checkout/route.ts an unbounded quantity flows straight into users.inviteQuota.
Existing related work (none of it closes this)
- PR #2141 (open, "Checkout conversion...guest checkout lockdown") fixes only
guest-checkout/route.tsadds anallowedPriceIds()check againstSTRIPE_PLAN_IDSand
clamps quantity to 1-100.subscribe/route.tsand the desktop/subscribeendpoint are
untouched by that PR, andisProSubscriptionremains a deny-list. - PR #1929 (open) adds Vercel-Firewall rate limiting to
guest-checkoutonly doesn't prevent
a single request from buying Pro at an arbitrary price, and fails open on self-hosted deploys
without a configured Firewall rule. - No existing issue covers this.
Fix
- Allowlist
priceIdagainstSTRIPE_PLAN_IDS[env]at all three endpoints (not just
guest-checkout), mirroring the pattern already used inv1/route.ts. - Clamp
quantityatsubscribe/route.tsand the desktop endpoint the same way #2141 does
for guest-checkout. - Convert
isProSubscriptionfrom a deny-list to an allow-list (only prices in
STRIPE_PLAN_IDSgrant Pro), so entitlement isn't dependent on catching every non-Pro price
individually as it's created in Stripe. - Require auth on
guest-checkoutor otherwise bound its blast radius (currently zero auth).
Caveat
Actual historical exposure depends on which legacy/test prices are live (non-archived) in Cap's
Stripe account right now someone with Stripe dashboard access should check before sizing
impact. The code-level flaw is independent of that and reproducible today with any second live
recurring price.
- 主要言語
- Rust
- スター
- 22.5k
- フォーク
- 1.9k
- 平均マージ
- 6時間 33分
- マージ済み PR(30日)
- 77
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
CapSoftware/Cap のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
CapSoftware/Cap#2305 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
CapSoftware/Cap#1714 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
CapSoftware/Cap#2329 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
CapSoftware/Cap#2328 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
CapSoftware/Cap#2324 · コメント 1 件 ·
CapSoftware/Cap の issue をすべて見る
似ている issue
-
Browser (wasm) relay client cannot connect to relays whose URL has a trailing-dot FQDN hostname オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
n0-computer/iroh#4550 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
paritytech/zombienet-sdk#591 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
farion1231/cc-switch#7638 · コメント 1 件 ·
-
onnx-ir re-exports ModelProto and GraphProto but not NodeProto, AttributeProto and AttributeType オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100