Skip to content

fix: stop world-readable exposure of private session metadata (#1926) - #1932

Open
atul-upadhyay-7 wants to merge 2 commits into
durdana3105:mainfrom
atul-upadhyay-7:fix/private-sessions-metadata-1926
Open

fix: stop world-readable exposure of private session metadata (#1926)#1932
atul-upadhyay-7 wants to merge 2 commits into
durdana3105:mainfrom
atul-upadhyay-7:fix/private-sessions-metadata-1926

Conversation

@atul-upadhyay-7

Copy link
Copy Markdown
Contributor

Fixes #1926

Problem

The sessions SELECT policy "Anyone can view sessions" uses USING (true) with no role restriction, so both anonymous and authenticated users can read every session row — including invite-only is_private = true sessions. This leaks private session titles, descriptions, mentor identities, and scheduling details. session_participants has the same open USING (true) SELECT, leaking who attends private sessions.

Changes

New migration 20260805000003_restrict_private_session_visibility.sql:

  • Drop the broad SELECT policies on sessions ("Anyone can view sessions", "Authenticated users can view sessions", "sessions_select").
  • Add anonymous_cannot_view_sessions — anonymous users see no session rows.
  • Add authenticated_users_can_view_sessions — scoped to:
    • public sessions (is_private = false),
    • sessions the user mentors (mentor_id = auth.uid()),
    • sessions the user is invited to (session_invites),
    • sessions the user participates in (session_participants).
  • Apply the same access rule to session_participants SELECT (scoped + anon-deny).

The SECURITY DEFINER join_session() RPC and the app's authenticated session queries are unaffected.

Verification

  • All frontend from("sessions") queries live in authenticated pages (Dashboard, Sessions, MentorDashboard, widgets, hooks) — they keep working since public sessions remain visible.
  • No landing/anonymous page queries sessions.

…ry (durdana3105#1925)

Authenticated users could delete their own leaderboard row and re-insert it
with arbitrary xp/streak/badges values, bypassing the UPDATE hardening from
previous migrations. Drop the permissive INSERT/DELETE RLS policies and revoke
those privileges from anon + authenticated; join_leaderboard() remains the
only row-creation path.
…a3105#1926)

The sessions SELECT policy (USING true, no role restriction) exposed every
session row - including invite-only is_private=true sessions - to anonymous
and authenticated users alike. session_participants had the same open policy.

Replace with an anonymous-deny policy plus a scoped authenticated policy that
only allows viewing public sessions and sessions the user mentors, is invited
to, or participates in. session_participants follows the same access rule.
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

@atul-upadhyay-7 is attempting to deploy a commit to the durdana3105's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@atul-upadhyay-7, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1826530f-322b-481b-ab40-20b259e615cb

📥 Commits

Reviewing files that changed from the base of the PR and between 880eed9 and 06e72cc.

📒 Files selected for processing (2)
  • supabase/migrations/20260805000002_block_leaderboard_client_insert_delete.sql
  • supabase/migrations/20260805000003_restrict_private_session_visibility.sql

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Security] Private study session metadata is world-readable, including by unauthenticated users

1 participant