fix(console): verify payment ownership before generating receipt URL#28396
Open
PanAchy wants to merge 5 commits into
Open
fix(console): verify payment ownership before generating receipt URL#28396PanAchy wants to merge 5 commits into
PanAchy wants to merge 5 commits into
Conversation
Billing.generateReceiptUrl was calling Stripe with a caller-supplied paymentID without checking that the payment belongs to the caller's workspace. Any authenticated user who knew a payment intent ID from another workspace could retrieve that workspace's Stripe receipt URL (billing email, card last-4, amount, date) — a classic IDOR. Fix: look up the payment in PaymentTable scoped to Actor.workspace() before calling Stripe. Throw if not found.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #28395
Type of change
What does this PR do?
Billing.generateReceiptUrlwas passing the caller-suppliedpaymentIDdirectly to Stripe without first checking that the payment belongs to the caller's workspace. This is an IDOR (Insecure Direct Object Reference): any authenticated OpenCode user who knows a Stripe payment intent ID from another workspace could retrieve that workspace's Stripe receipt URL, which contains their billing email, card last-4, amount, and transaction date.The fix adds an ownership check before calling Stripe. The function now looks up the payment in
PaymentTablefiltered by bothpaymentIDandworkspaceID = Actor.workspace(). If no matching record is found, it throws before making any Stripe API call.No schema changes. No migrations needed. The fix is contained to a single function in
packages/console/core/src/billing.ts.How did you verify your code works?
bun typecheckinpackages/console/core— no errors.PaymentTableschema to confirmworkspaceIDandpaymentIDcolumns exist andtimeDeletedis part ofworkspaceColumns.payment-section.tsx:26) to confirm the function runs inside an authenticated actor context, soActor.workspace()is always available when this function is called.subscription.test.ts,date.test.ts,rateLimiter.test.ts) with no mocking infrastructure.generateReceiptUrlrequires a live DB connection, Stripe API, and SST resource context — testing it purely is not feasible within the current test conventions. The fix is verifiable by code review: the DB lookup is scoped toActor.workspace()before any Stripe call is made.Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.