Summary
An information disclosure flaw in Capgo's Supabase PostgREST RPC function public.rescind_invitation leaks whether an organization ID exists by returning distinct error messages.
When invoked using only a publishable API key, unauthenticated attackers can enumerate valid organization identifiers, expanding the potential attack surface for targeted phishing and social engineering campaigns.
Affected context
This vulnerability occurs in Capgo instances that expose the Supabase PostgREST RPC endpoint public.rescind_invitation backed by a SECURITY DEFINER function.
It becomes relevant when:
- Calls to the function are allowed with a publishable (non-secret) API key
- The function returns different error messages for non-existent organizations (
NO_ORG) versus organizations where the caller lacks permissions (NO_RIGHTS) - Clients or third parties can freely probe organization IDs without strong authentication or rate limiting
Exploit preconditions
- Attack surface: Publicly accessible Supabase PostgREST RPC endpoint
public.rescind_invitation - Required access: Possession of a publishable API key or ability to invoke the endpoint with minimal credentials
- Trigger point: Calling the RPC function with different candidate organization IDs and inspecting the returned error code or message
- Why exploitation is possible: The SECURITY DEFINER function leaks authorization and existence details through distinguishable error responses, allowing attackers to infer whether an organization exists independent of access rights
Why this happens
The root cause is a side-channel in error handling logic where the RPC function exposes different failure modes based on resource existence and caller authorization.
This behavior maps to CWE-203: Information Exposure Through Discrepancy, in which the application reveals sensitive state (such as organization existence) because it returns inconsistent error codes or messages for closely related conditions.
In abstract terms, the function does not normalize its responses for unauthorized or invalid inputs, enabling an attacker to use the error channel as an oracle to enumerate valid identifiers.
Potential impact
- Attackers can enumerate valid organization IDs across a Capgo deployment
- Increased likelihood and effectiveness of targeted phishing or social engineering campaigns
- Improved reconnaissance for adversaries planning account takeover or business email compromise
- Potential correlation of organization identifiers with other leaked or public data to refine targeting
General mitigation guidance
Mitigation typically focuses on normalizing error responses and tightening access control to sensitive lookup operations.
Useful defensive patterns include:
- Returning a single generic error for both non-existent and unauthorized resources to avoid existence oracles
- Applying strict authentication and authorization checks prior to running SECURITY DEFINER functions that reference organizational data
- Designing RPC functions so that they do not reveal internal identifiers or state in error channels
- Implementing rate limiting and anomaly detection on endpoints that accept arbitrary identifiers to reduce enumeration viability
- Minimizing reliance on publishable API keys for operations touching organizational or user-related metadata
How teams detect issues like this
Effective detection strategies often combine code-level review and behavioral monitoring:
- Static or manual review of RPC and SECURITY DEFINER functions for branching logic that returns different errors based solely on resource existence
- Policies requiring uniform error messages for authorization and existence failures in API endpoints
- Log analysis to identify repeated requests against the same RPC function with varying organization IDs, indicating enumeration attempts
- Automated testing frameworks that probe endpoints for distinguishable error conditions when given invalid or unauthorized identifiers

