Skip to content

Harden upsert_version_meta RPC auth path#1713

Open
riderx wants to merge 1 commit intomainfrom
riderx/fix-version-metrics
Open

Harden upsert_version_meta RPC auth path#1713
riderx wants to merge 1 commit intomainfrom
riderx/fix-version-metrics

Conversation

@riderx
Copy link
Member

@riderx riderx commented Feb 27, 2026

Summary (AI generated)

  • Added migration supabase/migrations/20260227000000_harden_upsert_version_meta.sql to secure public.upsert_version_meta.
  • Reworked the RPC to verify write authorization for the target app before insert and require p_version_id to belong to that app.
  • Removed RPC execute access for anon and authenticated, keeping execution for service_role only.
  • Kept existing positive/negative size dedupe behavior and kept the return contract as boolean.

Motivation (AI generated)

The RPC was previously callable with publishable anon/auth credentials and allowed arbitrary inserts into public.version_meta, enabling cross-tenant storage-metric integrity issues in downstream aggregation.

Business Impact (AI generated)

This blocks unauthenticated metric-poisoning by external callers and reduces the risk of falsified usage dashboards, alerts, or tenant-level reporting decisions driven by untrusted version_meta data.

Test Plan (AI generated)

  • Run bun lint.
  • Review migration diff with git diff origin/main...HEAD.
  • Run focused backend tests for RPC behavior in an isolated DB environment (precondition for final sign-off).

Generated with AI

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@riderx has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e719357 and 0ae4325.

📒 Files selected for processing (1)
  • supabase/migrations/20260227000000_harden_upsert_version_meta.sql
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch riderx/fix-version-metrics

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 and usage tips.

@sonarqubecloud
Copy link

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.

1 participant