Summary
A Supabase PostgREST RPC function in Capgo is exposed with SECURITY DEFINER privileges and granted to the anonymous role, enabling unauthenticated data access via a publishable API key.
Because the RPC accepts arbitrary user UUIDs without verifying ownership, an attacker can query organization membership, role assignments, subscription metadata, and management email (PII) for any user.
Affected context
The vulnerability appears in Capgo deployments that use Supabase PostgREST and expose the RPC function public.get_orgs_v6(userid uuid) to the anon role.
The function runs as SECURITY DEFINER, meaning it executes with elevated database privileges relative to the caller.
When clients can invoke this RPC using only a publishable API key and supply arbitrary UUIDs, the system may return sensitive user- and organization-related records even when no authenticated user context is established.
Exploit preconditions
- Attack surface: Public Supabase PostgREST endpoint (
POST /rest/v1/rpc/get_orgs_v6) - Required access: Possession of the public publishable API key or any ability to call the anonymous API endpoint
- Trigger point: Invoking the
get_orgs_v6RPC with a chosenuseridUUID in the request body - Why exploitation is possible: The RPC is SECURITY DEFINER, granted to the
anonrole, and trusts the caller-provideduseridparameter without confirming it matches an authenticated user identity or applying row-level security checks.
Why this happens
The underlying issue is an authorization and data exposure flaw where a high-privilege stored function is bound to an unauthenticated role.
By design, SECURITY DEFINER functions in databases bypass the caller's privilege limitations and can see more data than the invoking role normally would.
In this case, the function accepts a userid parameter directly from the client and uses it to fetch organizational and subscription data without ownership verification or row-level security enforcement.
This maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, where the system returns confidential records (membership details, roles, subscription status, and PII email addresses) to requestors who lack appropriate authorization.
Potential impact
- An attacker may retrieve organization membership information for arbitrary users.
- An attacker could obtain role and permission details that aid in targeted attacks or social engineering.
- An attacker can access subscription and trial metadata, revealing business-usage patterns.
- An attacker may view
management_emailfields, exposing personally identifiable information (PII). - Aggregated exposure of user and organization data can weaken privacy guarantees and regulatory compliance posture.
General mitigation guidance
Effective mitigation centers on ensuring that privileged database functions are not callable by unauthenticated or broadly scoped roles, and that every data access path enforces ownership and authorization checks.
Common defensive patterns include:
- Restricting SECURITY DEFINER RPCs to authenticated roles and integrating them with an identity-aware access control mechanism.
- Validating that any user identifier parameter matches the currently authenticated user or is constrained by row-level security policies.
- Minimizing the data fields exposed by RPCs, returning only the information strictly required for the client use case.
- Applying privacy-by-design principles to segregate PII from general metadata and protecting it with additional access controls.
- Periodically reviewing database functions and API endpoints for over-privileged roles and inadvertent public access.
How teams detect issues like this
Organizations can detect similar exposure issues by:
- Reviewing Supabase and database configurations for SECURITY DEFINER functions granted to anonymous or public roles.
- Using static configuration analysis or schema review tools to flag RPC endpoints that bypass row-level security or ownership checks.
- Implementing code review checklists that require explicit authorization logic for any function returning user-specific or organizational data.
- Monitoring API logs for patterns of access where anonymous clients query data associated with multiple distinct user IDs.
- Applying security policies that prevent publishing RPC endpoints unless they are mapped to well-defined access control rules and identity validation.

