Capgo - Hashed API Key Enforcement Bypass via PostgREST/RLS Plane
Description
Capgo before 12.128.2 contains a security control bypass vulnerability where the PostgREST/RLS plane accepts plaintext API keys through the capgkey header despite enforce_hashed_api_keys being enabled. Attackers can bypass org-level hashed-key enforcement by sending plaintext API keys directly to the PostgREST/RLS plane to access protected resources.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected products
1Patches
Vulnerability mechanics
Root cause
"The org-level hashed-key enforcement check is applied only on the backend plane, while the PostgREST/RLS identity path (get_identity / find_apikey_by_value) accepts plaintext API keys by value without consulting the enforcement policy."
Attack vector
An attacker who possesses a valid plaintext API key for an organization that has enabled `enforce_hashed_api_keys=true` can bypass the org's security control by sending the plaintext key in the `capgkey` header directly to the Supabase/PostgREST REST API, rather than to the backend `/apikey` endpoint. The backend plane correctly rejects the plaintext key with a 401 error, but the PostgREST/RLS plane accepts it through `get_identity(...)` / `find_apikey_by_value(...)` and authorizes access to RLS-protected resources. This creates a policy split where the same key is rejected on one auth plane and accepted on another.
Affected code
The vulnerability spans multiple migration files: `supabase/migrations/20250530233128_base.sql` (lines 2007-2021) reads the `capgkey` header, `supabase/migrations/20250903010822_consolidated_org_apikey_migrations.sql` (lines 27-41) defines RLS policies that use `get_identity(...)`, and `supabase/migrations/20260105150626_fix_is_allowed_capgkey_hashed_apikeys.sql` (lines 26-33) implements `find_apikey_by_value(...)` which matches both plaintext `key` and hashed `key_hash`. The org-level hashed-key enforcement in `supabase/migrations/20251228080032_hashed_api_keys.sql` (lines 132-136) is applied only on the backend plane, not in the RLS identity path.
What the fix does
The advisory recommends applying org hashed-key enforcement in the same identity path used by RLS/PostgREST API-key authentication, specifically that `get_identity(...)` / `find_apikey_by_value(...)` should consult org hashed-key enforcement before returning a usable principal for plaintext keys. The patch is not included in the bundle, but the fix would ensure both planes share one enforcement decision so that if the backend rejects a plaintext key for an org, PostgREST/RLS rejects it too.
Preconditions
- configThe target organization must have enforce_hashed_api_keys set to true
- inputThe attacker must possess a valid plaintext API key that was created before enforcement was enabled
- networkThe attacker must know the Supabase project URL and be able to send HTTP requests to the PostgREST/RLS REST API
Generated on Jun 24, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
2- github.com/Cap-go/capgo/security/advisories/GHSA-6g74-8cpq-g2c8mitrevendor-advisory
- www.vulncheck.com/advisories/capgo-hashed-api-key-enforcement-bypass-via-postgrest-rls-planemitrethird-party-advisory
News mentions
0No linked articles in our index yet.