Skip to content

fix: lock down identity org RPC exposure#1709

Open
riderx wants to merge 1 commit intomainfrom
riderx/fix-apikey-oracle
Open

fix: lock down identity org RPC exposure#1709
riderx wants to merge 1 commit intomainfrom
riderx/fix-apikey-oracle

Conversation

@riderx
Copy link
Member

@riderx riderx commented Feb 27, 2026

Summary

  • Added a migration to remove PostgREST-facing access to identity resolution RPCs (get_identity_apikey_only, get_identity_org_allowed, get_identity_org_appid) from anon and authenticated roles.
  • Reworked public.get_orgs_v6(userid uuid) to enforce that callable user IDs match the authenticated caller identity, preventing user-id probing and unauthorized org membership leaks.
  • Tightened execution grants to keep get_orgs_v6(userid uuid) and identity helpers available only to trusted roles and revoked broad default anonymous/authenticated function/table privilege inheritance for new objects.

Test plan

  • Run bun lint.
  • Review git diff origin/main... for the migration scope and ensure no unrelated objects changed.
  • Apply migration in a non-production environment and verify:
    • get_identity_apikey_only/get_identity_org_allowed/get_identity_org_appid are not callable as anon.
    • get_orgs_v6(<other-user>) is denied for non-service roles.

Screenshots

Checklist

  • My code follows the code style of this project and passes
    bun run lint:backend && bun run lint.
  • My change requires a change to the documentation.
  • I have updated the documentation
    accordingly.
  • My change has adequate E2E test coverage.
  • I have tested my code manually, and I have provided steps how to reproduce
    my tests

@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 27 minutes and 44 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 b63d36c.

📒 Files selected for processing (1)
  • supabase/migrations/20260227000000_fix_identity_oracle_and_org_rpc_exposure.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-apikey-oracle

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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b63d36cc0a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +7 to +8
REVOKE ALL ON FUNCTION "public"."get_identity_org_allowed" ("keymode" "public"."key_mode"[], "org_id" "uuid") FROM "anon";
REVOKE ALL ON FUNCTION "public"."get_identity_org_allowed" ("keymode" "public"."key_mode"[], "org_id" "uuid") FROM "authenticated";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve anon/auth execute on RLS identity helpers

Revoking EXECUTE from anon/authenticated on get_identity_org_allowed (and similarly get_identity_org_appid) will break any RLS policy that calls these helpers for those roles, because policy expressions still require function execute privileges; for example, supabase/migrations/20260226000100_fix_org_rls_2fa_function_permissions.sql defines an anon/authenticated policy that directly calls get_identity_org_allowed, so those requests will start failing with permission denied for function ... instead of applying RLS.

Useful? React with 👍 / 👎.

@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