Skip to content

Fix missing session ownership and round-active checks in transaction confirm endpoint#4

Draft
Copilot wants to merge 3 commits intofix/prodfrom
copilot/sub-pr-1-another-one
Draft

Fix missing session ownership and round-active checks in transaction confirm endpoint#4
Copilot wants to merge 3 commits intofix/prodfrom
copilot/sub-pr-1-another-one

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 10, 2026

The PUT /api/sessions/[id]/transactions/[transactionId]/confirm endpoint never validated that the transaction belonged to the session in the URL, allowing any valid transactionId to be confirmed/rejected regardless of session context. Additionally, there was no guard against confirming transactions on ended rounds.

Changes

  • Session ownership check: After fetching the transaction, verify tx.session_id === params.id. Returns 404 (not 403) to avoid leaking cross-session transaction existence.
  • Active round guard: Query rounds table and reject with 400 Round is not active if the round has ended or doesn't exist — preventing mutations after round close.
if (tx.session_id !== id)
  return NextResponse.json({ error: 'Transaction not found' }, { status: 404 });

const rounds = await sql`SELECT * FROM rounds WHERE id = ${tx.round_id}`;
if (rounds.length === 0 || rounds[0].status !== 'active')
  return NextResponse.json({ error: 'Round is not active' }, { status: 400 });

Both checks are applied before the existing partner_id authorization check.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
live-game Error Error Mar 10, 2026 5:40am

Copilot AI and others added 2 commits March 10, 2026 05:31
…ctive in confirm endpoint

Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Co-authored-by: ghostleek <44336310+ghostleek@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on sessions API, DB lib, and UI fixes Fix missing session ownership and round-active checks in transaction confirm endpoint Mar 10, 2026
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.

2 participants